Material Type: Exam;
Professor: Champion;
Class: A Mathematical World;
Subject: Mathematics;
University: University of Illinois - Urbana-Champaign;
Term: Summer 2018;
01.1. Introduction^ Lecture No.01Course Objective: Objective of this course is to make students familiar with the concepts ofobject oriented programming. These concepts will be reinforced by theirimplementation in C++. Course Contents: The main topics that we will study in the 45 lectures of this course are givenbelow, Recommended Text Book: Reference Books: • • • • • • • • 1. Object OrientationObjects and ClassesOverloadingInheritancePolymorphismGeneric ProgrammingException HandlingIntroduction to Design PatternsC++ How to Program (Object-Oriented Software Engineering Deitel & Deitel )
2. By Jacobson, Christerson, Jonsson, Overgaard(For object oriented programming introductory concepts)The C++ Programming Language By Bjarne Stroustrup(For better c++ understanding)
Objects in a School
Suppose we want to develop a fee collection system for a school for this we will needto find out related objects and their interactions as happens in real life.In this way we can say thatworld problems by thinking solution of the problem in terms of real world objects. So we can say that in our daily life everything can be taken as an object that behaves in acertain way and has certain attributes. In object orientation we move our concentration to objects in contrast to proceduralparadigm in which we simply write our code in functions and call them in our mainprogram. 01.2. A model is an abstraction of something real or conceptual.We need models to understand an aspect of reality.^ Teacher^ BookParents What is a Model?^ StudentPenClassroom object orientation^ makes it easier for usSchool BagPlaygroundLibrary to solve our real
Model Examples Highway mapsArchitectural modelsMechanical models 01.3. In the context of programming models are used to understand the problem beforestarting developing it.We make Object Oriented models showing several interacting objects to understanda system given to us for implementation. Example 1– Object Oriented Model Objects Ali, Car, House, Tree OO Models: Interactions Ali lives in the house
Example 2– Object Oriented Model (A School Model)Ali drives the car^ AliCardrives lives-in HouseTree
01.6. Examples of Tangible Objects: Ali is a tangible object, having some characteristics (attributes) and behavior as givenbelow, We will identify Ali using his name. Car is also a tangible object having some characteristics (attributes) and behaviorgiven below, CarState (attributes) ColorModel AliCharacteristics (attributes) NameAge^ 3. Tangible and Intangible Objects^ Unique identity Behavior (operations)AccelerateStart CarChange GearBehaviour (operations)WalksEats
We can identify Car using its registration number Examples of Intangible Objects (also called as conceptual objects): Time is an intangible (conceptual) object We will assign our own generated unique ID in the model for Time object Date is also an intangible (conceptual) object TimeState (attributes) HoursSecondsMinutes State (attributes) YearDayMonth Behavior (operations)Set/Get HoursSet/Get Seconds Set/Get Minutes Behavior (operations) Set/Get YearSet/Get DaySet/Get Month
We will assign our own generated unique ID in the model for Date object. 01.7. • • • • • • • • • • Summary: Model is the abstraction of some real word scenario. It helps us to understandthat scenario.Object oriented model of any scenario (problem) describes that scenario(problem) in the form of interacting objects.We use Object Orientation because it helps us in mapping real world problemin a programming language.Object Orientation is achieved using objects and their relationships.Properties of an object are described using itsobject is described using itsObjects may be tangible (physical) or intangible (also called conceptual orvirtual).Generally when we have given a certain problem description,problem description areThere may be more than one aspects of an objectIt is not necessary that every object has a specific role in implementation of aproblem there may be some objects without any role, like school parking inour school.It is easier to develop programs using Object Oriented Programming becauseit is closer to real life. candidates functions. for becoming objects of our system. data members and behavior of an nouns in that
Advantages of Information Hiding Following are two major advantages of information hiding, It simplifies our Object Oriented Model: Asinteractions hiding implementation details so it makes it easier for everyone tounderstand our object oriented model. It is a barrier against change propagation As implementation of functions is limited to our class and we have only given thename of functions to user along with description of parameters so if we changeimplementation of function it doesn’t affect the object oriented model.We can achieve information hiding usingthese two concepts in detail now, 02.2. Encapsulation means itself” Encapsulation and information hiding are much related concepts (informationwe Encapsulation saw earlier^ •^ •^ •^ thatAll information related to an object is stored within the objectIt is hidden from the outside worldIt can only be manipulated by the object itself “we have enclosed all the characteristics of an object in the object our object oriented Encapsulation model only and hadAbstraction objects , so we seeand their
hiding is achieved using Encapsulation)We have seen in previous lecture that object characteristics include data membersand behavior of the object in the form of functions.So we can say that Data and Behavior are tightly coupled inside an object andboth the information structure and implementation details of its operations arehidden from the outer world. Examples of Encapsulation Consider the same example of object Ali of previous lecture we described it asfollows,
You can see that Ali stores his personal information in itself and its behavior isalso implemented in it.Now it is up to object Ali whether he wants to share that information withoutside world or not. Same thing stands for its behavior if some other object inreal life wants to use his behavior of walking it can not use it without thepermission of Ali.So we say that attributes and behavior of Ali are encapsulated in it.Any other object don’t know about these things unless Ali share this informationwith that object through an interface,Same concept also applies to phone which has some data and behavior ofshowing that data to user we can only access the information stored in the phoneif phone interface allow us to do so. Advantages of Encapsulation The following are the main advantages of Encapsulation, a. As all data and functions are stored in the objects so there is no data or functionaround in program that is not part of any object and is this way it becomes veryeasy to understand the purpose of each data member and function in an object. b. As data members and functions are hidden in objects and each object has aspecific behavior so there is less complexity in codesituations that a functions is using some other function and that functions is Simplicity and clarityLow complexity there will be no such
02.3. using some other function.^ c.^ Everyone will be able to understand whole scenario by simple looking into objectdiagrams without any issue as each object has specific role and specific relationwith other objects. Interface^ Better understanding
Ali • • CharacteristicsBehavior(attributes)(operations) • • NameAgeWalksEats
02.5.^ b. Real Life example of separation of interface and implementations Separation of Interface & Implementation^ So it has,Address Book in a Phone^ Similarly take the example of contact details saved in the SIM of a phone,In that case we can say physical structure of SIM card as^ And Read/write operations provided by the phone as As discussed earlier we only show interface of an object to outside world andhide actual implementation from outside world. The benefit of using thisapproach is that our object interface to outside word becomes independentfrom inside implementation of that interface.This is achieved through the concepts of encapsulation and informationhiding.^ •^ • ¾^ Data StructureFunctionalityDriver has a standard interface to drive a car and using that interfacehe drive can drive any car regardless of its model or type whateverengine type it has or whatever type of fuel it is using.^ mechanism to change gear^ in the form of Mechanical structure of gear box^ Functionality^ Data Structure.
02.6. A Person sends message (stimulus) “stop” to a Car by applying brakesA Person sends message “place call” to a Phone by pressing appropriate button 02.7. Examples – Messages MessagesSummary Objects communicate through messages they send messages (stimuli) byinvoking appropriate operations on the target object. The number and kind ofmessages that can be sent to an object depends upon its interface • • • • • • Information hiding is achieved through encapsulation.Encapsulation and Information Hiding are related to each other.Interface of an object provides us the list of available functions.An object may have more than one interface.Interface and implementation are separated from each other to achieveInformation Hiding.Objects communicate with each other using messages.
Useful Links:http://www.alice.org/A Graphical Programming Environment to teach Computer Programming.