views:

172

answers:

4

I'm a computer science student, and I'm just starting to write relatively larger programs for my coursework (between 750 - 1500 lines). Up until now, it's been possible to get by with any reasonable level of modularization and object oriented design. However, now that I'm writing more complex code for my assignments I'd like to learn to write better code.

Can anyone point me in the direction of some resources for learning about what sort of things to look for when designing your program's architecture so that you can make it as modularized as possible?

+3  A: 

This question has been asked here before, and the answer has generally been there is no such book. The reason for this is that there are no "rules" that can be applied to the problem - you have to go on experience. My experience is that you should write multiple libraries with a clear, singly directed dependency graph, but beyond that I wouldn't like to commit myself.

anon
+1  A: 

There is one important thing which will make it easier when developing modular apps, or even turning an app modular at a later point, which is Dependency Injection.

It allows your modules to work separately of everything else, as it receives whatever data it needs to perform its task, without needing to know anything about the application itself.

It may take some experience to produce good quality context-neutral DI code, which is why it's important to begin thinking about and experimenting with it as soon as possible.

Tor Valamo
That's one way of designing code - there are lots of others. I, and many, many others manage to write modular code without using it.
anon
sure, but he asked for any resource, not a definitive all-encompassing solution.
Tor Valamo
+2  A: 

Read Clean Code by Robert Matin

Dave Kirby
No, don't. Or any other book by that blowhard nitwit.
anon
I sense that Neil might dislike that author, but I'm not sure.
GMan
@Neil: Any specific reason why you wouldn't recommend this book?
Krystian
I think that Clean Code requires that the reader has seen some dirty code.. so not the first book I would recommend.
mkorpela
@Krystian The reviews I've read of it, my experiences of his other books, and his posts on usenet over the years. I'd class him as the Herb Schildt of the bullshit circus.
anon
@GMan My shrink told me not to bottle up my feelings.
anon
@Neil: *"Herb Schildt of the bullshit circus."* Harsh words.
greyfade
@greyfade Cruel to Herb, I know, but he's survived much worse.
anon
+1  A: 

refactoring by martin fowler is the book that has helped me most among the 20 or so books that I have read on oo, patterns, test driven development and general software engineering over the last two years. particularly the section on smells can help you see what you need to avoid as you are developing more complex code.

derdo