Table of Contents
Essential Object Oriented Design
This book covers the basic Object Oriented Design concepts using Ruby programming language. The goal is to provide a solid foundation to build upon. This book distills my Object Oriented Design knowledge into a concise and easy-to-read format. Repetition is key to learning Ruby. We will visit the concepts from different angles. You will get the most benefit out of the book if you work through every example as you read through the book. This book uses Ruby 2.3.0.
About the Author
Bala Paranj has a Master's degree in Electrical Engineering from Wichita State University. He began working in the IT industry in 1996. He started his career as a Technical Support Engineer and then became a Web Developer using Perl, Java and Ruby.
He is available for freelance work. Please contact him at support@zepho.com or via Ruby Plus . He is also working on screencasts based on this book. If you want notification about the release, please contact him.
Basics of Abstraction
In this chapter, you will learn the basics of abstraction using examples.
Definition
The dictionary says abstraction means to draw away , to remove characteristics from something in order to reduce it to a set of essential characteristics. It is a tool for simplification. We find the essence by ignoring irrelevant details.
In his paper Is Abstraction the Key to Computing ?, Jeff Kramer says abstraction also means:
- The process of formulating general concepts by abstracting common properties of instances, and;
- A general concept formed by extracting common features from specific examples.
Example 1
Chemistry is an abstraction of physics.
VS
Biology is an abstraction of chemistry.
VS
Genetics is an abstraction of biology.
VS
Example 2
The London Underground map that overlays the underground system onto a conventional geographical map.
In this map, you can see:
- River Thames
- Relative distances between stations.
Harry Beck's simplified map.
- This fits the purpose of navigating around the London Underground.
- It is misleading for other purposes.
Let's consider two extremes:
Too abstract
The map would not provide sufficient information for the purpose.
Too detailed
The map becomes confusing and less comprehensible.
The level, benefit and value of a particular abstraction depend on its purpose.
Abstraction in Software
To quote Booch in Object-Oriented Analysis and Design with Applications :
An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer."
The term perspective of the viewer needs an explanation. Let us consider a House object, when a banker sees this house, he thinks in terms of the value of the property, opportunity for appreciation, etc whereas when a decorator views it, he thinks in terms of what color the house should be painted, total area to be painted, etc. The same object House can be viewed from different perspectives and can lead to entirely different abstractions by different people.
Booch, Fairsmith, Henderson-Sellers define abstraction as:
Any model that includes the most important, essential, or distinguishing aspects of something while suppressing or ignoring less important, immaterial, or diversionary details.
Coad, Fairsmith, Henderson-Sellers, Rumbaugh define abstraction as:
The cognitive tool for rationalizing the world by considering only those details necessary for the current purpose.
So, abstraction is about what details we choose to emphasize and what details we choose to ignore. What we choose to emphasize is dictated by the application. It simplifies the things that we look at in the real world. For example, a chair can be made up of different kinds of material, height adjusting knobs, reclining adjustment knobs etc. If every time we looked at the chair, if we had to deal with what material it is made up of, how the height adjustment knobs are designed and other irrelevant details related to our purpose using a chair to sit, our brains will be exhausted. So, the abstraction process simplifies things and allows us to manage complexity during problem solving process.
Computer science is a science of abstraction creating the right model for thinking about a problem and devising the appropriate mechanizable techniques to solve it. Every other science deals with the universe as it is. The physicists job, for example, is to understand how the world works, not to invent a world in which physical laws would be simpler or more pleasant to follow. Computer scientists, on the other hand, must create abstractions of real-world problems that can be understood by computer users and, at the same time, that can be represented and manipulated inside a computer. Abstraction in the sense we use it implies simplification, the replacement of a complex and detailed real-world situation by an understandable model within which we can solve a problem. That is, we abstract away the details whose effect on the solution to a problem is minimal or nonexistent, thereby creating a model that lets us deal with the essence of the problem. -- From the book 'Foundations of Computer Science' by Alfred V Aho and Jeffrey D Ullman
Why Abstraction?
Abstraction is crucial to produce clear, elegant designs and programs. It is useful to manage complexity. We can diagnose components at the interfaces rather than by exhaustively tracing functions of all components.
Next page