ID:2487868
 
So I have been learning coding for the last few weeks by messing around with code. I often find that code from even fully functional games is designed incredibly messy. So could anyone give me pointers on what a well organized code file SHOULD look like and if/when sometimes necessary exceptions must be made for the purpose of functionality?

For example, what I am working on right now has 10 different trees at the lowest level in the object tree. And things seem defined in random locations wherever it happened to be convenient. You could take a given function such as "Attacking" and "Skills" and anything pertaining to combat and the definitions are everywhere even in random files that you wouldn't think to look for such definitions. Wouldn't a well coded file have one location with all of its relevant functions and definitions in the same place?

Basically if you were to be hired to work on a project that already has all of it's primary coding completed and you were tasked with a goal of organizing said code, how exactly would you go about it? What should a "proper" object tree look like and how could you define the code it represents as "well organized"?
Basically, it's organized code until you see it.
Can confirm.
look at ss13 and do the exact opposite
In response to Optimumtact
LOL, what are you doing here Oranges?
Do children objects match the category of their parent? If no, move them somewhere they do.

Is common code reused elegantly or just copy pasted to oblivion? Inheritance, utility modules.

Do objects with similar uses have similar names? Is it easy to guess what something does just by reading its name and path?

Is then code spaced and organized similarly across files or have the developers never agreed to a style?

Is there code which is never used? Or better yet do you have a bunch of code which got commented out long ago and has never been addressed?

Do comments state the obvious or do they provide useful information that couldn't easily be gained from a glance? I dont need to know the method adds something to your inventory if it's literally called inventory.add(). Dont bother.

Do you have modules that could probably be moved together instead of being separated? Some people go module crazy and have esoteric modules that only make sense to their developer and to no one else.

Do you have redundant code? Two things that do the exact same thing in different places? Pick one and share it.

Do you have variables that are long chains of parents and children? mob.inventory.slots[2].effects.fireResistances.max? Consider helper methods. Resistances.max(mob, 2, "fire")
See here, and click all the links:

https://en.wikipedia.org/wiki/Code_smell

Login to reply.