Jump to content

Code design\improvement help

- - - - -

  • Please log in to reply
2 replies to this topic

#1
tier

tier

    Learning Programmer

  • Members
  • PipPipPip
  • 36 posts
Hi,

I have been programing for a project (~ 6 classes and ~1,600 lines) for the last 2 weeks, but I suspect the code design not that strong/
Where can I find some guidelines \ material about correct design + packaging + programming in a robust\good way?

Thanks.

#2
Sinipull

Sinipull

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 386 posts
Bruce Eckel - Thinking In Java is a great book with a lot of examples.
.

#3
LukeyJ

LukeyJ

    Learning Programmer

  • Members
  • PipPipPip
  • 93 posts
Look up cohesion and coupling.

Your classes need to fit 1 role (cohesion) and class a/ class b should work well together without knowing anything about how the other works. Implementation details should be hidden behind the interface (public methods and variables). This means that if the underlining behaviour of class B changes, then class A will still happily work without any changes to its own implentation. For example, say if you get your information from a database, or a text file, or a properties file, it will not matter. It just gets the information it needs from the class.

Really good design is MVC, especially in web development, where your business logic is seperated from how data is presented (your view/interface) as well as being seperated from page flow and access control (controller). Either way, that's a good start in terms of things to read up. Technically your business logic should be seperated from the persistance code (code that saves the data (database or file)).

Might be worth looking at object oriented principles too, encapsulation and inheritance, plus polymorphism too if you're really interested.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users