E for Experts

OOP Basys and its AmigaE Implementations (Part 1)


Overview

Object Oriented Programming (OOP) is the natural evlution of other programming techniques, such as structured and procedural programming. Various programming techniques grown in these years, have tried to encapsulate data not essential for the coder inside invisible structures to reduce errors to the minimum. For example, a proc or function called Test() should require some params in input and should be able to assure proper results even in critical situations (ex. not valid params, memory problems...)

Main feature of procedural programming is the extremely easy debug sessions: if results obtained from Test() proc are not correct, problem relies in proc Test() only. So coder can work out errors fast. But he should not write an entire program and then try to test it in a single shot....

OOP rappresents the natural evolution of procedural programming. Even if what I am going to say is not completely correct, an object should be seen as a data structure (C structs, E OBJECTs, BLITZ NEWTYPE) linked to a series of functions related to manipulate structure data itself. My definition of what an object is surely very limited but, summing up, OOP is limited to this. Advantages are not so limited...

From programmer's point of view, an object could be seen as a real program with its global and local vars (first inside object definition, the others inside functions/procs of object itself), its functions and its init and dispose routines (C and E main()). Writing an object, programmer acts exactly as he's writing a program. All data will be mainipulated inside object, and it is up to the programmer to choose what to make visible and what to keep hidden inside the object.


OOP Fundamentals

An object, as we previously said, is made up by a data structure (vars) and object related functions, which allow data manipulation. Both avrs and functions can be made visible or invisible from object creator to future object users: so, the creator chooses whether some object features should be used from others or to remain internal to the object itself.

This OOP feature, allows to create real "black boxes" (objects), which execute some functions correctly and could (and should) be used from other coders without worrying how these boxes were effectively created.

Personally, I have written a lot of objects which allow particular data operations or use some Amiga OS features... and, in some cases, I am not able to remember exactly how they work. More or less this should happen to all of us: an object must be closed and assure functionality.

continued in next issue...


Main Page


    Written By: Fabio Rotondo      e-mail: fsoft@intercom.it
                C.so Vercelli 9
                28100 Novara
                ITALY               tel:    (ITA) - (0)321 459676