Chapter 8 Matters of Inheritance
This chapter is an overview of object-oriented programming in CLIPS. Unlike rule- based programming in which you can just jump right in and write a rule without caring what else is in the system, object-oriented programming requires some essential background material.
How to be Objective
A key characteristic of good program design is flexibility. Unfortunately, the rigid methodology of structured programming techniques does not provide the needed flexibility for fast, reliable, and efficient changes. The object-oriented programming (OOP) paradigm. provides this flexibility.
The term paradigm comes from the Greek word paradeigma which means a model, example, or pattern. In computer science, a paradigm is a consistent, organized methodology for trying to solve a problem. Today, there are many programming paradigms such as OOP, procedural, rule-based, and connectionist. The term artificial neural systems, is a modern synonym for the older term connectionist.
Traditional programming is procedural because it emphasizes algorithms or procedures in solving problems. Many languages have been developed to support this procedural paradigm, such as Pascal, C, Ada, FORTRAN, and BASIC. These languages have also been adapted for objectoriented design (OOD) by either adding extensions or imposing a design methodology on the programmers. In contrast, new languages have been developed to provide OOP, which is not the same as OOD. You can do OOD in any language, even assembly language.
CLIPS provides three paradigms: rules, objects, and procedures. You will learn more about the objects in the CLIPS ObjectOriented Language (COOL) which is integrated with the rule and procedural based paradigms of CLIPS. CLIPS supports the procedural paradigm through generic functions, deffunctions, and user-defined external functions. Depending on the application, you can use rules, objects, procedures, or a combination.
Rather than imposing a single paradigm on the user, our philosophy is that a variety of specialized tools, a multiparadigm approach, is better than trying to force everyone to use a single general purpose tool. As an analogy, while you could use a hammer and nails for fastening everything, there are cases in which other fasteners are preferred. For example, imagine fastening your pants with a hammer and nails instead of a zipper. (NOTE: if anyone does use a hammer and nails on their pants, please contact the Guiness Book of World Records.)
The Class Stuff
In OOP a class is a template which describes the common characteristics or attributes of objects. Note that this use of the term template is not the same as a deftemplate as described in an earlier chapter. Here, the word template is used in the sense of a tool that is used to build objects having common attributes. As analogies, a straightedge is a template for drawing straight lines while a cookie-cutter is a curvacious template.
Classes of objects are arranged in a hierarchy or in a graph to describe the relationships of objects in a system. Each class is an abstraction of a real-world system or some other logical system that we are trying to model. For example, one abstract model of a real-world system might be an automobile. Another abstract model of a logical system could be financial instruments such as stocks and bonds, or complex numbers. The term abstraction refers to (1) the abstract descrip