Brain dump: considerations for organizing code

Published September 09, 2014
Advertisement
No structure or real nice formatting will be found in this post. This is a stream-of-consciousness blathering process wherein I contemplate how to organize code in a way that escapes the limitations of the file paradigm.



Considerations for organizing code
Main goal: aid in discoverability and navigation of complex code bases. Secondary benefit could be that complicated architectures will be correspondingly "messy" to look at, encouraging cleaner design.

Files suck because:

- They force revision history to occur at the file level instead of the unit-of-code (function/etc.) level. Move a function into a new file and POOF goes its revision history. This is lame.

- They imply a single view of code which may not be the most expedient way to look at code "right now". Working on functionality that spans multiple files is a classic example; I have to change files all the time when the chunk of code I'm conceptually editing has nothing to do with these dumbass file divisions.

- Files as modules or other semantic implications of file separation are FUCKING EVIL (Java I'm looking at you). There should be no forced correlation between the code storage mechanism on disk and the conceptual organizationS (emphatically plural) of the code at a high level.

- Where the fuck did that function go? Sigh, time for grep. This is lame if you misspell the function's name or can't remember exactly what it's called. grep cannot search for IDEAS. Files are not directly to blame for this, but the forced implied taxonomy of code based on files exacerbates the problem significantly.

- They unnecessarily complicate code reuse. I should be able to reuse just that function, or that entire group of related code, or whatever - independent of shuffling files around. This should tie in to revision history too so I can see the history of a function when I steal it for another project.




Other assorted thoughts:


Avoid the sin of only being able to see tiny fragments of code at a time, ala early Visual Basic; ensure that a comfortable volume of code is always at hand to be edited and browsed.


Would be nice to have some kind of graphical visualization of the code taxonomies created by the programmer.

I want a way to select groups of functions to view together; checkboxes are lame; lasso?


"Search for code unit by name" as first-class IDE feature, including full language parse?


How do we minimize reparsing without having to write a standalone incremental parser?


Parsing != semantic checks; maybe the former can be done fast enough for realtime work, and maybe that justifies keeping the semantic work as semi-modal operations?
6 likes 5 comments

Comments

popsoftheyear

Glad to see you working on things-Epoch again!

September 09, 2014 04:11 PM
polyfrag
Thanks for this interesting post
September 10, 2014 08:42 AM
Sporniket

I agree on the Java rant on one point, that is the matching between package name and folder nesting, on the fact that the relation ship between folders (a subfolder is a part of the parent folder) does not translate into a relationship between the packages (the two packages are not related in any way).

On the other hand, I am fond of nested static classes to model the close relationship between a set of classes, the main class being the main concept being modelized. The downside being the file size, and such subclasses MUST be specific to the main model.

September 10, 2014 03:26 PM
nukomod
Have you seen code bubbles?
http://www.andrewbragdon.com/codebubbles_site.asp

I think their approach may be of interest to you.
September 11, 2014 09:27 PM
Gregory Cheyney

Oh but I've never failed to find a method where I remember part of the method name or line of code, while using NetBeans IDE and its search features....

September 14, 2014 04:36 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement