SlideShare a Scribd company logo
1 of 43
Download to read offline
CSCI-383
Object-Oriented Programming & Design




        Lecture 3-4: Abstraction

                       Ji Ruan
                2009/09/18 and 09/21
Overview

Abstraction and Information Hiding
Levels of Abstraction
Forms of Abstraction
A Short History of Abstraction
Abstraction

 What is Abstraction?
   Definition: Abstraction is the purposeful suppression, or
   hiding, of some details of a process or artifact, in order to
   bring out more clearly other aspects, details, or structure.
   In other word, the elimination of the irrelevant and the
   amplification of the essential
 Why?
   It’s one of the most important techniques to create,
   understand and manage complex systems
An Example of Abstraction - Map
Think of maps, and the different levels of details:
    A map of the world, contains mountain ranges, large political
    boundaries
    A map of a continent, contains all political boundaries, large
    cities
    A map of a country, contains more cities, major roads
    A map of a large city, roads, major structures
    A map of a portion of a city, buildings, occupants
Each level contains information appropriate to the level of
abstraction.
    A demo with: Google Maps (maps.google.com)
Information Hiding

 Information hiding is the purposeful omission
 of details in the development of an abstract
 representation.
 Information hiding is what allows abstraction
 to control complexity.
Example of Real-world Abstraction - Car

        For drivers:
Need to know
Ignition
Steering wheel
Shifting gear
Can ignore (hidden)
the particular engine in this car;
the way fuel is pumped to the engine where a spark ignites it, it explodes pushing down a piston and driving a crankshaft.
        For mechanics:
Need to know
batteries and engines
Can ignore (hidden)
inside the battery there's a complex chemical reaction going on.
        For the battery designers:
Need to know
What is inside the battery
How to make it durable
Can ignore (hidden)
How to use this battery, e.g. the electronics going into the car's radio.
Five Levels of Abstraction
Levels of Abstraction in OO Programs

  At the highest level (level
  1) of abstraction we view
  a program as a
  community of interacting
  objects.
  Important characteristics
  here are the lines of
  communication between
  the various agents.
Abstraction in OO Programs
-- Packages and Name spaces
The next level (level 2) of abstraction is found in some (but not
all) OO languages. A package, Unit or Name Space allows a
programmer to surround a collection of objects (a small
community in itself) with a layer, and control visibility from
outside the module.
Abstraction in OO Languages
-- Clients and Servers
The next level of abstraction considers the relationship between
two individual objects. Typically one is providing a service, and
the other is using the service.
Abstraction in OO languages
-- Description of Services

We can examine just the person
providing a service, independent
of the client. We define the
nature of the services that are
offered, but not how those
services are realized. (like
billboard advertisements)
Levels of Abstraction in OO
-- Interfaces

Interfaces (level 3) are one way to describe services at this level
of abstraction.


   interface Stack {
   public void push (Object val);
   public Object top () throws EmptyStackException;
   public void pop () throws EmptyStackException;
   }
Levels of Abstraction
-- An Implementation
Next (level 4) we look at the services provided, but from the
implementation side:

public class LinkedList implements Stack ... {
public void pop () throws EmptyStackException { ... }
...
}

Concern here is with the high level approach to providing the
designated service.
Levels of Abstraction
-- A Method in Isolation
Finally (level 5), we consider the implementation of each method
in isolation.

public class LinkedList implements Stack ... {
...
public void pop () throws EmptyStackException {
if (isEmpty())
throw new EmptyStackException();
removeFirst(); // delete first element of list
}
...
}

Every level is important, and often you move quickly back and
forth between levels.
Summary of abstraction levels

 Level 1, community of interacting objects
 Level 2, a package or Name Space to surround a collection of
 objects
 Level 3, interfaces to describe services (the client side)
 Level 4, concrete implementation of the abstract behavior
 (the server side)
 Level 5, every single method
Finding the Right Level of Abstraction

  A critical problem in early stages of development is to
  determine what details are appropriate at each level of
  abstraction, and (often more importantly) what details should
  be omitted.
  One does not want to ignore or throw away important
  information
  But one does not want to manage too much information, or
  have the amount of information hide critical details.
Forms of Abstraction
Forms of Abstraction



   Specialization (Is-A)
       Car :: Wheeled vehicle :: Means of transportation
   Division into parts (Has-A)
       Car { engine; transmission; body; wheels}
   Multiple views
       CarDriverView { Ignite(); SteerWheel(); ShiftGear() }
       CarMechanicsView { CheckBattery(); CheckWheels();
       CheckEngine() }
Forms of Abstraction
Is-a Abstraction

  Is-a abstraction takes a complex system, and views it as an
  instance of a more general abstraction.
  Characterized by sentences that have the words "is-a''
      A car is a wheeled vehicle, which is-a means of
      transportation
      A bicycle is-a wheeled vehicle
      A pack horse is-a means of transportation
  Allows us to categorize artifacts and information and make it
  applicable to many different situations.
Has-a Abstraction

 Division into parts takes a complex system, and divides into
 into component parts, which can then be considered in
 isolation.
 Characterized by sentences that have the words "has-a''
     A car has-a engine, and has-a transmission
     A bicycle has-a wheel
     A window has-a menu bar
 Allows us to drop down a level of complexity when we
 consider the component in isolation.
Encapsulation and Interchangeability

  An important aspect of division into parts is to clearly
  characterize the connection, or interface, between two
  components.
  Allows for considering multiple different implementations of
  the same interface.
  For example, a car can have several different types of engine
  and one transmission.
The Service View

 Another way to think of an
 interface is as a way of describing
 the service that an object
 provides.
 The interface is a contract for the
 service--if the interface is upheld,
 then the service will be provided
 as described.
Inheritance and Polymorphism


  Square and Triangle
  inherited method
  set_colour()
  Square and Triangle
  implement different
  method draw()
Other Types of Abstraction: Composition

  While is-a and has-a are two important types of
  abstraction, there are others.
  Composition is one example; a form of has-a;
  characterized by the following
     Primitive forms
     Rules for combining old forms to create new forms
     The idea that new forms can also be subject to further
     combination
Regular expressions
Basic alphabet {a, b, c}

    Rule 1: any single element of the alphabet is a regular expression.
         a is a regular expression
    Rule 2: composition of two regular expressions is a regular
    expression.
         ab is a regular expression
    Rule 3: alternation (|) of two regular expressions is a regular
    expression.
         aba|abc|abd is a regular expression
    Rule 4: use parentheses for grouping, the result is a regular
    expression.
         ab(a|c|d), meaning aba|abc|abd, is a regular expression
    Rule 5: use * symbol represent “zero or more repetitions”, the result
    is a regular expression.
         (((a|b)*c)|dd)a is a regular expression.
Patterns
  Patterns are another attempt to document and
  reuse abstractions.
  Patterns are description of proven and useful
  relationships between objects; which can help
  guide the solution of new problems.
Patterns: example
 The Great Firewall of China, China's Internet Censorship System,
 blocks many sites, e.g Youtube, Wikipedia, Twitter etc.)
 The GFW even blocks my personal blog: jiblog.jiruan.net. Here is a
 screenshot when I tried to visit my blog in a netbar in China (2007).
 “找不到服务器,
 无法显示网页”
 “The Connection
 Has Been Reset”
 (Article | wikipeida)
Patterns: example
 Proxy Model




 An application: crack the GFW using proxy
A Short History of Abstraction Mechanisms
An Overview of History

Another way to better understand OOP is to put it in context with
the history of abstraction in computer science.
    Assembly languages
    Procedures
    Modules
    Abstract Data Type (ADT)
    The Service View
    Objects
    The future....
Assembly Languages
Assembly languages and linkers were perhaps the first tools used
to abstract features of the bare machine.
    Addresses could be represented symbolically, not as a
    number.
    Symbolic names for operations.
    Linking of names and locations performed automatically
Procedures and Functions
 Libraries of procedures and functions (such as mathematical
 or input/output libraries) provided the first hints of
 information hiding.
 They permit the programmer to think about operations in high
 level terms, concentrating on what is being done, not how it is
 being performed.
 But they are not an entirely effective mechanism of
 information hiding.
Failure of Procedures in Information Hiding

A Simple Stacks:
      int datastack[100];
      int datatop = 0;
      void init() // initialize the stack
      { datatop = 0;
      }
      void push(int val) // push a value on to the stack
      { if (datatop < 100)
      datastack [datatop++] = val;
      }
      int top() // get the top of the stack
      { if (datatop > 0)
      return datastack [datatop - 1];
      return 0;
      }
      int pop() // pop element from the stack
      { if (datatop > 0)
      return datastack [--datatop];
      return 0;
      }

Where can you hide the implementation?
Modules

 Modules basically provide collections of
 procedures and data with import and export
 statements
 Solves the problem of encapsulation -- but
 what if your programming task requires two or
 more stacks? (No instantiation)
Parnas's Principles

David Parnas described two principles for the proper use of
modules:
   One must provide the intended user of a module with all the
   information needed to use the module correctly, and with
   nothing more.
   One must provide the implementer of a module with all the
   information needed to complete the module, and nothing
   more.
Abstract Data Types (ADTs)

 An Abstract Data Type is a programmer-defined data type
 that can be manipulated in a manner similar to system-
 provided data types
    Must have the ability to instantiate many different copies of the
    data type.
    Data type can be manipulated using provided operations,
    without knowledge of internal representation.
 But ADTs were important not because they were data
 structures, but because they provided an easily characterized
 service to the rest of an application.
Summery
Looking at the history, we can separate it into three periods of
time:
                                                      Major concern is
         The                 Assembly language        characterizing the
         Function Centered   Functions and Procedures functionality of an
         View                                         application



         The                                           Major concern is
         Data Centered       Modules                   characterizing the
         View                Abstract Data Types       data types used in an
                                                       application



         The                 Object-Oriented           Major concern is
         Service Centered    Programming               characterizing the
         View                                          services provided by
                                                       objects in the application
Objects - ADT's with Message Passing

Characterists of Objects
   Encapsulation -- similar to modules
   Instantiation -- similar to ADT's
   Messages -- dynamic binding of procedure names to behavior
   Classes -- a way of organization that permits sharing and
   reuse
   Polymorphism -- A new form of software reuse using
   dynamic binding
What Does the Future Hold?
 Prediction is hard, particularly about the future.
 However, one you have accepted the idea of an application
 formed from interacting agents, there is no reason why those
 components must exist on the same computer (distributed
 computing) or be written in the same language (components).
 So some of the trends we see today in software are natural
 results of the OOP mind set.
 Web services, Cloud computing, Agent-Based Computing
Basic Idea of Cloud Computing
Cloud computing is a paradigm of computing in which dynamically scalable and
often virtualized resources are provided as a service over the Internet. Users need
not have knowledge of, expertise in, or control over the technology infrastructure
in the "cloud" that supports them.
Assignment 2:



 Textbook Chapter 2: Exercises 1,2,3.
 Deadline: Wed, September 30, 2009.
 Either by email or giving it to me directly in
 the class.
About these slides

These slides are created by Dr.    The slides are licensed under
Ji Ruan on top of the lecture      Creative Commons Attribution-
notes by Prof. Wendy MacCaull      Share Alike 3.0
and Dr. Hao Wang from their
previous years' teaching on this
course at StFX University.         You are free to Share and Remix
                                   this work, under the following
The core materials are based on    conditions:
book: An introduction to Object-       Attribution
Oriented Programming, 3rd              Share Alike
edition, by Timothy Budd.

More Related Content

What's hot

C programming structures &amp; union
C programming structures &amp; unionC programming structures &amp; union
C programming structures &amp; unionBathshebaparimala
 
Structure in c language
Structure in c languageStructure in c language
Structure in c languagesangrampatil81
 
Visula C# Programming Lecture 8
Visula C# Programming Lecture 8Visula C# Programming Lecture 8
Visula C# Programming Lecture 8Abou Bakr Ashraf
 
Cs583 information-integration
Cs583 information-integrationCs583 information-integration
Cs583 information-integrationBorseshweta
 
R Programming: Introduction to Vectors
R Programming: Introduction to VectorsR Programming: Introduction to Vectors
R Programming: Introduction to VectorsRsquared Academy
 
Introduction to database-Normalisation
Introduction to database-NormalisationIntroduction to database-Normalisation
Introduction to database-NormalisationAjit Nayak
 
Ppt 2 d ploting k10998
Ppt 2 d ploting k10998Ppt 2 d ploting k10998
Ppt 2 d ploting k10998Vinit Rajput
 
Lecture 5 Inheritance
Lecture 5 InheritanceLecture 5 Inheritance
Lecture 5 Inheritancebunnykhan
 
SAD11 - Sequence Diagrams
SAD11 - Sequence DiagramsSAD11 - Sequence Diagrams
SAD11 - Sequence DiagramsMichael Heron
 
R Programming: Variables & Data Types
R Programming: Variables & Data TypesR Programming: Variables & Data Types
R Programming: Variables & Data TypesRsquared Academy
 
Classes And Methods
Classes And MethodsClasses And Methods
Classes And Methodsadil raja
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database DesignPrabu U
 
An Introduction to the SOLID Principles
An Introduction to the SOLID PrinciplesAn Introduction to the SOLID Principles
An Introduction to the SOLID PrinciplesAttila Bertók
 
Dbms ii mca-ch5-ch6-relational algebra-2013
Dbms ii mca-ch5-ch6-relational algebra-2013Dbms ii mca-ch5-ch6-relational algebra-2013
Dbms ii mca-ch5-ch6-relational algebra-2013Prosanta Ghosh
 

What's hot (20)

C programming structures &amp; union
C programming structures &amp; unionC programming structures &amp; union
C programming structures &amp; union
 
Structure in c language
Structure in c languageStructure in c language
Structure in c language
 
Visula C# Programming Lecture 8
Visula C# Programming Lecture 8Visula C# Programming Lecture 8
Visula C# Programming Lecture 8
 
CASCON04.ppt
CASCON04.pptCASCON04.ppt
CASCON04.ppt
 
Cs583 information-integration
Cs583 information-integrationCs583 information-integration
Cs583 information-integration
 
R Programming: Introduction to Vectors
R Programming: Introduction to VectorsR Programming: Introduction to Vectors
R Programming: Introduction to Vectors
 
Designmethodology1
Designmethodology1Designmethodology1
Designmethodology1
 
Introduction to database-Normalisation
Introduction to database-NormalisationIntroduction to database-Normalisation
Introduction to database-Normalisation
 
Ppt 2 d ploting k10998
Ppt 2 d ploting k10998Ppt 2 d ploting k10998
Ppt 2 d ploting k10998
 
Lecture 5 Inheritance
Lecture 5 InheritanceLecture 5 Inheritance
Lecture 5 Inheritance
 
SAD11 - Sequence Diagrams
SAD11 - Sequence DiagramsSAD11 - Sequence Diagrams
SAD11 - Sequence Diagrams
 
R Programming: Variables & Data Types
R Programming: Variables & Data TypesR Programming: Variables & Data Types
R Programming: Variables & Data Types
 
Structure and union
Structure and unionStructure and union
Structure and union
 
Classes And Methods
Classes And MethodsClasses And Methods
Classes And Methods
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
 
An Introduction to the SOLID Principles
An Introduction to the SOLID PrinciplesAn Introduction to the SOLID Principles
An Introduction to the SOLID Principles
 
Dbms ii mca-ch5-ch6-relational algebra-2013
Dbms ii mca-ch5-ch6-relational algebra-2013Dbms ii mca-ch5-ch6-relational algebra-2013
Dbms ii mca-ch5-ch6-relational algebra-2013
 
L9
L9L9
L9
 
User defined functions in matlab
User defined functions in  matlabUser defined functions in  matlab
User defined functions in matlab
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 

Viewers also liked

Applying Innovation at different levels of abstraction
Applying Innovation at different levels of abstractionApplying Innovation at different levels of abstraction
Applying Innovation at different levels of abstractionJathish MJ
 
Is Abstraction the Key to Artificial Intelligence? - Lorenza Saitta
Is Abstraction the Key to Artificial Intelligence? - Lorenza SaittaIs Abstraction the Key to Artificial Intelligence? - Lorenza Saitta
Is Abstraction the Key to Artificial Intelligence? - Lorenza SaittaWithTheBest
 
Temas de análisis químico y control de calidad
Temas de análisis químico y control de calidadTemas de análisis químico y control de calidad
Temas de análisis químico y control de calidadMario Mercado
 
Dirección estratégica
Dirección estratégicaDirección estratégica
Dirección estratégicaThink Creative
 
Regalito Mesaversario
Regalito MesaversarioRegalito Mesaversario
Regalito Mesaversariosangulo85
 
Digital Communication Power Tools: Speakers Notes version
Digital Communication Power Tools: Speakers Notes versionDigital Communication Power Tools: Speakers Notes version
Digital Communication Power Tools: Speakers Notes versionMarilyn Herie
 
Networks and resourcing white paper by Business360 and TFPL December 2013
Networks and resourcing white paper by Business360 and TFPL December 2013Networks and resourcing white paper by Business360 and TFPL December 2013
Networks and resourcing white paper by Business360 and TFPL December 2013TFPLltd
 
EUROSTAT Study on Circulatory diseases main causes of death for persons aged...
EUROSTAT Study on Circulatory diseases  main causes of death for persons aged...EUROSTAT Study on Circulatory diseases  main causes of death for persons aged...
EUROSTAT Study on Circulatory diseases main causes of death for persons aged...ESPAMarketing
 
Mapa Don Ferdinando
Mapa Don FerdinandoMapa Don Ferdinando
Mapa Don FerdinandoSantiVI
 
Friedrichshafen
FriedrichshafenFriedrichshafen
Friedrichshafenkaiwen0926
 
Propuesta masa
Propuesta masaPropuesta masa
Propuesta masaENAXION77
 
Il mausoleo di Ciano a Livorno - Rilievo digitale e ricostruzione critica
Il mausoleo di Ciano a Livorno - Rilievo digitale e ricostruzione criticaIl mausoleo di Ciano a Livorno - Rilievo digitale e ricostruzione critica
Il mausoleo di Ciano a Livorno - Rilievo digitale e ricostruzione criticaMattia Sullini
 

Viewers also liked (20)

Abstraction
AbstractionAbstraction
Abstraction
 
Biometria
BiometriaBiometria
Biometria
 
Applying Innovation at different levels of abstraction
Applying Innovation at different levels of abstractionApplying Innovation at different levels of abstraction
Applying Innovation at different levels of abstraction
 
Ch1 1
Ch1 1Ch1 1
Ch1 1
 
Is Abstraction the Key to Artificial Intelligence? - Lorenza Saitta
Is Abstraction the Key to Artificial Intelligence? - Lorenza SaittaIs Abstraction the Key to Artificial Intelligence? - Lorenza Saitta
Is Abstraction the Key to Artificial Intelligence? - Lorenza Saitta
 
295 - Abstraction
295 - Abstraction295 - Abstraction
295 - Abstraction
 
Multithreading Design Patterns
Multithreading Design PatternsMultithreading Design Patterns
Multithreading Design Patterns
 
Temas de análisis químico y control de calidad
Temas de análisis químico y control de calidadTemas de análisis químico y control de calidad
Temas de análisis químico y control de calidad
 
Ewerpol - auto serwis Piaseczno
Ewerpol - auto serwis PiasecznoEwerpol - auto serwis Piaseczno
Ewerpol - auto serwis Piaseczno
 
Dirección estratégica
Dirección estratégicaDirección estratégica
Dirección estratégica
 
Regalito Mesaversario
Regalito MesaversarioRegalito Mesaversario
Regalito Mesaversario
 
Digital Communication Power Tools: Speakers Notes version
Digital Communication Power Tools: Speakers Notes versionDigital Communication Power Tools: Speakers Notes version
Digital Communication Power Tools: Speakers Notes version
 
Document 104
Document 104Document 104
Document 104
 
Networks and resourcing white paper by Business360 and TFPL December 2013
Networks and resourcing white paper by Business360 and TFPL December 2013Networks and resourcing white paper by Business360 and TFPL December 2013
Networks and resourcing white paper by Business360 and TFPL December 2013
 
EUROSTAT Study on Circulatory diseases main causes of death for persons aged...
EUROSTAT Study on Circulatory diseases  main causes of death for persons aged...EUROSTAT Study on Circulatory diseases  main causes of death for persons aged...
EUROSTAT Study on Circulatory diseases main causes of death for persons aged...
 
Mapa Don Ferdinando
Mapa Don FerdinandoMapa Don Ferdinando
Mapa Don Ferdinando
 
Friedrichshafen
FriedrichshafenFriedrichshafen
Friedrichshafen
 
Propuesta masa
Propuesta masaPropuesta masa
Propuesta masa
 
Il mausoleo di Ciano a Livorno - Rilievo digitale e ricostruzione critica
Il mausoleo di Ciano a Livorno - Rilievo digitale e ricostruzione criticaIl mausoleo di Ciano a Livorno - Rilievo digitale e ricostruzione critica
Il mausoleo di Ciano a Livorno - Rilievo digitale e ricostruzione critica
 
Por Tutatis
Por TutatisPor Tutatis
Por Tutatis
 

Similar to CSCI 383 Lecture 3 and 4: Abstraction

MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...Aravind NC
 
Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1LK394
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfkarymadelaneyrenne19
 
ITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptxITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptxkristinatemen
 
Functional Effects - Part 1
Functional Effects - Part 1Functional Effects - Part 1
Functional Effects - Part 1Philip Schwarz
 
Object oriented modelling
Object oriented modellingObject oriented modelling
Object oriented modellingsujithmv1
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptVGaneshKarthikeyan
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptVGaneshKarthikeyan
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptVGaneshKarthikeyan
 
Architecture and design
Architecture and designArchitecture and design
Architecture and designhimanshu_airon
 
M04 Design Patterns
M04 Design PatternsM04 Design Patterns
M04 Design PatternsDang Tuan
 

Similar to CSCI 383 Lecture 3 and 4: Abstraction (20)

Abstraction
AbstractionAbstraction
Abstraction
 
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...
MC0083 – Object Oriented Analysis &. Design using UML - Master of Computer Sc...
 
Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
 
Intro Uml
Intro UmlIntro Uml
Intro Uml
 
ITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptxITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptx
 
Uml - An Overview
Uml - An OverviewUml - An Overview
Uml - An Overview
 
Functional Effects - Part 1
Functional Effects - Part 1Functional Effects - Part 1
Functional Effects - Part 1
 
Object oriented modelling
Object oriented modellingObject oriented modelling
Object oriented modelling
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
java tr.docx
java tr.docxjava tr.docx
java tr.docx
 
SEMINAR
SEMINARSEMINAR
SEMINAR
 
Seminar
SeminarSeminar
Seminar
 
uml2-1214558329929112-8.ppt
uml2-1214558329929112-8.pptuml2-1214558329929112-8.ppt
uml2-1214558329929112-8.ppt
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
 
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.pptUNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
UNIT-I(Unified_Process_and_Use Case_Diagrams)_OOAD.ppt
 
Architecture and design
Architecture and designArchitecture and design
Architecture and design
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
M04 Design Patterns
M04 Design PatternsM04 Design Patterns
M04 Design Patterns
 

Recently uploaded

ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

CSCI 383 Lecture 3 and 4: Abstraction

  • 1. CSCI-383 Object-Oriented Programming & Design Lecture 3-4: Abstraction Ji Ruan 2009/09/18 and 09/21
  • 2. Overview Abstraction and Information Hiding Levels of Abstraction Forms of Abstraction A Short History of Abstraction
  • 3. Abstraction What is Abstraction? Definition: Abstraction is the purposeful suppression, or hiding, of some details of a process or artifact, in order to bring out more clearly other aspects, details, or structure. In other word, the elimination of the irrelevant and the amplification of the essential Why? It’s one of the most important techniques to create, understand and manage complex systems
  • 4. An Example of Abstraction - Map Think of maps, and the different levels of details: A map of the world, contains mountain ranges, large political boundaries A map of a continent, contains all political boundaries, large cities A map of a country, contains more cities, major roads A map of a large city, roads, major structures A map of a portion of a city, buildings, occupants Each level contains information appropriate to the level of abstraction. A demo with: Google Maps (maps.google.com)
  • 5. Information Hiding Information hiding is the purposeful omission of details in the development of an abstract representation. Information hiding is what allows abstraction to control complexity.
  • 6. Example of Real-world Abstraction - Car For drivers: Need to know Ignition Steering wheel Shifting gear Can ignore (hidden) the particular engine in this car; the way fuel is pumped to the engine where a spark ignites it, it explodes pushing down a piston and driving a crankshaft. For mechanics: Need to know batteries and engines Can ignore (hidden) inside the battery there's a complex chemical reaction going on. For the battery designers: Need to know What is inside the battery How to make it durable Can ignore (hidden) How to use this battery, e.g. the electronics going into the car's radio.
  • 7. Five Levels of Abstraction
  • 8. Levels of Abstraction in OO Programs At the highest level (level 1) of abstraction we view a program as a community of interacting objects. Important characteristics here are the lines of communication between the various agents.
  • 9. Abstraction in OO Programs -- Packages and Name spaces The next level (level 2) of abstraction is found in some (but not all) OO languages. A package, Unit or Name Space allows a programmer to surround a collection of objects (a small community in itself) with a layer, and control visibility from outside the module.
  • 10. Abstraction in OO Languages -- Clients and Servers The next level of abstraction considers the relationship between two individual objects. Typically one is providing a service, and the other is using the service.
  • 11. Abstraction in OO languages -- Description of Services We can examine just the person providing a service, independent of the client. We define the nature of the services that are offered, but not how those services are realized. (like billboard advertisements)
  • 12. Levels of Abstraction in OO -- Interfaces Interfaces (level 3) are one way to describe services at this level of abstraction. interface Stack { public void push (Object val); public Object top () throws EmptyStackException; public void pop () throws EmptyStackException; }
  • 13. Levels of Abstraction -- An Implementation Next (level 4) we look at the services provided, but from the implementation side: public class LinkedList implements Stack ... { public void pop () throws EmptyStackException { ... } ... } Concern here is with the high level approach to providing the designated service.
  • 14. Levels of Abstraction -- A Method in Isolation Finally (level 5), we consider the implementation of each method in isolation. public class LinkedList implements Stack ... { ... public void pop () throws EmptyStackException { if (isEmpty()) throw new EmptyStackException(); removeFirst(); // delete first element of list } ... } Every level is important, and often you move quickly back and forth between levels.
  • 15. Summary of abstraction levels Level 1, community of interacting objects Level 2, a package or Name Space to surround a collection of objects Level 3, interfaces to describe services (the client side) Level 4, concrete implementation of the abstract behavior (the server side) Level 5, every single method
  • 16. Finding the Right Level of Abstraction A critical problem in early stages of development is to determine what details are appropriate at each level of abstraction, and (often more importantly) what details should be omitted. One does not want to ignore or throw away important information But one does not want to manage too much information, or have the amount of information hide critical details.
  • 18. Forms of Abstraction Specialization (Is-A) Car :: Wheeled vehicle :: Means of transportation Division into parts (Has-A) Car { engine; transmission; body; wheels} Multiple views CarDriverView { Ignite(); SteerWheel(); ShiftGear() } CarMechanicsView { CheckBattery(); CheckWheels(); CheckEngine() }
  • 20. Is-a Abstraction Is-a abstraction takes a complex system, and views it as an instance of a more general abstraction. Characterized by sentences that have the words "is-a'' A car is a wheeled vehicle, which is-a means of transportation A bicycle is-a wheeled vehicle A pack horse is-a means of transportation Allows us to categorize artifacts and information and make it applicable to many different situations.
  • 21. Has-a Abstraction Division into parts takes a complex system, and divides into into component parts, which can then be considered in isolation. Characterized by sentences that have the words "has-a'' A car has-a engine, and has-a transmission A bicycle has-a wheel A window has-a menu bar Allows us to drop down a level of complexity when we consider the component in isolation.
  • 22. Encapsulation and Interchangeability An important aspect of division into parts is to clearly characterize the connection, or interface, between two components. Allows for considering multiple different implementations of the same interface. For example, a car can have several different types of engine and one transmission.
  • 23. The Service View Another way to think of an interface is as a way of describing the service that an object provides. The interface is a contract for the service--if the interface is upheld, then the service will be provided as described.
  • 24. Inheritance and Polymorphism Square and Triangle inherited method set_colour() Square and Triangle implement different method draw()
  • 25. Other Types of Abstraction: Composition While is-a and has-a are two important types of abstraction, there are others. Composition is one example; a form of has-a; characterized by the following Primitive forms Rules for combining old forms to create new forms The idea that new forms can also be subject to further combination
  • 26. Regular expressions Basic alphabet {a, b, c} Rule 1: any single element of the alphabet is a regular expression. a is a regular expression Rule 2: composition of two regular expressions is a regular expression. ab is a regular expression Rule 3: alternation (|) of two regular expressions is a regular expression. aba|abc|abd is a regular expression Rule 4: use parentheses for grouping, the result is a regular expression. ab(a|c|d), meaning aba|abc|abd, is a regular expression Rule 5: use * symbol represent “zero or more repetitions”, the result is a regular expression. (((a|b)*c)|dd)a is a regular expression.
  • 27. Patterns Patterns are another attempt to document and reuse abstractions. Patterns are description of proven and useful relationships between objects; which can help guide the solution of new problems.
  • 28. Patterns: example The Great Firewall of China, China's Internet Censorship System, blocks many sites, e.g Youtube, Wikipedia, Twitter etc.) The GFW even blocks my personal blog: jiblog.jiruan.net. Here is a screenshot when I tried to visit my blog in a netbar in China (2007). “找不到服务器, 无法显示网页” “The Connection Has Been Reset” (Article | wikipeida)
  • 29. Patterns: example Proxy Model An application: crack the GFW using proxy
  • 30. A Short History of Abstraction Mechanisms
  • 31. An Overview of History Another way to better understand OOP is to put it in context with the history of abstraction in computer science. Assembly languages Procedures Modules Abstract Data Type (ADT) The Service View Objects The future....
  • 32. Assembly Languages Assembly languages and linkers were perhaps the first tools used to abstract features of the bare machine. Addresses could be represented symbolically, not as a number. Symbolic names for operations. Linking of names and locations performed automatically
  • 33. Procedures and Functions Libraries of procedures and functions (such as mathematical or input/output libraries) provided the first hints of information hiding. They permit the programmer to think about operations in high level terms, concentrating on what is being done, not how it is being performed. But they are not an entirely effective mechanism of information hiding.
  • 34. Failure of Procedures in Information Hiding A Simple Stacks: int datastack[100]; int datatop = 0; void init() // initialize the stack { datatop = 0; } void push(int val) // push a value on to the stack { if (datatop < 100) datastack [datatop++] = val; } int top() // get the top of the stack { if (datatop > 0) return datastack [datatop - 1]; return 0; } int pop() // pop element from the stack { if (datatop > 0) return datastack [--datatop]; return 0; } Where can you hide the implementation?
  • 35. Modules Modules basically provide collections of procedures and data with import and export statements Solves the problem of encapsulation -- but what if your programming task requires two or more stacks? (No instantiation)
  • 36. Parnas's Principles David Parnas described two principles for the proper use of modules: One must provide the intended user of a module with all the information needed to use the module correctly, and with nothing more. One must provide the implementer of a module with all the information needed to complete the module, and nothing more.
  • 37. Abstract Data Types (ADTs) An Abstract Data Type is a programmer-defined data type that can be manipulated in a manner similar to system- provided data types Must have the ability to instantiate many different copies of the data type. Data type can be manipulated using provided operations, without knowledge of internal representation. But ADTs were important not because they were data structures, but because they provided an easily characterized service to the rest of an application.
  • 38. Summery Looking at the history, we can separate it into three periods of time: Major concern is The Assembly language characterizing the Function Centered Functions and Procedures functionality of an View application The Major concern is Data Centered Modules characterizing the View Abstract Data Types data types used in an application The Object-Oriented Major concern is Service Centered Programming characterizing the View services provided by objects in the application
  • 39. Objects - ADT's with Message Passing Characterists of Objects Encapsulation -- similar to modules Instantiation -- similar to ADT's Messages -- dynamic binding of procedure names to behavior Classes -- a way of organization that permits sharing and reuse Polymorphism -- A new form of software reuse using dynamic binding
  • 40. What Does the Future Hold? Prediction is hard, particularly about the future. However, one you have accepted the idea of an application formed from interacting agents, there is no reason why those components must exist on the same computer (distributed computing) or be written in the same language (components). So some of the trends we see today in software are natural results of the OOP mind set. Web services, Cloud computing, Agent-Based Computing
  • 41. Basic Idea of Cloud Computing Cloud computing is a paradigm of computing in which dynamically scalable and often virtualized resources are provided as a service over the Internet. Users need not have knowledge of, expertise in, or control over the technology infrastructure in the "cloud" that supports them.
  • 42. Assignment 2: Textbook Chapter 2: Exercises 1,2,3. Deadline: Wed, September 30, 2009. Either by email or giving it to me directly in the class.
  • 43. About these slides These slides are created by Dr. The slides are licensed under Ji Ruan on top of the lecture Creative Commons Attribution- notes by Prof. Wendy MacCaull Share Alike 3.0 and Dr. Hao Wang from their previous years' teaching on this course at StFX University. You are free to Share and Remix this work, under the following The core materials are based on conditions: book: An introduction to Object- Attribution Oriented Programming, 3rd Share Alike edition, by Timothy Budd.