views:

69

answers:

3

I was wondering what methods of code organization stackoverflow users use. I have a sporadic thought process and as a result my code can start to look messy and over whelming. Any tips ?

+1  A: 

Keep methods short and give classes a single, clear responsibility.

It's not necessary, but TDD can help you acheive this

Rob Fonseca-Ensor
+1 this was pretty much what I answered, just noticed you beat me to it
kekekela
+1  A: 

One file per class.

Folders for related classes.

Use modules/packages/assemblies/namespaces if your language supports them.

In general, keep many levels of abstraction, and try to keep them separate through whatever mechanism you can in your language/ide/platform of choice.

Read Domain Driven Design, which discusses these issues (design, documentation, organization and communication).

Oded
A: 

I would suggest looking at the principles of Large Scale C++ Software Design by John Lakos (ISBN-13: 978-0201633627) if not the book itself. They are summed up in these lecture notes. Another summary of ideas.

Here's a brief outline of the headings of the principles, which while written about in the C++ context, the geist of which are language agnostic.

  • Internal and External Linkage
  • Components and Dependency Relations
  • Physical Hierarchy Reducing Link-Time
  • Dependencies: Levelization Reducing
  • Compile-Time Dependencies: Insulation
mctylr