OO and the Nodal Model

From Organic Design wiki
Legacy.svg Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, this is only useful for a historic record of work done. You may find a link to the currently used concept or function in this article, if not you can contact the author to find out what has taken the place of this legacy item.

The OOP methodology helps us to model our systems in terms of real objects and relationships. It is a methodology so it can be done in any programming language, not just the object-oriented-programming-languages (OOPL's). In fact OO was even around before programming languages under the name of abstract data types (ADT's) in maths.

A quick OOP refresher

Objects are containers of properties, the values of which form the objects' state. Also contained in the object are a set of methods which are functions designed to manipulate its state. The function names and the parameters they require form the interface of the object, through which all external interactions take place. This is called encapsulation and allows the internal workings of the object to be independent from programs which use it.

Different kinds of objects are defined by the names and types of properties and the interfaces (names and parameters) of their methods. This structural aspect of an object is its class. When objects come into being to be used by a program, they are created by effectively using the class as a template, creating a new "live" version of it in a specific context and under a specific name.

The way this template-like activity happens is via methods called a constructor and a destructor, which create and remove occurences of the class "in the field". Such an occurrence of a class is called an instance and the process of creating one is referred to as the class instantiating itself.

Often a new class needs to be created which is a refinement or extension of an existing class. This is called inheritance and we say that the new class is derived from the existing one. The new class is the sub-class or derived-class of the original one, and the original is the super-class or base-class of the new. Multiple-inheritance is when a class is derived from more than one base-class; it inherits the properties and methods from them all. (Note: multiple-inheritance is not the class-chain formed from classes to sub-classes, multiple inheritance means a class is actually derived from more than one chain. Today the only commonly known language supporting this is C++).

Polymorphism is when a base-class defines the interface for a method, but leaves it to the derived classes to implement the method. For example, a shape class may define the interface for an area method which all shapes must have, but the actual implementation (in this case a formula) depends on the specifics of the derived classes such as triangle or circle.

Classes

Class-based programming, or more commonly class-orientation, refers to the style of object-oriented programming in which inheritance is achieved by defining classes of objects, as opposed to the objects themselves (compare Prototype-based programming which is the nodal model's paradigm).

The most popular and developed model of OOP is a class-based model, as opposed to an object-based model. In this model, objects are entities that combine state (i.e., data), behavior (i.e., procedures, or methods) and object-identity (unique existence among all other objects). The structure and behavior of an object are defined by a class, which is a definition, or blueprint, of all objects of a specific type. An object must be explicitly created based on a class and an object thus created is considered to be an instance of that class. An object is similar to a data structure, with the addition of method pointers, member access control, and an implicit data member which locates instances of the class (i.e. actual objects of that class) in the class hierarchy (essential for runtime inheritance features).

In this class-based paradigm, there are two distinct trees involved in a running application, the static tree of class definitions defined in the programming, and the dynamic runtime tree of objects currently in use. This conceptual division becomes a problem when classes need to be dynamic or when instances are distributed, which is the reason that the project uses an instance-oriented (prototype-based) approach instead.

Prototype-based programming

Prototype-based programming is a style of object-oriented programming in which classes are not present, and behaviour reuse (known as inheritance in class-based languages) is accomplished through a process of cloning existing objects which serve as prototypes. This model is also known as class-less, prototype-oriented, or instance-based programming.

The original (and most canonical) example of a prototype-based language is the programming language Self developed by David Ungar and Randall Smith. However, the class-less programming style has recently grown increasingly popular, and has been adopted for the programming languages JavaScript, Squeak when using the Viewer framework to manipulate Morphic components, Cecil, NewtonScript, Io, MOO, REBOL, Kevo, and several others.

Distributed Instances

The prototype-based approach is moving more of the overall concept out of the static domain and into the dynamic runtime space. This is exactly the what a real distributed space should be; a single unified runtime environment formed from the processing and storage resources of its peers. In the nodal model, part of the enviornment is the syncronisation of instances with the prototypes they're based on which occurs on a cycle related to the scale of operation. An environment in which distributed instances of a particular concept are automatically maintained has far more descriptive power than the standard OO approaches, because all communications or reporting of information can be described in terms of instantiating instances separated by various processes.

How the Nodal Model differs from OO

  • Naming: Many problems in OO come from its foundation in naming - all the classes and objects use textual-names as their fundamental means of identity and distinction leading to problems with naming conflicts and language-dependence.
  • Instance-based: Problems arrise in OO from the fundamental difference between class and instance...
  • Unified-space: Problems arrise in OO from the runtime space not being a logical continuation of the file-system and global network spaces
  • Self-organising: Change is inherent in the network, so applications within can execute directly from their conceptual description requiring less code
  • Self-contained: Like OO, the Nodal Model is a methodology and so can be implemented in any programming environment, but unlike OO, the Nodal Model fully describes its own instantiation into those enviornments.