|
Author: John Barnes
Abstract: This week’s gem is the fifth chapter of John Barnes’ new booklet:
Safe and Secure Software: An Introduction to Ada 2005.
Over the coming months, we will be publishing all thirteen chapters of the booklet. In the attachment at the bottom of Gem #30 you can access the contents and bibliography for the entire booklet. We hope you will enjoy the read!
OOP took programming by storm about twenty years ago. Its supreme merit is said to be its flexibility. But flexibility is somewhat like freedom discussed in the Introduction – the wrong kind of flexibility can be an opportunity that permits dangerous errors to intrude.
The key idea of OOP is that the objects dominate the programming and subprograms (methods) that manipulate objects are properties of objects. The other, older, view sometimes called Function-Oriented (or structured) programming, is that programming is primarily about functional decomposition and that it is the subprograms that dominate program organization, and that objects are merely passive things being manipulated by them.
Both views have their place and fanatical devotion to just a strict object view is often inappropriate.
Ada strikes an excellent balance and enables either approach to be taken according to the needs of the application. Indeed Ada has incorporated the idea of objects right from its inception in 1980 through the concept of packages which encapsulate types and the operations upon them, and tasks that encapsulate independent activities.
Note: All chapters of this booklet will, in time, be available on the Ada 2005 home page.
|
722.4Kb |
Posted
in Development Log, Ada / Ada 2005, Devt log - Gem of the Week
If you have an idea for a Gem you would like to contribute please feel free to contact us at: gems@adacore.com
Raoul Duke said:
These chapters are much appreciated food for thought, thanks for making them available.
I question the OOP geometric figure example as being useful: I dare say it does more harm than good in that it leaves several issues unresolved. What are the (X,Y) of the base class meant to actually represent? In fact, I didn’t notice X,Y ever being used in any of the functions in the beginning, making them seem wholly lacking proper motivation. It is not clearly specified what they are for. Perhaps for a Circle or a Rectangle one could make an educated guess that they are the ‘center’. However, what then would we do for an Ellipse? Would it be the center of mass rather an a focus?
So I found it all rather confusing and misleading. Please, we have enough bad examples of OO in the world :-(
yours sincerely, in the hopes of improving discourse.
Raoul Duke said:
P.S. since I’m now in an entirely too pedantic frame of mind, I will also note that there are people in the world who might take issue with the claim that the only genders are Male and Female. ;-) More things in heaven and earth, Horatio, than are dreamt of in your philosophy, etc.
John Barnes said:
I must thank Raoul Duke for his comments. It is always hard to know how much to assume for the background knowledge of the reader. I should have said that X and Y were the coordinates of the centre (or center) of the object. Interestingly enough I used this example in Programming in Ada 95 and similarly it does not say that and nobody ever commented before.
So I should add something for clarification. Of course X and Y do not feature much in the individual properties of an object because most properties are independent of position. It is only when we come to move objects or compare them or consider the distance between them that the values of X and Y matter.
Yes, it is the centre as defined in elemntary geometry and in the case of the ellipse X**2/a**2 + Y**2/b**2 = 1, the center is at (0, 0). Think of it as the centre of gravity of a lamina for irreglar objects.
The mind boggles at more that two sexes but Programming in Ada does contemplate a type Neuter at one point!
By the way I find it irritating the way the world is using the word gender to mean sex. Strictly speaking Gender is (or was) a linguistic term and has nothing to do with sex. Thus in French a table has neuter sex but feminine gender.
And it is nice to think of it in terms of names or access types. My name John as a pointer has gender masculine but I (John) as a person has sex male.
Enough of this.
John