Re: How much oop is too much oop?



In article <efWT7KwSFHA.2256@xxxxxxxxxxxxxxxxxxxx>,
dave@xxxxxxxxxxxxxxxxxxx says...

[ ... ]

> The principle
> of making operations failsafe, is in no way violated by simply
> providing quick tests to see if you know they're going to fail in
> advance.

Providing both violates the general notion of an interface being
complete yet _minimal_.

[ ... ]

> Of course you can. For an object with N boolean attributes which
> are important to you, you can create 2^N derived classes so that you
> have one with every possible combintion of attributes. I don't envy
> you writing a program that way though.

You seem to have carefully snipped and ignored the most important
point here: if N is large enough for this to matter, your design is
_almost_ certainly screwed up from the beginning.

On the _rare_ occasion that N really is unavoidably large, however,
you don't need to (at least directly) write N^2 classes to handle the
job. Rather, you can write N base classes, and then generate the N^2
combinations thereof via templates.

[ ... ]

> Consider this: the strength of object orientation comes from the
> fact that it models the objects and procedures of real life.

Quite the contrary. This is, at most, one of many strengths of OO
programming -- and a rather minor one at that, IMO.

> In
> real life you know that if you have a stack of regular pentagons,
> then you can't tile the plane with them. You don't start trying.
> In real life you *can* look in the varnish pot to see if it is empty
> and you don't (at least I don't) start doing a long operation which
> a few hours later will require it to be full.

If this analogy really applies to your code, then your code is
probably utterly and irretrievably broken.

In real life, there are physical constraints on nearly everything. If
your code is intentionally simulating those physical constraints,
well and good -- but in the case of such a simulation, you almost
certainly do NOT want to add "intelligence" above or beyond what the
physical object possesses, or your simulation is broken.

Under nearly all other circumstances, your code should not suffer
from the physical constraints of real life. There's only one physical
constraint that applies to most well-written code: memory
availability. For better or worse, other than assuring yourself that
your data can fit into the available address space, you can't do much
about this though -- the physical memory of the machine isn't a
practical limit when you have virtual memory. You can't reasonably
measure virtual memory, because (for example) Windows supports
expanding the swap file when needed.

As such, nearly the only reasonable course of action is for most code
to be written on the assumption that adequate memory is available,
and fail when/if that's found to be false.

Real-time code adds the possibility of the processor not being fast
enough -- but, again, measuring this ahead of time is rarely a
feasible solution to anything. For example, on a laptop the CPU can
speed up or slow down, so your measurement may not accurately reflect
reality.

To summarize: having such a limitation that needs to be checked for
ahead of time is a strong indication that the code is broken.

--
Later,
Jerry.

The universe is a figment of its own imagination.
.



Relevant Pages

  • Re: How much oop is too much oop?
    ... >> fact that it models the objects and procedures of real life. ... there are physical constraints on nearly everything. ... > constraint that applies to most well-written code: memory ... I use arrays of items rather than other structures: ...
    (microsoft.public.vc.language)
  • Re: Thin Man.
    ... > think my memory is bad on rmp you should see me reintroducing myself to ... > people over and over again in real life.. ...
    (rec.music.phish)
  • [fw-wiz] Certification ?
    ... I'm gagging on this "certification" thing. ... REAL life not only involves memory of facts but memory of where to LOOK for answers and finding them in what ever resource is available. ... Cert Smert!! ...
    (Firewall-Wizards)
  • Re: hawkeye game
    ... >>>I'm not sure I saw that one, but it sounds like in real life it would be ... >> A pencil and paper or a good memory will get you loads of points. ...
    (uk.sport.cricket)