The Pragmatic Craftsman         :: Simplicity from complexity :: | About Me |

You are here: The Pragmatic Craftsman > Better Coder

Go to: « Keep Your Methods Cohesive: Short and Concrete | Excellent CareerNews Newsletter »

OO Design Heuristics for Classes and Objects (Riel)

Writing good OO code is not easy. Here's a set of rules of thumb when creating classes. These are taken from the Object-Oriented Design Heuristics book by Riel -- good stuff.

    2.1 All data should be hidden within its class.

    2.2 Users of a class must be dependent on its public interface, but a class should not be dependent on its users.

    2.3 Minimize the number of messages in the protocol of a class.

    2.4 Implement a minimal public interface that all classes understand [e.g., operations such as copy (deep versus shallow), equality testing, pretty printing, parsing from an ASCII description, etc.].

    2.5 Do not put implementation details such as common-code private functions into the public interface of a class.

    2.6 Do not clutter the public interface of a class with things that users of that class are not able to use or are not interested in using.

    2.7 Classes should only exhibit nil or export coupling with other classes, that is, a class should only use operations in the public interface of another class or have nothing to do with that class.

    2.8 A class should capture one and only one key abstraction.

    2.9 Keep related data and behavior in one place.

    2.10 Spin off nonrelated information into another class (i.e., noncommunicating behavior).

    2.11 Be sure the abstractions that you model are classes and not simply the roles objects play.


Reference
Object-Oriented Design Heuristics, Riel


Comments

Post a comment









Remember personal info?







Go to:
   « previous entry: Keep Your Methods Cohesive: Short and Concrete
   » next entry: Excellent CareerNews Newsletter

Random Quote

Search

 

Topics

Architecture & Design :12
Better Coder :29
Books :43
Books Recommended :18
Buzzwords :5
Career :25
Craftsmanship :15
Java :15
Quotes :25
Recommended :9
Software Engineering :3
Uncategorized :33
Web Development :1

Archive

May 2008 (1)
April 2008 (2)
March 2008 (1)
February 2008 (1)
January 2008 (2)
November 2007 (1)
October 2007 (3)
August 2007 (3)

...since January 2002

Currently Reading


:: See list of books I finished reading

Info

© 2001-2008 Stanley Kubasek About me :: Contact me