CISC 3150
Object-Oriented Programming

On the Path to Object-Orientation

Object-oriented Programming

Class Definitions

Data Initialization Variations on Classes Mutually Recursive Class Definitions Classes as Objects Message passing / invocation : process of requesting an object (the receiver) to perform an action (execute the method associated with the method name -- often called the selector), often in the presence of arguments. Statically vs Dynamically Typed Languages Referring to the Receiver within a Method

Object Creation

Creating Arrays of Objects

Memory Management

Constructors

Shallow vs Deep Copy

Destructors / Finalizers

Orthodox Canoncal Class Form (C++)

Essentially mandatory for any class with one or more data members that pointers; good idea in general:

What goes wrong if the Canoncal Class Model is not Followed in the Presence of Pointers

Just a Brief Word ABout Smalltalk

class Class {
    name
    new
    addVariable(...) {...}
    addMethod(...) {...}
    VariableTable instanceVariables;
    MethodTable methods;
}

class MetaNumber extends Class {
    addVariable("value")        // Adds instance variable 'value' for Number
    addMethod("add")            // Adds method 'add' for Number
    addMethod("sub")            // Adds method 'sub' for Number
    ...
    Number with(int val) {...}  // MetaNumber method: initialize the instance variable, value, to val).
                                // note the receiver is an instance of MetaNumber (i.e., Number), while the return object
                                // is an instance of Number
}

MetaNumber Number = MetaNumber new;  // Number is a (in fact the ONLY) variable of class MetaNumber

Number n = Number new with(12);         // creates and initializes a new Number object
If this is of interest to you-- more on Smalltalk's metaclasses can be found here.

An Aside About Design Patterns in the Context of Smalltalk's Metaclasses