TweetFollow Us on Twitter

OOP, MacApp
Volume Number:5
Issue Number:9
Column Tag:MacOOPs!

Back to the Future: OOP & MacApp

By Jean-Denis Muys-Vasovic, Argenteuil, France

Back to the future: OOP & MacApp

(or: The Hitch Hiker’s Guide to Objectivity)

Introduction

The seventies saw the increasing popularity of a programming technology known as “structured programming”, of which the best witness is the good & famous book by Niklaus Wirth: Algorithm + Data Structures = Programs. The design of programming languages followed this trend, beginning with Pascal, and ending with Ada or Modula II.

On the other hand, the eighties have seen the birth of another programming concept, whose roots can be found in the seventies as well: Object-Oriented Programming. This technology has not yet got its “Algorithm + Data Structures = Programs”, though a few good books are around. The roots of Object-Oriented Programming are buried deep in the past, and go back to the early seventies when a research team at the Xerox PARC (Palo Alto Research Center), including (sounds familiar?) Alan Kay, Ted Kaehler, Larry Tesler, started to design Smalltalk And yet Object-Oriented Programming (OOP in short) is the way of the future. The object of this short article is to explain some of the hows and whys. Follow me if you dare to The Restaurant At The End of Programming Knowledge.

Object-Oriented Programming

What is Object-Oriented Programming by the way? This question, often asked, is much more seldom answered. The fact is that it is difficult to answer it without calling on associated definitions:

Object-Oriented Programming is the compliance to the technology by which a computer program is designed and written around objects.

Above all, Object-Oriented programming is a technique for programming, a set of paradigms for writing “good” programs. The main characteristics of OOP is that it is consistent with the way in which humans think about solving problems. It consists of identifying objects and what is to be done with those objects as specific steps in a problem solution.

But all this won’t be clear until the definition of “object” is given. An object is first a data type. At first glance it can be thought of as a record (for Pascal programmers) or a struct (for C programmers). As such, it defines a set of fields which will contain related data, as for example, the name, age, sex and social security number of people. But what makes an object different from a mere struct, is that it also contains behavioral information, let’s say procedures. And this brings it to life (pict 1). So fields convey the static and declarative information of the object, while procedures convey its dynamic and operational information. Some self examination will show you that this is the way people solve problems in everyday life. In OOP language, the procedures are called methods. And when you call the method, you say that you send the object a message, and that the object answers the message by executing the method. This is completely metaphorical, but it helps a lot. And in C, you could indeed build objects as structs in which some fields are pointers to functions.

In fact, it would be wasteful to use memory in every object just to contain the pointers to all of its methods, which are probably the same for a lot of objects. That’s why the methods are defined in an object template, which is used to mold new objects of the same kind. This template, in fact the actual type definition, is called a class. It defines the structure and behavior of all objects of this kind, called instances of the class. For example, you can define a Car data type, with power, size, color, speed fields, and start, stop, turn methods. This is the Car class, instances of which could be myBMW, yourPorsche, hisToyota objects. The Class is a data type definition, while the instances are the real variables (picture 2).

But OOP goes a little further. All these classes are not just there ignoring each other. Just like in real life people classify objects (i.e. real objects, but also animals, problems, music and people ) in categories according to their similarities, in the same way, OOP introduces inheritance (pict 3). Look at the biological classification of animals: it is an inheritance tree. It says (forgive the errors, I am not a biologist):

- There is the biggest class, instances of which are all animals

- This class has some subclasses, including (but not limited to) mammals, insects, fish

- The mammals class has itself subclasses, including rodents, apes

- The last subclasses, which have no subclass are the species, including rabbits, men, cows

- The rabbit I bought last week is an instance of the rabbits class, but also of the rodents class, and mammals class, and the animals class (and probably several intervening classes).

What is important to notice is that a subclass inherits everything from its parent class (or superclass), including the fields and the methods. But it can itself be specialized (by adding fields and/or methods), and/or customized (by replacing some methods, you override those methods).

For example the birds class tells us that a bird can fly. The albatrosses subclass is specialized and tells us an albatross can fly long and well. The ostrich class is customized and tells us an ostrich cannot fly. In this way, every bird will understand the message “fly”, but will answer it differently, including ostriches which will say “no”.

Structured programming introduced code structuring. Inheritance introduces data structuring. The benefits are similar. This inheritance process allows a very different programming style, in which you program mostly by differences, only specifying the differences between your class and a preexisting class.

Object-Oriented Languages

As it should now be clear, it is possible to program “Object-Oriented” in any language but the poorest. But it is far from sufficient for a language just to enable Object-Oriented Programming. It must also support Object-Oriented Programming. To enable means to make it possible, but maybe painful, difficult, tedious, awkward. To support it means to make it easy, safe, efficient, fun.

More specifically, a language can be said to be Object-Oriented if it satisfies four requirements, namely encapsulation, abstraction, inheritance, and polymorphism.

Encapsulation is satisfied when the language supports the definition of data types in which data and procedures are encapsulated, i.e. tied together. This is the very definition of the word object (in our context of course). Typically, the procedures act on the data. The module concept found in languages such as Ada or Modula II fulfills this requirement.

Abstraction is satisfied when the language supports the definition of abstract data types. An abstract data type is a incomplete type definition, which cannot be used alone, but only together with another data type. For example, a stack (whose methods could include push, pop, top ) is an abstract data type, because you must specify a stack of what. In Object-Oriented languages, you often define abstract classes which have no instance, but are there to be subclassed. Their methods typically do nothing and are to be overridden by subclasses. Abstract data types such as the stack can be defined in Ada.

Inheritance is satisfied when the language supports the definition of data types by specialization or customization of preexisting data types. In that case, the new data type inherits both the data and the procedures from its parent data type. It can thereafter add new data or new procedures, and replace part (or all) of the behavior of the parent class. Ada does not support inheritance.

Polymorphism is satisfied when the language supports the process by which the same procedure call can result in the execution of different pieces of code, depending on the type of its arguments. This is typically what is reflected in the message metaphor: the same message can be sent to two objects whose answer will be different because their methods are different. Ada does support a limited form of polymorphism through its overloading mechanism.

Let’s first say that Ada is definitively NOT Object-Oriented, as it sometimes claims to be, though it’s a very near miss. Before giving you some names of real Object-Oriented languages, let me give some other desirable features, which an Object-Oriented language could have:

The Object-Oriented mechanisms must be integrated

The Object-Oriented mechanisms must be combinable

The Object-Oriented mechanisms must be general purpose

The Object-Oriented mechanisms must not impose overhead over programs which do not use them.

The Object-Oriented mechanisms must not depend on other mechanisms (in other words, what you don’t know won’t hurt you).

You may have recognized the implementation goals of Bjarne Stroustrup, the designer of the C++ language. Of course, C++ is a leader among the contenders in the OOL war. C++ is a strict superset of the C language, from which it inherits the efficiency. Others are Smalltalk-80, the father of OOP, which is more than an Object-Oriented language, its also an Object-Oriented programming environment and an Object-Oriented philosophy. Second class contenders are Objective-C, and Object Pascal for example. So far, Object Pascal has been very important at Apple because it was designed by Apple, together with Pascal’s father, Professor Niklaus Wirth. It is even more important, because Object Pascal is the language in which MacApp was implemented. As C++ is to C, Object Pascal is a strict superset of Pascal, though much simpler than C++.

Benefits and Methodology

The benefits of OOP are numerous. As stated above, the paradigm is closer to the way humans think. But more practically, objects are small self contained software computers. Once they are debugged, they work. They can be considered as black boxes, or better yet, as actors to whom you delegate tasks, and who delegate subtasks to other objects.

Another advantage of OOP worth noticing is that you do not have to remember which procedure acts on which data type. Just send the message to the object which will answer correctly. Of course you still have to write as many methods as concerned data types for a given operation, but you don’t have to remember any more the name of the actual procedure, just a symbolic, generic message name which describes the nature of the procedure.

As a side effect of using OOP, you will find that your control structures will be a lot simpler. You won’t have large and tedious switch (or case) statements any more. The dispatching can most of the time be done by the language itself through message passing and method selection. Moreover, the OOL dispatching can be quite efficient.

And indeed you often end up with a program which is smaller and faster than it would have been if developed with traditional technology. Of course, a method call is on average slightly slower than a traditional procedure call. But this overhead is constant (and small). In particular, the method call time does not depend on the class in which the actual executed method is found, or on the depth of the inheritance tree to walk through before finding the method. Moreover, a large number of method calls can be optimized to become real traditional procedure calls: those for which the actual executed method is not ambiguous. An important fact to notice is that this optimization can be done at link time. Another reason why the program is often shorter and faster is that it is actually easier to design good and efficient algorithms with OOP.

But the real advantages of OOP lie in code extensibility and reusability. You don’t even need the source code of a class to use it, subclass it, extend it, or customize it. That’s why a lot of Object-Oriented Languages (including Smalltalk and Objective C for example) bring with them a large amount of predefined common use object classes. If you are not satisfied with their behavior, you don’t have to rewrite them from scratch. You just have to subclass and override. But what can be done with the code of others, can - even more so - be done with your own code. It is indeed a lot easier to reuse your classes from one application to the next.

As a global result you will find that your development times are shorter. And the time gain is more and more important as your experience improves and as you reuse more and more of your code from one application to the other. Of course to extract the largest gain from OOP, you will have to understand the methodology. And that is only learned through experience. There is no magic rule which could tell you how to design THE good object and method structure.

In terms of choices for subclasses or subclass protocol, there is more than one solution for any given problem. Thus, Object-Oriented problem solving requires creativity and intelligence in establishing the “best” solution to a problem.

The process of deciphering and designing the objects which are part of a problem solution is often relatively easy. The process of finding the most efficient generalization of those objects is often a difficult task, more of an art than of a technique! Two design methodologies can be used (but not interchangeably): top-down and bottom-up.

Top down design methodology is often used with traditional structured programming. You begin by stating the problems to be solved as general tasks. And you proceed by dividing the tasks into subtasks of decreasing size, up to the point where each subtask is simple enough to have an obvious solution.

Bottom-up design methodology is often used in threaded coded languages like Forth. It consists in designing very small and elementary low-level building blocks. Thereafter, the building blocks are used to design one level higher building blocks. And you proceed that way, designing higher and higher level building blocks, up to the point where one building block actually solves your problem, maybe with the help of others. You can easily see how well the design methodology fits in the Object-Oriented Programming paradigm. Building blocks are objects (or the other way around if you like). And contrary to plain vanilla Forth for example, they are customizable. You design variants of existing objects to fit more closely your problem, just by subclassing and overriding.

MacApp

Now, what is MacApp? MacApp is NOT an Object-Oriented Language. MacApp is a class library which includes a lot of already debugged object classes. The objects of MacApp handle all the Macintosh features which are always found in a Macintosh application, including handling windows, menu, undo, printing, saving and opening, and a lot more. MacApp also does a lot of things which are very rarely done in commercial applications, including safe memory management, efficient error handling As an effect, MacApp applications are often a lot more “bombproof” than other applications, especially in hostile executing conditions.

So MacApp is an Object-Oriented Application Framework. Object-Oriented because it is built around objects rather than procedures and functions. Framework because MacApp provides a general structure for any application. MacApp implements for you windows, mouse handling, printing And Application because MacApp can only be used to write applications. You won’t be able to use MacApp to write desk accessories, device drivers, INITs, cdev, etc.

MacApp is therefore a large code library. It is written in Object Pascal with some assembler (which by the way tells you that Apple has an Object-Oriented assembler). To use MacApp, you currently must use MPW, with either MPW Pascal, TML Pascal II or p1 Modula II. However Symantec announced its intent to support MacApp under LightSpeed Pascal 2.0. and other third parties are encouraged to support MacApp in their development environments too. All the MacApp code is organized as a main code unit and optional parts. For example, the dialog building block is optional. The mandatory part contains general utility classes as well as the main MacApp classes.

Now, why would you want to use MacApp? Try to look at what Macintosh programming consists of without MacApp. First of all, you have to know the Toolbox. All of it. That means having read and understood all but the most exotic Inside Macintosh chapters. You must deal with a complicated and large main event loop. You must dig out what you can and cannot do for the sake of past, present, and future compatibility. You must program defensively, which means foreseeing every imaginable run-time circumstance. You must handle all memory and error situations. Above all, for each and every application you develop, you have to start over again, reinventing the wheel. Of course you don’t start from scratch every time. But there are a lot of pitfalls in reusing an application as a basis for a new one. Variables change, behavior changes, structure changes.

Now with MacApp you have reusability without the pitfalls, thanks to its Object-Oriented structure. You roughly have to fill in the blanks of a template application. The responsibilities in the application are divided between MacApp and you. MacApp does everything it can know, but nothing it might have to guess. Instead of guessing, MacApp will call your own code. All in all, you can trust MacApp, it will do its part of the job.

There are a lot of benefits in using MacApp. First to benefit will be the users of your application. The reason why is that the typical Macintosh user expects all his/her applications to work the same way. Most of the time, he/she doesn’t even read the documentation. With MacApp, your user will feel at home with your application, because MacApp was written by Apple in strict conformance to its own User Interface Guidelines. Moreover, your application will be compatible with all currently available Macintosh systems, and you can expect it to stay compatible with future hardware or software architectures. For example, an application written with MacApp works without a hitch under A/UX. Of course, all this will be true only if you stick to MacApp rules as defined in its documentation. You will always be free to break whatever you like.

Last, but certainly not least, you will also benefit. You will benefit because you will be able to concentrate on the interesting part of your application. MacApp will take care of the rest. You will benefit because your application will be very modular, and organized along human-like lines. You will benefit because you will always have a running, testable application which will keep your boss happy. And you will benefit because your development cycles will be much shorter, and thus more productive. The high level symbolic Object-Oriented debugging tools that MacApp provides will shorten your development cycle even more.

Drawback? Which drawback? Oh yes, there’s always a drawback! Well, the drawback is that you will have to learn MacApp. It will take some time. How long depends on you, on whether you have any OOP experience, and how much, and on whether you have any Macintosh programming experience, and how much. On average, I would guess the learning time is somewhere between two and three months. But the reward far exceeds the journey. On the other hand there are no other drawbacks. There is no significant speed penalty. There is no significant size penalty.

Conclusion

If you have any objection concerning the objectivity of this paper, or if you find its very objective objectionable, don’t hesitate to object. But the fact is that the future of OOP is very bright in Life, the Universe, Computer Science and Everything. It has already given birth to some very strong new programming languages, including Smalltalk-80, C.L.O.S., Objective-C, and of course C++. Others are probably on the way. Object-Oriented Programming technology will probably increasingly be used for software development, at both application and system level. And I can tell you that Apple is committed to supporting that old paradigm strongly in the future.

In the meantime, So Long, and Thanks for All the MacApp Apps!

Acknowledgments: Douglas Adams provided much of the inspiration for this article.

Bibliography:

Object-Oriented Programming for the Macintosh, Kurt J. Schmucker, Hayden Books, 1986.

Object-Oriented Programming, an Evolutionary Approach, Brad J. Cox, Addison Wesley, 1987.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Ableton Live 11.3.11 - Record music usin...
Ableton Live lets you create and record music on your Mac. Use digital instruments, pre-recorded sounds, and sampled loops to arrange, produce, and perform your music like never before. Ableton Live... Read more
Affinity Photo 2.2.0 - Digital editing f...
Affinity Photo - redefines the boundaries for professional photo editing software for the Mac. With a meticulous focus on workflow it offers sophisticated tools for enhancing, editing and retouching... Read more
SpamSieve 3.0 - Robust spam filter for m...
SpamSieve is a robust spam filter for major email clients that uses powerful Bayesian spam filtering. SpamSieve understands what your spam looks like in order to block it all, but also learns what... Read more
WhatsApp 2.2338.12 - Desktop client for...
WhatsApp is the desktop client for WhatsApp Messenger, a cross-platform mobile messaging app which allows you to exchange messages without having to pay for SMS. WhatsApp Messenger is available for... Read more
Fantastical 3.8.2 - Create calendar even...
Fantastical is the Mac calendar you'll actually enjoy using. Creating an event with Fantastical is quick, easy, and fun: Open Fantastical with a single click or keystroke Type in your event details... Read more
iShowU Instant 1.4.14 - Full-featured sc...
iShowU Instant gives you real-time screen recording like you've never seen before! It is the fastest, most feature-filled real-time screen capture tool from shinywhitebox yet. All of the features you... Read more
Geekbench 6.2.0 - Measure processor and...
Geekbench provides a comprehensive set of benchmarks engineered to quickly and accurately measure processor and memory performance. Designed to make benchmarks easy to run and easy to understand,... Read more
Quicken 7.2.3 - Complete personal financ...
Quicken makes managing your money easier than ever. Whether paying bills, upgrading from Windows, enjoying more reliable downloads, or getting expert product help, Quicken's new and improved features... Read more
EtreCheckPro 6.8.2 - For troubleshooting...
EtreCheck is an app that displays the important details of your system configuration and allow you to copy that information to the Clipboard. It is meant to be used with Apple Support Communities to... Read more
iMazing 2.17.7 - Complete iOS device man...
iMazing is the world’s favourite iOS device manager for Mac and PC. Millions of users every year leverage its powerful capabilities to make the most of their personal or business iPhone and iPad.... Read more

Latest Forum Discussions

See All

‘Junkworld’ Is Out Now As This Week’s Ne...
Epic post-apocalyptic tower-defense experience Junkworld () from Ironhide Games is out now on Apple Arcade worldwide. We’ve been covering it for a while now, and even through its soft launches before, but it has returned as an Apple Arcade... | Read more »
Motorsport legends NASCAR announce an up...
NASCAR often gets a bad reputation outside of America, but there is a certain charm to it with its close side-by-side action and its focus on pure speed, but it never managed to really massively break out internationally. Now, there's a chance... | Read more »
Skullgirls Mobile Version 6.0 Update Rel...
I’ve been covering Marie’s upcoming release from Hidden Variable in Skullgirls Mobile (Free) for a while now across the announcement, gameplay | Read more »
Amanita Design Is Hosting a 20th Anniver...
Amanita Design is celebrating its 20th anniversary (wow I’m old!) with a massive discount across its catalogue on iOS, Android, and Steam for two weeks. The announcement mentions up to 85% off on the games, and it looks like the mobile games that... | Read more »
SwitchArcade Round-Up: ‘Operation Wolf R...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for September 21st, 2023. I got back from the Tokyo Game Show at 8 PM, got to the office here at 9:30 PM, and it is presently 11:30 PM. I’ve done what I can today, and I hope you enjoy... | Read more »
Massive “Dark Rebirth” Update Launches f...
It’s been a couple of months since we last checked in on Diablo Immortal and in that time the game has been doing what it’s been doing since its release in June of last year: Bringing out new seasons with new content and features. | Read more »
‘Samba De Amigo Party-To-Go’ Apple Arcad...
SEGA recently released Samba de Amigo: Party-To-Go () on Apple Arcade and Samba de Amigo: Party Central on Nintendo Switch worldwide as the first new entries in the series in ages. | Read more »
The “Clan of the Eagle” DLC Now Availabl...
Following the last paid DLC and free updates for the game, Playdigious just released a new DLC pack for Northgard ($5.99) on mobile. Today’s new DLC is the “Clan of the Eagle" pack that is available on both iOS and Android for $2.99. | Read more »
Let fly the birds of war as a new Clan d...
Name the most Norse bird you can think of, then give it a twist because Playdigious is introducing not the Raven clan, mostly because they already exist, but the Clan of the Eagle in Northgard’s latest DLC. If you find gathering resources a... | Read more »
Out Now: ‘Ghost Detective’, ‘Thunder Ray...
Each and every day new mobile games are hitting the App Store, and so each week we put together a big old list of all the best new releases of the past seven days. Back in the day the App Store would showcase the same games for a week, and then... | Read more »

Price Scanner via MacPrices.net

Apple AirPods 2 with USB-C now in stock and o...
Amazon has Apple’s 2023 AirPods Pro with USB-C now in stock and on sale for $199.99 including free shipping. Their price is $50 off MSRP, and it’s currently the lowest price available for new AirPods... Read more
New low prices: Apple’s 15″ M2 MacBook Airs w...
Amazon has 15″ MacBook Airs with M2 CPUs and 512GB of storage in stock and on sale for $1249 shipped. That’s $250 off Apple’s MSRP, and it’s the lowest price available for these M2-powered MacBook... Read more
New low price: Clearance 16″ Apple MacBook Pr...
B&H Photo has clearance 16″ M1 Max MacBook Pros, 10-core CPU/32-core GPU/1TB SSD/Space Gray or Silver, in stock today for $2399 including free 1-2 day delivery to most US addresses. Their price... Read more
Switch to Red Pocket Mobile and get a new iPh...
Red Pocket Mobile has new Apple iPhone 15 and 15 Pro models on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide service using all the major... Read more
Apple continues to offer a $350 discount on 2...
Apple has Studio Display models available in their Certified Refurbished store for up to $350 off MSRP. Each display comes with Apple’s one-year warranty, with new glass and a case, and ships free.... Read more
Apple’s 16-inch MacBook Pros with M2 Pro CPUs...
Amazon is offering a $250 discount on new Apple 16-inch M2 Pro MacBook Pros for a limited time. Their prices are currently the lowest available for these models from any Apple retailer: – 16″ MacBook... Read more
Closeout Sale: Apple Watch Ultra with Green A...
Adorama haș the Apple Watch Ultra with a Green Alpine Loop on clearance sale for $699 including free shipping. Their price is $100 off original MSRP, and it’s the lowest price we’ve seen for an Apple... Read more
Use this promo code at Verizon to take $150 o...
Verizon is offering a $150 discount on cellular-capable Apple Watch Series 9 and Ultra 2 models for a limited time. Use code WATCH150 at checkout to take advantage of this offer. The fine print: “Up... Read more
New low price: Apple’s 10th generation iPads...
B&H Photo has the 10th generation 64GB WiFi iPad (Blue and Silver colors) in stock and on sale for $379 for a limited time. B&H’s price is $70 off Apple’s MSRP, and it’s the lowest price... Read more
14″ M1 Pro MacBook Pros still available at Ap...
Apple continues to stock Certified Refurbished standard-configuration 14″ MacBook Pros with M1 Pro CPUs for as much as $570 off original MSRP, with models available starting at $1539. Each model... Read more

Jobs Board

Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Retail Key Holder- *Apple* Blossom Mall - Ba...
Retail Key Holder- APPLE BLOSSOM MALL Brand: Bath & Body Works Location: Winchester, VA, US Location Type: On-site Job ID: 03YM1 Job Area: Store: Sales and Support Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.