From: Srinivas Nayak on
Dear All,

This is a unfortunate-problem of everyday life to every programmers.
What are the simple guidelines to choose my classes for my problem?
We would like to gather some thumb-rules from our own experience.

This question arose, when I encounter two very different OOP approach.
1. For every word uttered in the requirement, we can write a class.
2. Most restrictive approach where it is forbidden to add one more
class.

Obviously, the above two approaches are not correct, for they
represent two extremes.
Question is now, where shall I stop adding more classes? What are the
simple guidelines/thumb-rules to choose classes for my problem?

Here interest is not on any particular type of problem. Guidelines
need be very generic, applicable to all problems that can better be
solved with OO technology.

I will be happy to listen from your own experience.


Sincerely,
Srinivas Nayak
From: Daniel T. on
On Aug 11, 1:46 am, Srinivas Nayak <sinu.nayak2...(a)gmail.com> wrote:
>
> This is a unfortunate-problem of everyday life to every programmers.
> What are the simple guidelines to choose my classes for my problem? We
> would like to gather some thumb-rules from our own experience.
>
> This question arose, when I encounter two very different OOP approach.
> 1. For every word uttered in the requirement, we can write a class.
> 2. Most restrictive approach where it is forbidden to add one more
> class.
>
> Obviously, the above two approaches are not correct, for they
> represent two extremes. Question is now, where shall I stop adding
> more classes? What are the simple guidelines/thumb-rules to choose
> classes for my problem?
>
> Here interest is not on any particular type of problem. Guidelines
> need be very generic, applicable to all problems that can better be
> solved with OO technology.

Although I already answered this question with the standard "it's not
easy, here are some books" approach, I slept on it and I have a much
more pithy answer.

1. Classes are custodians of invariants.

2. Classes allow the function that decides "what to do" to be
different from the function that decides "when to do it."

These are the two main reasons I make classes. I hope it helps.
 | 
Pages: 1
Prev: Now comes Zephyr v3.0
Next: On choosing classes.