Download Table of Contents

Transcript
Object-Oriented Programming in SIL
Classes and Inheritance
This section contains these topics:
➢ Classes
➢ Inheritance
➢ Specialization and Generalization (how objects are viewed
relative to each other, and how to manipulate the views)
➢ Abstract Classes
One of the main characteristics of object-oriented programming is the
concept of inheritance. Two objects, A and B, belonging to different
types (classes), can be related in such a way that all properties of A are
also properties of B. In this case, B inherits A’s properties. In SIL
terminology, B is a specialization of A, since B may have additional
“specialized” properties apart from those inherited from A; or A is a
generalization of B. Applying this concept to machine-tools, we can say
that a machining center is a specialization of an NC machine, which in
turn is a specialization of a kinematics device.
The advantage of inheritance is that programmers do not have to build
an object from the ground up. By declaring object B to be a
specialization of A, the properties of A automatically become properties
of B. This is especially useful if A is a system-defined object with many
useful, but low-level, properties. For example, B might be a cutting-tool
with properties such as location of cutting tip, cutting edge, etc., whereas
A might be a CAD model with geometric and graphical properties such
as boundary representation, surface normals, color, etc. If you are
creating a simulation of an NC machining process, you are probably
familiar with the cutting properties of a cutting-tool, but may not be
familiar with the lower level properties of a CAD model, even though
these properties are necessary for displaying and manipulating the
cutting-tool in a simulation. Because Soft Machines provides a type
(class) shape, which represents a simulated object in three-dimensional
space, the class cutting_tool (cutting tool) can simply be described as a
specialization of shape.
2-24
Soft Machines