Re: How much OO is too much OO?



Veloz wrote:

Hello

There seems to be lots of information out there on how to use good OO
practices, principles and patterns, but it's not clear to me how far
to go with these, and when.

It seems some people go full tilt with all projects. For example, I
read one post where the author states his base classes are always
abstract and he never programs to concrete classes, but to interfaces,
and so on.

Others maintain that most of these practices are irrelevant until/
unless you need to make a change to your program and find out that
it's inflexible or hard to grow in a certain area. Or, of course, if
you know up front that a part of your design will vary, then
encasulate that part of the design.

I guess I'm looking for some advice on what a good rule of thumb is.
Should you really always have abstract base classes, even if you can't
imagine ever needing a different branch of your class hierarchy?

Should you really delegate every part of an algorithm that you can
possibly think of *just in case* you need a variation someday?

I am currently working on my first application in .NET and have re-
worked my design countless times.. sometimes feeling that my design is
very rigid because all I have are concrete classes and only one place
I can clearly see a need for some delegation .. and at others times
feeling that for just two small use cases I have created an unwieldy
amount of abstract classes, interfaces, and indireciton mechanisms.

Ugh!

Michael

Hello, Michael,

There are no strict rules that I know of.

There are no rules that say, "Use concrete base classes in these cases, but
never in those cases."

It's all judgement. (This shouldn't undermine judgement, of course: it's
judgement that keeps companies afloat and gives consumers precisely what
they want to consume.)

I can only suggest the limits within which I work: use interfaces when
dealing with inter-name-space dependencies. In other words, use Facades
once your dependencies leak between name spaces.

Your question, therefore, is at least limited (in my experience) to
intra-name-space dependencies (i.e., between classes private to a name
space); and so - and this is the point - if you make the wrong decision
then at least the damage is limited to one name space.

Yes, this is essentially raising the, "Program to an interface, not an
implementation," to name-space-level (at a minimum), but I've found this to
be a good mid-path through this particular jungle. For more, see:
http://www.edmundkirwan.com/fracdoc/frac-page10.html

--
..ed

www.EdmundKirwan.com - Home of The Fractal Class Composition

.



Relevant Pages

  • Re: OT: Binary Search - Should They Know It?
    ... Considering you are having problems it would be advisable to design the app ... that the classes inside the DLL are unlikely to change but are reused ... Interfaces - This holds the interfaces for the data objects in the ... Our calculation engine is a monster. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: XP Requirement Analysis?
    ... >> the analysis and design. ... > I think the main difference is not in the practices, ... Like writing some code and some tests. ... >> there is no revolution, ...
    (comp.object)
  • Interface standards (was Re: Dual Port RAM)
    ... instead of hiding complex functions behind simple interfaces, ... "TTL 7400" design mentality. ... Of course, vendors' in-house synthesis tools ... do anything similar on the IP core side. ...
    (comp.arch.fpga)
  • Re: How Our Brains Ignore Unpleasant Facts was: Re: The Reasonable
    ... and independently the interfaces between ... If so then can one attempt to detect certain approaches to said design ... elements, inferred techniques, inferred specifications for certain ... the least with the ongoing work of large aspects of scientific work ...
    (talk.origins)
  • Deadline Extension: ACHI 2012 || January 30 - February 4, 2012 - Valencia, Spain
    ... running experiments, applications, and industrial case studies. ... Graphical user interfaces; Intelligent user interfaces; Adaptive user ... on interface design; Interfaces for disadvantaged users; Interface ... New visions of human-computer interaction ...
    (comp.specification.z)