Re: The OO approach



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.).
.



Relevant Pages

  • Re: Why return None?
    ... > That extend doesn't work for strings and tupples is irrelevant. ... If lists were being designed from scratch today, ... A "greenfield design", an entirely new language designed from scratch, ...
    (comp.lang.python)
  • Re: Design for Extension
    ... Actually I think "Design for Extension" can work very well with XP. ... extend a class, you cannot just make a subclass and override a method; ... you need to refactor the base class and add an extension hook somewhere ...
    (comp.lang.java.programmer)
  • Re: Design for Extension
    ... Actually I think "Design for Extension" can work very well with XP. ... extend a class, you cannot just make a subclass and override a method; ... you need to refactor the base class and add an extension hook somewhere ...
    (comp.lang.java.programmer)
  • Re: What comes first, the abstraction or the implementation?!
    ... If the customer cannot decide what they need, or don't know yet, there will ... by the customer during development (and therefore, the design of the code is ... Is it necessary to have a good framework, so that you can extend ... However I have found that if an abstraction is ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: learning object-oriented programming w/ PHP - any good example projects?
    ... phpPeanuts is an OOP framework that comes with a tutorial and examples. ... It is the third generation of a framework i started to develop because i ... object-oriented design for maintainable and flexible systems. ... extend real life software. ...
    (comp.lang.php)