Organizing and visualizing a growing project.
Members - Reputation: 828
Posted 14 June 2012 - 09:56 AM
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?
Members - Reputation: 525
Posted 14 June 2012 - 01:17 PM
Not sure how that helps though.
Prime Members - Reputation: 643
Posted 14 June 2012 - 01:54 PM
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).
Members - Reputation: 221
Posted 14 June 2012 - 02:54 PM
- 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.
Members - Reputation: 586
Posted 14 June 2012 - 03:01 PM
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, 14 June 2012 - 03:05 PM.
Members - Reputation: 828
Posted 15 June 2012 - 05:38 AM
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 )
turch: 30000, 50000 lines of codes. Oh wow. I am having trouble with 1000+ lines already.
Edited by Legendre, 15 June 2012 - 06:15 AM.
Validating - Reputation: -39
Posted 17 August 2012 - 05:13 AM
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...)
Crossbones+ - Reputation: 5598
Posted 17 August 2012 - 07:15 AM
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.
So, your idea of organized code is removing all whitespace and newlines 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).
The number one priority for me is O.C.D. style programming and constantly moving code around to keep everything organized.
Also, kind of a necro... heh
Edited by Bacterius, 17 August 2012 - 07:16 AM.
"The best comment is a deleted comment."
Validating - Reputation: -39
Posted 17 August 2012 - 10:13 AM
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.