Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!sdd.hp.com!spool.mu.edu!uunet!munnari.oz.au!uhccux!uhunix1.uhcc.Hawaii.Edu!baumgard From: baumgard@uhunix1.uhcc.Hawaii.Edu (Jon Baumgardner) Newsgroups: comp.object Subject: OOPs defined Summary: This is a review of 20 magazine articles NOT FOOTNOTED. Please correct. Keywords: OOPS, SmallTalk, Eiffel, C++, Turbo Pascal, OOPL, OOD, OOA Message-ID: <11238@uhccux.uhcc.Hawaii.Edu> Date: 31 Jan 91 20:46:06 GMT Expires: 28 Feb 91 10:00:00 GMT Sender: news@uhccux.uhcc.Hawaii.Edu Organization: University of Hawaii Lines: 89 The following is a review of over 20 articles on OOPS from Byte, Computer Language, Dr. Dobbs Journal, ACM, and Programmer's Journal magazines. It is seven pages long and was originally written in Word Perfect. I editted the document in Windows 3.0's Write to get a text file. You might want to download it to read it. Please reply to me directly if you see any glaring errors. I will attemp to answer all inquiries after February 20th and post a summary of the conclusions. Please press n now to avoid a long document or s to save it to a file for downloading. Thank you for your Kokuo (coop- eration in Hawaiian). PS Does anybody know when COBOL++ will be available? 1-14-91 08:22a OOPS REVIEW Object Oriented Programming Jon Baumgardner baumgard@uhunix.mso.hawaii.edu Overview Object oriented programming (OOP) is an emerging technology extending or replacing structured programming techniques. OOP promises to simplify programming in ever more complex systems and reduce maintenance time for constantly changing systems. Once OOP becomes common, programmers will no longer start from scratch on aproject or work like 16th century skilled tradesmen. The theory behind systems development will be to find and order the rightparts (objects), change the objects a little bit for your own needs, test each object, then put the system together with aminimum of integrating code. Even file structures can be made into objects. In this paper I will: - review the basic concepts of the object oriented approach - review seven of the major OOP languages - compare relational databases with Object Oriented Data Bases (OODB) - describe the new object oriented systems analysis and design methods - attempt to fore see how OOP can be used in MSO Basic Concepts All object oriented programming languages (OOPLs) include three concepts: objects, classes, class inheritance, and message passing. Some OOPLs add several other concepts: polymorphism, dynamic binding, encapsulation, concurrency, persistent objects, strong typing, and object libraries with search and choice facilities. The following is an easy to read description of these concepts one-at-a-time. Objects are data/code hybrids. An object is a reusable component including code and data that can be used by several different programs over and over again without changing the object in anyway. A particular object is an 'instance' of the object. An instance can be viewed as the time an object was used with aparticular program. Objects have to be very general in nature sothey can be used in many ways. Object Classes are groups of objects. Objects are grouped by their behavior. Read/write, move, push, to color, to have are all behaviors. Class Inheritance is the ability of an object to derive its data and functionality automatically from another object. There is always a root object within a class. The root object has the most basic components for this class of objects. So, in the Read/writeclass, the root might have a write command and a read command. The next layer of objects might include an object to print to the screen (including the number of lines, characters per line, etc.), an object to print to a printer, an object to read a disk drive, an object to read from the VAX... At the third level some languages allow many to many relationships but most only allow a one to many relationship (similar to the DOS directory hierarchy). Message Passing - instead of calling a method (or procedure in COBOL) directly, you call an object's message by sending that object a message indicating which method you wish to call. The object then uses the message to select which method code isactually invoked. Polymorphism is the ability to have different kinds of objects respond to the same message in different ways. Within a program anobject may have a different output depending on the state it was left in when it was used last _or_ the output may be different depending on what message was sent to it. Dynamic binding when an object is bound to a procedure at run-time as opposed to compile-time. The code associated with a given procedure call is not known until the moment of the call at run-time. The program can invoke a method (procedure in COBOL jargon),and each of the receiving objects will execute its own version ofthe method to achieve appropriately customized actions. Late binding involves setting up a run.time table search to match methodnames to local method code which could increase the time it takesto run the program. Dynamic (or run-time) binding can make a program very flexible. Encapsulation is the protection of an object's private data from outside access. No other object can access the internal data of another object. This is very important in making an object reusable. Concurrency has to do with parallel execution of parts of a computation. The execution of components of a program can either use interleave features on a single processor or be distributed to several processors. Strong Typing is a concern of software engineering. OOP supports an abstract type. This way the type of data to be manipulated is separated from _how_ the data is to be manipulated. The type of data has to be in the run-time table so the data can be bound at run-time (see dynamic binding above). Persistent objects are objects that can be used by many applications without revision or rewrite. If a revision is needed, the proper response is not to revise a debugged object but to create a descendant object that embodies the new elements required. Persistent objects can be kept in their compiled form with documentation. Class Libraries are collections of persistent objects or reusable software stored in class or type libraries with no need for source code. There are commercially available class libraries already. Some languages have navigation facilities to search the library and read the documentation associated with objects. Some people envision national public domain libraries of debugged, virus free,compiled objects that can work on any platform. OBJECT ORIENTED PROGRAMMING LANGUAGES There are seven major OOPLs. Smalltalk, Actor, Eiffel, Trellis are true OOPLs with most of the concepts outlined above. C++, Turbo Pascal, and Quick Pascal have some OO extensions. COBOL++ is just around the corner but it too will just have some OO extensions. The following is a quick review of the strengths and weaknesses of each language. Real OOPL Smalltalk was one of the first languages with a graphical interface and true objects. Most graphical user interfaces (GUIs) were derived from Smalltalk. You can use this language on the MAC, under X, in unix environments, and soon in Windows 3.0. You have to use the Smalltalk GUI though. Everything must be an object and these objects are translated through a "virtual machine" to the platform. No recompiling is necessary to change platforms. All of Smalltalk is written in objects. All objects are ava ilable for modification. A "generation scavenger" eliminates dead objects after a program is run (reinitializing them) and an incremental garbage collector also can be used to clean up used objects. Programming in Smalltalk is incremental as each object needs to be debugged and compiled as it is created. After the program is debugged a "stripper" can be used to remove compilation, debugging, and browsing support from an program to create a stand alone application. The best part about this system is the library toolset. Browsers and inspectors help you explore the systems's class hierarchy, methods, and data. Multiple desktops are supported so you can write your code several different ways and test each one at once without messing up other desktops. Smalltalk is a great prototyping tool but is a memory hog and runs slow at times. Current implementations include Smalltalk-80 and Smalltalk/V286 ($499.95). Actor ($495.00) has the feature of not having to define a classinstance variable, the compiler will automatically associate the ancestor's (the higher level object's) methods and instance variables with a new class and define the instance variable when the object is created. No types are assigned to instance variables because Actor all variables hold objects and every object 'knows'its own type. Actor also has a fine library toolset and a garbage collector that destroys objects that can no longer be refer enced from a program. Eiffel is a little different. In Eiffel classes can use eachother's facilities. A class which relies on another class is called a client, the other class is the supplier. Some features of a supplier are purely internal and the export clause lists the features which are available to clients. Inheritance is multiple and features may be excluded from the heir. Repeated inheritance is also supported. Abstract classes (see Smalltalk above) are called deferred classes in Eiffel. A flattened class in Eiffe l has no inheritance (no root class, in essence it supports multiple root classes as no other language presented above does). Eiffel supports the generation of final code in C for portability. The language specifications of Eiffel are in the public domain and anyone is welcome to write Eiffel compilers, interpreters, etc. The International Eiffel Consortium was created in August 1990. Eiffel is the most experimental and leading edge of the languages reviewed here. Trellis (from Digital) has some unique type features. A"parameterized" type is a generic form of a type often associated with collections of objects. A "type union" specifies that several types of objects might occur as the value of some expression. A"type case" can perform different actions depending on the type ofan object. Trellis also support abstract type. Trellis has a Call-out Library to convert Trellis code to C and a Call-in Library to convert code in other languages to Trellis code. "Foreig n operations" can be used to call external routines. Summary All of these languages support libraries of objects and tools for browsing. The only way to find the right mix of features in a real OOPL for a group of programmers is probably to try the OOPL first. All have a separation of Type and Class except Trellis. Languages with OOPL extensions C++ is the most widely used of all OOPLs. C++, like all the languages with OOPL extensions, gives the developer a chance to learn OOP without losing anything from the standard C. Strong type checking is the most obvious benefit but automatic pointer maintenance is not supported. The class construct allows programmers to define new types. Objects are the instances ofthese classes (types are now classes in C++). Constructors initialize classes and destructors clean up deleted objects and close them afte r a program is run. A static object automatically calls its own constructor and destructor. Automatic objects reside on a stack an are the local variables within a function and also automatically calls its own constructor and destructor. Dynamic objects have to be explicitly opened and closed. C++ supports multiple inheritance and all classes don't have to come from a single root. A single root is defined as virtual. Virtual functions are called depending on the class of the object being invoked. The data or functions (methods) within an object can be public or private (see Eiffel) or protected. A class can also specify a friend function that can access private and protected data or methods within an object. c++ source code is translated into C then compiled. Quick Pascal has only one thing that is better than Turbo Pascal. It runs in Windows. The main drawback is that it does not have a stand-alone debugger. Turbo Pascal has one advantage and that is the availability of commercial libraries of objects. Run-time binding is supported. Methods can be executed from within the Turbo Debugger (TD) environment. TD provides an Object Instance Inspector that allows you to look at the data of object instances. There are also Object Type and Method Inspectors. Object Professional ($150.00) is a library of OO classes for Turbo Pascal. It has 50 units, 130 objects, 2100 documented procedures, functions, and methods, 1200 additional internal routines, and 1600 pages of text and examples in three manuals. Object Professional includes a unit to make Terminate and Stay Resident (TSR) programs. It also has an Object called Command Processor that translates key sequences into command codes making key assignments easy to reconfigure. There are also browsers and choosers for ease of navigation through the library. Many of the library's objects are routines that were built for TP4.0 then translated into objects for TP5.5. Tools for GUIs are included. Summary There are no debugging tools for any of the OO extension languages' code except for TP 5.5. Debugging is done at the original language level. There is no virtual machine as in Smalltalk to interface with different platforms. They do not support persistence explicitly but it can be done. Concurrency is also not supported. Parameterized types, exception handling and garbage collection are not supported. Polymorphism is an option in these languages. You have to use message passing to support polymorphism Brought to you by Super Global Mega Corp .com