So

I'm a hobbyist programmer. I wrote a small piece of game code (about 300 lines, 2 files, 1 class, 2 functions), and a friend of mine, who is a professional software developer, pulled it from my github.

He handed it back to me two days later, and it is now like 20 files, 10 classes, 500 lines of code, everything is created dynamically, and main function that has like 4 lines in it.

What sorcery is this?

Other urls found in this thread:

github.com/HexInjector/documents/tree/master/c/sdl
github.com/codywizlet/LeoClean
en.wiktionary.org/wiki/anecdotal
github.com/codywizlet/LeoClean/issues/1
twitter.com/SFWRedditGifs

He modernized it by using using cutting edge cross-functional development techniques.

in laymans terms


he crapped it up

he pood init

Prefer object composition over inheritance, and keep your main() function as simple as possible.

That said, if he has 20 files and 10 classes with only 500 lines of code, he's almost certainly retarded.

>500 lines across 20 files
Sounds like Java and that's before we even get to the Sup Forums boogeyman (OOP).

Is it object-oriented?

>▶
It is C++

>and keep your main() function as simple as possible
Why though? I'm starting to program and if this is a good habit, I'd like to start practicing it but knowing why I'd do it.

Link to your original repo and the reup from this supposed "pro" please.

Autism

Makes it easier to understand what the program does i.e. gives you a summary of major function calls made.

Learn about software design pattern, user!
I guess His main function most likely just need to instantiate a controller class or a factory class and then run it.

Your main function should be very clear and make calls to some methods with well thought out, high level names. Just makes it easier for someone who didn't write it to understand since if you work in industry youll be working with a ton of shit lords.

dont listen to these fuckers. it is completely anecdotal to the program

Mine:
github.com/HexInjector/documents/tree/master/c/sdl

Pros:
github.com/codywizlet/LeoClean


be cool. i know i suck.

>completely anecdotal

I don't think this word means what you think it does.

yes it does

it means that it is completely dependant on what type of program it is

Idiot OOP code-moneys think you need to put every class in it's own file, and sometimes every function and codeblock too, and if your program doesn't take 2 minutes to start, it isn't enterprise quality.

Every function call should be in its own file.

Well, you see a function should only do one thing and be easily described by its name. Even on non-oop program you shouldn't have that long main function.
What's the benefits?
- other programmer can easily tell what a function do
- can be reused on other occasion.
- testable using unit test.
As I said before, learn this thing called design pattern, boy

That's not what it means.

en.wiktionary.org/wiki/anecdotal

Not the guy who called you out, but no, no it doesn't.

>not placing every statement in its own file

You don't want to be able to read your code from the file manager?

>trying to warp the definition of a word that kind of makes sense but actually doesn't in the context that you used it

>being this autistic

I do this with the thought that my main class essentially scripts things while the methods actually perform work. when looking at main it is as close to spoken english as is reasonable

>fuck I lost
>I know I'll call him autistic

STOP PLS YOU ALRDY WON

Refactored code is much more readable.

>change a single character
>have to recompile the entire program

>What sorcery is this?

software development. read a book bitch

Their culled ebuk beesh.

I actually prefer to base32 encode each statement into the hostnames of all the machines on my network ordered by ip address and use subnetting for blocks and control flow.

tfw even his hyperlink is cleaner than yours

Kek kek
github.com/codywizlet/LeoClean/issues/1

What a dick, the cleaned up code isn't that bad, at least not as far as "the most horrifying monstrosity to ever touch Github", talk about being overdramatic.
>holy shit, this guy split up some spaghetti C++/C franken-code into like 5 manageable C++ classes!!! wtf!!!

Looking through his github I see he's got pretty much no OOP experience, what a surprise. I guess if you've never touched OOP something simple like this probably would frighten you.

Can we get the link? Current on the code

Non-coder here but isn't the point of corporate coding to obfuscate as much as possible so you get to keep your job?

I'm not sure why people get worked up about numbers of lines and numbers of files. These aren't metrics of anything important. The fact that your version only has 2 functions leads me to think you either aren't doing very much or you crammed a ton of logic into a rigid organization that's probably hard to understand, extend, or maintain.

no.

that's how you get fired.

it's 2017, people don't live in a tech vacuum anymore.

A easy tip to improve is:
NEVER WRITE SOMETHING A THIRD TIME
Copy paste counts too !
Use functions instead
In many cases its ok to write something twice, but never a third or fourth time.

Tbh my code can look like either of those or anything in between depending on how large or modifiable I intend for it to be/how lazy I feel
Although the 'pro' not having fucking multiline full-description comments on everything makes me feel better about hating the people who do.

dont use clases or functions.
just retype everything and keep it all in the main.

>friend tries to help you learn
>you post his code on Sup Forums
Of course was going to happen OP. Be a little nicer to your friends.

lol well he's a busy guy, and I wanted to get some insight on why he would make some of these changes.

ever wanna be the best at any cost? being coy here.

If your functions have more than 50 lines, it's time to refactor.

Check Derek Banas tutorials on youtube. What hes doing is basically what every programmer does: adding modularity. Data and function organization in classes.

It becomes simpler to change or reuse some parts of the code.

I know jack shit about code optimization though (compiling and perfomance speeds "oooh da shitty pointers" and "the trenary operator is better/faster/slower than this if else or switch case).

Here's why someone would redo it this way:

- the original code is about 300 lines, but was that all the functionality that would be in there? If not, refactoring to the 5 or so classes (Player, Game, Projectile, World, Renderable) could make it easier to add the functionality that is missing and reuse. What if you want the player to do something else, etc? In the original code, would you then add it as another switch statement / if statement deeper in your main method? What's there currently in the original code is already hard to understand -- how much harder to understand will it be once you add something besides just a character moving and jumping with a static background?

- Yeah, it looks a bit overkill for the short program, but if there should be more stuff going on, those classes are encapsulating the different parts of the program from each other. In code for the world, you can't accidentally mess up variables from the player for instance.

- There are twice as many files as classes because C++ has header files. Some other OO languages don't have header files.

>404
what a fag
anyone got archive?