Note that this is written before reading actual article. Here are my thoughts on the subject.
I always try to keep my code readable, simply because I often "jump between projects" - I have three Pascal projects right now (game engine, Super Heli Land and DCPU-16-like virtual processor) and two RPG Maker ones (plus one on hiatus until I'll get more skilled with RM because of magnitude of it) and when I get bored with one project I am going to other. So often I have few month breaks from one project.
Because of it, I've learned to write easy to read code. For my identifiers (variables, procedures and functions) I'm using CamelCase (with first letter upper case), for constants it is all uppercase. Sometimes for procedures/functions I'm using underscore_notation, but only when code readability suffers from usage of CamelCase or when I'm writing some library and want to visually separate its name (example: DarkhogGui_DrawButton).
I also do lots of commenting. Even most insignificant and obvious line should be IMO commented, because after few months you won't know what it does.
It happens to me too. I usually put comments after I'm certain code is doing what is supposed to do.
Yeah, about that... I'm not big fan of "self documenting code". I had many times read code that was supposed to be "self documenting one" but wasn't easy to grasp (though easier than if variables were called "Variable1","Variable2", etc. and functions "Function1","Function2",...). And it was both Pascal and other language code (which includes so easy, at least for me, languages like C# or Java).
In my opinion nothing will help more than properly documented code. Even comments like "this function is supposed to do..." before function body are good.
I hate comments in the code,it just makes it harder to visualize the actual code. I really hate people who indent 8 char at a time, 2 is enough.
I don't hate coments in the code unles they span through several lines. Those can realy make hadred to visualize the code.
The best thing to help bisualize the code are region definitions and code folding that is of course if they are used properly. It is to bad they are somwheat broken in Delphi. If you make any syntactical error all the code that is below that point gets unfolded automaticaly. This unfortunately makes code foldin almost uselsess in Delphi.
I myself use 4 char indents mosty 2 in type declarations only. The main reason for this is old practice from Delphi 6. Since Delphi 6 didn't support automaticly adding "end;" after every "begin" I dah to rite all those ends by myself. And since end is 4 characters long I kept 4 char indets as it alowed me to simply pres UP arrow key to get in place for writing the code inside the method I just started to write.
I hate code folders as well. to me they are simply a bandaid to an editor design that should have went away long ago. with the Explorer I have an editor design that allows me to qucikly move to where I want to work and see only what I am working on.
I don't think I quite folow what you wanna say.
These days follow code conventions is just a obligation. People just not accept non-standard code anymore.
I believe the next step to code quality is to focus in a reusable design and eliminate redundancies. Today I see in many production projects redundant code in many levels - some people make ctrl+c and ctrl+v in many lines of code or even a entire unit to make a new form looks like the other.
Another problem is bad design - giant functions that do many things and are completely specialized and not-reusable.
Unnecessary coupling is very common in Delphi - specializing units that could be more generic and reusable.
Bookmarks