Sign in to follow this  
Legendre

Organizing and visualizing a growing project.

Recommended Posts

Legendre    985
The browser-based game that I am programming has grew to over a thousand line of code. When I am actively developing, I have no problem keeping track of what everything does and where everything is, especially since I wrote all the code from scratch so there isn't any huge cut and pasted chunks.

The problem is, if I stopped developing for say a week and return to the code, I find that I have to refresh my memory of how everything flow. I was wondering if there are any standard ways of organizing and visualizing (flow chart, graph etc) code to give me a rough idea of what the parts/modules are and how they are connected?

Share this post


Link to post
Share on other sites
Ripiz    539
Visual Studio 2012 is able to draw diagram of classes, but it gets real ugly when it comes to templates.
Example: http://img69.imageshack.us/img69/8638/94015431.png
Not sure how that helps though.

Share this post


Link to post
Share on other sites
deftware    1778
I suffer from this problem regularly and it's time-consuming to 'surf' my code and get re-acquainted, "ahh, i see". Even just going from one project to a sub-project, like a tool or something that only works with a specific protocol or format can disorient me upon returning to work on the main project. I have tried everything but nothing seems to work more than just keeping my memory fresh and healthy - yes, I actually watch how I treat my body for the sake of maximizing coding enjoyment and success! But I'm just crazy like that.. I have used Freemind, a freeware mindmapping program, as well as http://bubbl.us, which is an online web-based mindmapping application that allows for a few other things that freemind doesn't, and it looks nicer, but you only get 3 'maps' before you have to pay to get more. The cool part is being able to access your maps from anywhere, any machine, just using your account credentials..

I've also discovered over time that there are two dimensions to program structure: code structure, and data structure. With most OOP projects they can be one-and-the-same, but sometimes some objects tend to be more functional, eg: they get data from somewhere else and then output data to somewhere else, or maybe the same place... but they don't contain data themselves.

So perhaps you could de-couple execution from data to resolve the issue Ripiz mentions above and draw everything out by hand. I recommend bubbl.us, because it allows child-bubbles to be connected to-and-fro, whereas Freemind is limited in that regard (only parent-to-child links, AFAIK).

Share this post


Link to post
Share on other sites
Tristan85    221
In my current and past projects, several things have helped me to keep track of code structure:
- strive for a clean design with minimal dependencies between parts (as these are hard to keep track of)
- make code as "self-documenting" as possible (i.e. use descriptive variable, class and function names)
- make UML class and/or activity diagrams depicting the public interfaces of high-level components
- when working in a team, make sure a single team member is responsible for each piece of code (so you can quickly ask a person to refresh your memory)
- use comments wisely (in my opinion, never to explain syntax...always to explain semantics)

Something I don't do quite often enough, but which might help as well:
- create unit and/or integration tests that demonstrate typical use cases for a (collection of) class(es).

I hope this might help a bit, and would be interested to read some additional insights.

Share this post


Link to post
Share on other sites
turch    590
Good commenting isn't just for other people to read. I'm currently working on a project with about 30,000 lines of code according to cloc (and that's not even that much, I worked at one place that had over 500,000 lines of code and I swear you could ask the senior dev about a line number in a file and he could explain exactly how it worked from memory); there are two of us working on it and we tend to jump around subsystems fairly often. The only reason we haven't gone mad is that we put a lot of effort into documenting it [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

I don't really like UML / diagrams for documentation, as they are much more time intensive to change and tend to get out of date much more easily than code comments. Though there are tools around for automatically generating diagrams, those do help. Edited by turch

Share this post


Link to post
Share on other sites
Legendre    985
Thanks for the input guys.

radioteeth: bubbl.us is so useful for my non-programming work as well, excellent suggestion! (edit: bubbl.us is not free, but it looks quite cheap, signed up for a month to try [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] )

turch: 30000, 50000 lines of codes. Oh wow. I am having trouble with 1000+ lines already. Edited by Legendre

Share this post


Link to post
Share on other sites
Estabon    39
Few random jumbled up tips:
Personally, I never use comments. As stupid as this may sound. When I code, I think in code. If I know I've just writen something that sketchy, I'll waste a half houring figuring out a re-write. If I have a section that is tediously taking up a lot of space.. I'll just get rid of all the white space and bunch it togeather in a stupid blob of code. <-- It sounds stupid but cutting back on a bunch of lines that eventually only do one thing is totally worth it, until I feel like re-writing it. The number one priority for me is O.C.D. style programming and constantly moving code around to keep everything organized.

Other jumbeled up tips:
Basically, you can try whatever you want. But, just make sure you ask yourself while working on the code if it's something you would understand and not just something you get a the moment because you're working on it. If you work alone, you're free to move everything around and completely change it up. Just make sure you keep your stuff backed up. Don't be afraid to spend that day doing something stupid like changing the structual integrity of your entire programming. The worst that could happen is that you've messed everything completely up and have to start over tomorrow. But, tomorrow you'll really see your code a whole for everything it is. It dosn't hurt to waste time relearning your work, or making mistakes.

(p.s. I'm really bad at message boards. Seriously...)

Share this post


Link to post
Share on other sites
Bacterius    13165
[quote name='Estabon' timestamp='1345202025' post='4970506']If I have a section that is tediously taking up a lot of space.. I'll just get rid of all the white space and bunch it togeather in a stupid blob of code.[/quote]

[quote name='Estabon' timestamp='1345202025' post='4970506']The number one priority for me is O.C.D. style programming and constantly moving code around to keep everything organized.[/quote]
So, your idea of organized code is removing all whitespace and newlines [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] Personally if there's a piece of code that I know I won't be touching for a while, and is getting in my way, I'd just fold it (nifty feature IDE's and some text editors have).

Also, kind of a necro... heh Edited by Bacterius

Share this post


Link to post
Share on other sites
Estabon    39
I just don't pay attention to any of this stuff.. heh. I actually had to google necro because I knew it was funny that you were saying I fuck dead bodies. So yeah, I just fucked a old nasty topic. And, I'm not ashamed for it.

I personally don't like the folding in C++ express. It's throws me off. I won't remove all the whitespace, but rather clump it together so my source code will still compile and get a quick overview on each possible parameter in that clump and think about how I'm going to apply it to my code in a cleaner way. When I see that chance I'll do it, and my code will make more sense in the end. I like to upgrade everything in that way.

The reason I don't like the folding feature is because if it's really big, I wouldn't be in the mood to expand 100 . I'd rather just keep it a clump of 30 line to get a feel for what variables, arrays, or functions, parameters or whatever I'd have to come up with to code it better.

I hope I make sense because I feel like I'm rambling and talking stupid. I'm really bad at explaining computers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this