6

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?

Nietzche-jou
  • 14,415
  • 4
  • 34
  • 45
Peter
  • 93
  • 4

4 Answers4

2

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.

N 1.1
  • 12,418
  • 6
  • 43
  • 61
2

Read Clean Code by Robert Matin

Dave Kirby
  • 25,806
  • 5
  • 67
  • 84
  • 3
    No, don't. Or any other book by that blowhard nitwit. –  Apr 18 '10 at 18:45
  • 4
    I sense that Neil might dislike that author, but I'm not sure. – GManNickG Apr 18 '10 at 18:46
  • @Neil: Any specific reason why you wouldn't recommend this book? – Kris Apr 18 '10 at 18:50
  • I think that Clean Code requires that the reader has seen some dirty code.. so not the first book I would recommend. – mkorpela Apr 18 '10 at 18:56
  • 1
    @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. –  Apr 18 '10 at 19:06
  • 1
    @GMan My shrink told me not to bottle up my feelings. –  Apr 18 '10 at 19:39
  • 2
    @greyfade Cruel to Herb, I know, but he's survived much worse. –  Apr 18 '10 at 20:59
1

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
  • 33,261
  • 11
  • 73
  • 81
  • 1
    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. –  Apr 18 '10 at 18:36
  • sure, but he asked for any resource, not a definitive all-encompassing solution. – Tor Valamo Apr 18 '10 at 18:38
1

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
  • 1,036
  • 12
  • 21