Abstraction In philosophical terminology abstraction is the thought process wherein ideas are distanced from objects. Abstraction uses a strategy of simplification of detail, wherein formerly concrete details are left ambiguous, vague, or undefined; thus speaking of things in the abstract demands that the listener have an intuitive or common experience with the speaker, if the speaker expects to be understood For example, many different things have the property of redness: lots of things are red
Abstract Art Abstract art is now generally understood to mean art that does not depict objects in the natural world, but instead uses shapes and colours in a non-representational or subjective way. Abstract art is defined as art that has no reference to any figurative reality. In its wider definition the term describes art that depicts real forms in a simplified or rather reduced way - keeping only an allusion of the original natural subject
Abstract Data Type O-O programming is often described as programming with abstract Data types But what is an Abstract Data type ? A tangible or visible 'thing' e.g. a person A conceptual thing e.g. the economy 'An object represents an individual identifiable item, unit or entity, either real or abstract, with a well defined role in the problem domain' 'An abstraction denotes the essential characteristics of an object that distinguishes it from all other kinds of objects and thus provides crisply defined conceptual boundaries, relative to the perspective of the viewer'
Handling Problems Designing Software for real life problems However real life problems are “too complex” So we must separate the necessary from the un- necessary This is known as abstraction Problem Model Abstraction
What Makes an Abstract Data Type (ADT) ADT implies that the model focuses only on the problem defines properties of the problem The problem defines Data which is affected Operations on the data
ADT example: London Underground Map First map created in 1908 Faithful to the geography of the stations and London All distances relative and twist and turns of tracks reproduced Map fully to scale Purpose to show travellers the order of stations on each line, and various interchanges; the fidelity of the map made it difficult to extract information
The New LU Map In 1933 map was changed to a more abstract representation called the diagram Connectivity of stations preserved However passengers could see at a glance the route to the destination This is an abstraction from superfluous detail, in this case the physical layout of the lines was the key to the usefulness of the Diagram
Why is the 'Diagram' a good abstraction Abstract, since it only records the logical layout not the physical reality in all it's detail Concise, it is printed on a single A5 Sheet Complete, Since every station on the London Underground network is represented Unambiguous, Since the meaning of the symbols are explained and the diagram is is expressed in simple geometric terms. Maintainable, with stations being removed and added. This is what we aim for when we are designing Object- Oriented code (and especially C++ classes)
Modelling the Real World OO Links together data and operations performed on the data Any real world object can be described in terms of what it is called (O-O term 'identity') what it is (O-O term 'state') what it does (O-O term 'behaviour') For Example a real world object such as a Coffee cup has : identity (Coffee Cup) state (white, hot, full etc) fixed behavior (manufactured, filled drunk, washed, broken)
Encapsulation Using the Coffee cup example All the previous examples are encapsulated into the object 'Coffee cup' We cannot divorce any one from the other eg. 'full' is linked with the action of 'being filled' as the 'cup cannot be full unless it has at some stage been filled' This link between data ('what it is') and operations ('what it does') This is the sort of real world example which we try to reflect in O-O software development.
How does this relate to Graphics programming? We can use the same abstraction techniques to derive identity, state and behaviour for any objects Try to decide upon identity, state and behaviour for the following A 3D point A Sphere A Colour
Information Hiding Encapsulation allows us to implement information hiding Encapsulation hides 'private' elements of an object behind a 'public' interface to give two aspects to the object protection of the objects state from unforeseen external influences hiding the implementation details used to define an object's behaviour Now an objects state cannot be altered except by fixed methods of behaviour
Information Hiding Now an objects state cannot be altered except by fixed methods of behaviour This makes life easier because behaviour of an object is predictable and less prone to error enhances re-usability and maintainability Now we need only know that an objects state changes and not how
Attributes and Methods To build abstract data types in a program we have to identify three things The abstract 'thing' we are trying to represent The data which represents the state of that 'thing' The behavior of that 'thing' The 'thing' will be the name of the abstract data type but not the object itself but a class of objects. The class will define the common attributes and methods for all objects of the class
Attributes and Methods All Coffee Cups.. have common attributes.... I have a color I have a temperature......................... and common methods.... drink me wash me.......................
Attributes Now we know what we are going to represent we need to identify what elements go to make up its state These are called attributes (in O-O speak) But in programming these are know as variables or data structures These, however, do not specify a value just what it represents For the coffee cup example we would (for example) say it has a colour (but not what the colour is) as all coffee cups have a colour but not all coffee cups are the same colour
Methods The behavior of an object is defined by it's methods These process routines related to the data type However the access to this data is limited by using methods The two most common types of methods are : Selector method (or get method) which retrieves the data from the object Modifier method (or set method) which sets the data from the object
Methods This can be seen using the doughnut diagram Attributes Method1 Method4 Method3 Method2