Re: The OO approach
- From: Bruce McFarling <agila61@xxxxxxxxxxxx>
- Date: Sat, 29 Mar 2008 09:41:35 -0700 (PDT)
On Mar 29, 12:08 pm, Jonah Thomas <jethom...@xxxxxxxxx> wrote:
So you do your IF every time the code executes.
But if there is an OO system in place, then it optimizes that
selection. And that can be designed so it works equally well in the
interpreter as the compiler, so there's no need to go into a state-
smart word that only works in a compiler.
Where that to> and from> starts to break down is exactly where you
pinpointed it as a potential convenience ... where it is smart enough
to work out the type of the thing it is storing to.
However, suppose that you have a structured data item, and you need a
different to> and from> for each different structure ... sometimes it
copies a pointer, because the underlying data is persistent, sometimes
it copies the whole structure, because the underlying data is dynamic,
sometimes it copies a pointer and updates a pointed-to count for a
garbage collector.
Instead of putting more and more intelligence into to> and from> ...
you package that structured data together with precisely the to> and
from> that works with *that* structure, so it does not need to know
that any other to> or from> exist and you never have to *extend* an
already working set of to> and from> ... just write a new one.
You have multiple data structures of a given type but only one set of
functions working on them, so you have store the data structure
creating code and the functions working on the data together, since
you only need either of them to show up once, and the data structure
only needs to be able to get back, somehow, to the set of functions
that work on it.
So you have an elaborated version of one creating word and multiple
created words, except instead of one action you have a system of
actions dedicated to that data structure.
Then after getting that, you notice that sometimes you extend a data
structure, so you are rewriting to> and from> but it is based on the
original data structure to> and from> ... so you develop a system
where you can copy the original data structure and then extend it, and
a system where you can get the working to> and from> from the original
and extend them, rather than writing them from scratch.
OK, that enhanced create/does> word is a class, that created data
structure that has its own collection of specific operations is an
object or instance, and the process of making an extended version of
an existing enhanced create/does> word is called class inheritance.
Its just a collection of solutions to a specific style of programming
problem, packaged together so that each piece is optimized to work
with each other piece, and given terminology to make it simpler to
talk about it.
The terminology is obviously extended depending on specific different
design choices that can be made in the system (do you hand the object
to the function or the function to be done to the object, can you
inherit directly from objects and go from there or only from classes,
etc. etc.).
.
- Follow-Ups:
- Re: The OO approach
- From: Jonah Thomas
- Re: The OO approach
- References:
- The OO approach
- From: Jonah Thomas
- Re: The OO approach
- From: Doug Hoffman
- Re: The OO approach
- From: Jonah Thomas
- The OO approach
- Prev by Date: Re: The OO approach
- Next by Date: Re: Images and libraries
- Previous by thread: Re: The OO approach
- Next by thread: Re: The OO approach
- Index(es):
Relevant Pages
|