Week1
Upcoming SlideShare
Loading in...5
×
 

Week1

on

  • 264 views

 

Statistics

Views

Total Views
264
Views on SlideShare
264
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Week1 Week1 Presentation Transcript

  • 1Object Oriented ProgrammingDevelopmentBy:Anoop GuptaSoftEra InformativeC-DAC TrainingEmail:softera.informative@gmail.com
  • Oops ?Object oriented programming is aprogramming paradigm which usesobjects and its interactions to designapplications and computer programs.Simula67 was the first object-orientedprogramming language. Java, Python, C++, Visual Basic .NET and Ruby are themost popular OOP languages today.2
  • Oops Features ?ClassObjectEncapsulationAbstractionPolymorphismInheritance3
  • Class ?Classes are user-defined (programmer-defined) types.Data (data members)Functions (member functions or methods)In other words, they are structures +functionsClasses are logical entity which definesbehaviors and property for Object4
  • ClassExamples -•Animals•Human•Books•Cricketer 5
  • Classes in C++A class definition begins with the keywordclass.The body of the class is contained within aset of braces, { } ; (notice the semi-colon)6Class class_Name{ ……………………..};Any valid identifierClass body (datamember + methodsmethods)
  • Object ?Object is a real time entity which existphysicallyObject occupy some space into memoryEvery object have some specific propertyand behavior but all objects from thesame class share common property andbehavior7
  • Objects ?•Animals8
  • 9What are we doing today?Introduction of:the lecturerObjectsBasic TerminologyC++the module
  • ObjectFruits10
  • Abstraction ?Abstraction is another good feature ofOOPS. Abstraction means to show onlythe necessary details to the client of theobject.Abstraction says that hide un necessarydetail from the user which are not requiredthem11
  • AbstractionAbstraction12
  • EncapsulationEncapsulation is a process of binding orwrapping the data and the codes thatoperates on the data into a single entity.This keeps the data safe from outsideinterface and misuse.Encapsulation Provide data security .13
  • EncapsulationEncapsulation defines the access levelsfor elements of that class. These accesslevels define the access rights to the data,allowing us to access the data by amethod of that particular class itself, fromaninheritance class, or even from anyother class. There are three levels ofaccess:14
  • Encapsulation– Encapsulation15
  • Polymorphism16
  • 17What is Object OrientedProgramming?An object is like ablack box.The internaldetails arehidden.Identifying objects andassigning responsibilities tothese objects.Objects communicate toother objects by sendingmessages.Messages are received bythe methods of an object
  • 18What is an object?Tangible Things as a car, printer, ...Roles as employee, boss, ...Incidents as flight, overflow, ...Interactions as contract, sale, ...Specifications as colour, shape, …
  • 19So, what are objects?an object represents an individual,identifiable item, unit, or entity, either realor abstract, with a well-defined role in theproblem domain.OrAn "object" is anything to which a conceptapplies.Etc.
  • 20Why do we care aboutobjects?Modularity - large software projectscan be split up in smaller pieces.Reuseability - Programs can beassembled from pre-written softwarecomponents.Extensibility - New softwarecomponents can be written ordeveloped from existing ones.
  • Example: The Person class#include<string>#include<iostream>class Person{char name[20];int yearOfBirth;public:void displayDetails() {cout << name << " born in "<< yearOfBirth << endl;}//...};privatedatapublicprocesses
  • 22The two parts of an objectObject = Data + Methodsor to say the same differently:An object has the responsibility to know andthe responsibility to do.= +
  • 23Basic TerminologyAbstraction is the representation of theessential features of an object. These are‘encapsulated’ into an abstract data type.Encapsulation is the practice of includingin an object everything it needs hiddenfrom other objects. The internal state isusually not accessible by other objects.
  • 24Basic Terminology:InheritanceInheritance means that one class inheritsthe characteristics of another class.This is also called a “is a” relationship:A car is a vehicleA teacher is a personA dog is an animal
  • 25Basic Terminology:PolymorphismPolymorphism means “having manyforms”. It allows different objects torespond to the same message in differentways, the response specific to the type ofthe object.E.g. the message displayDetails() of thePerson class should give differentresults when send to a Student object(e.g. the enrolment number).
  • 26Basic Terminology:AggregationAggregation describes a “has a”relationship. One object is a part ofanother object.We distinguish between compositeaggregation (the composite “owns” thepart) and shared aggregation (the part isshared by more then one composite).A car has wheels.
  • 27Basic Terminology:Behaviour and MessagesThe most important aspect of an object isits behaviour (the things it can do). Abehaviour is initiated by sending amessage to the object (usually by callinga method).
  • 28The two steps of ObjectOriented ProgrammingMaking Classes: Creating, extending orreusing abstract data types.Making Objects interact: Creating objectsfrom abstract data types and defining theirrelationships.
  • 29Historical NotesC++ owes most to C.Other ancestors are Simula67and Algol68.First versions of C++ in 1980 under thename “C with classes”. Since 1983 thename C++ is used.1990: ANSI/ISO 9899 defines a standardfor C1998: ISO/IEC 14882 specifies thestandard for C++C++ 1987
  • 30C++ and CC is a subset of C++.Advantages: Existing C libraries can beused, efficient code can be generated.But: C++ has the same caveats andproblems as C (e.g. pointer arithmetic,…).C++ can be used both as a low level andas a high level language.We focus on thehigh level aspects.
  • 31C++ and JavaJava is a full object oriented language, allcode has to go into classes.C++ - in contrast - is a hybrid language,capable both of functional and objectoriented programming.So, C++ is more powerful but alsomore difficult to handle than Java.
  • 32Module OutlineIntroductionThe non objectoriented basicsClassesDesign ApproachesTestingInheritanceAggregationPolymorphismMultifile Development
  • 33Assessment Details50% in course and 50% exam.For more details for the in courseassignment see separate handout.
  • 34BooksTeach Yourself C++ in 10 minutes,J. Liberty, SAMS 1999.C++ - How to program, Deitel & Deitel,Prentice Hall, 2001.Object Oriented Programming with C++,David Parson, Letts Educational, London1997.
  • 35WebsitesA C++ online tutorial:http://www.cplusplus.com/doc/tutorial/The C++ FAQ:http://www.parashift.com/c++-faq-liteThe homepage of Bjarne Stroustrup, theinventor of C++:http://www.research.att.com/~bsAnd many, many more!