1 / 24

Object Oriented Programming

Object Oriented Programming. M Taimoor Khan taimoorkhan@ciit-attock.edu.pk. Course Description.

washi
Télécharger la présentation

Object Oriented Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Oriented Programming M Taimoor Khan taimoorkhan@ciit-attock.edu.pk

  2. Course Description It teaches the concepts of object-oriented programming. Topics include data abstraction, encapsulation, hierarchy via composition and derivation (inheritance), and polymorphism. C++ used for lab work. A computer science major that makes the basis of programming applications.

  3. Course Relevance This course is of key importance to advance to programming as a profession. It gives all the important concepts and practical experience of the programming language. It can be extended to learning other languages like Java, PHP C# etc by using the same knowledge in different syntax

  4. Course Outline • Classes • Polymorphism • Encapsulation • Operators overloading • Method overriding • Templates • Inheritance • Types of classes

  5. Marks Distribution

  6. Course Flow • Key concepts • Quick Revision • Class practice • Notes • Resource www.cstags.com • Labs • Lab Instructor Mr. Waqas Ahmed

  7. Course Textbook(s) • Object Oriented Programming in C++ 4th Edition by Robert Lafore • How to Program in C++ 7th Edition by Deitel n Deitel

  8. Object Oriented Programming • An approach to application development • Appropriate for large scale applications with teams of developers • OO Programming paradigm: collection of objects

  9. OOAD • The proverb “owning a hammer doesn’t make one an architect” is especially true with respect to object technology • Knowing an object language is necessary but insufficient to create object systems • Its about analyzing system requirements in terms of objects and allocating responsibilities to class objects • How would these objects collaborate with each other • What classes should do what

  10. OOA • It emphasizes on finding requirements and problems rather than solutions • Object oriented analysis is a process of analyzing requirements in an object oriented paradigm • It approves some of the requirements while discards others • Based on this OOA the OOD is built

  11. OOD • It emphasizes on the conceptual solution in software or hardware that fulfills the requirements • It does not give any implementation details • Design ideas normally exclude low level details that are obvious to the intended customers • Ultimately designs can be implemented in code to give its true and complete realization

  12. How to solve OOP problem • Identify nouns, they are your potential objects (Discard irrelevant ones) • Identify adjectives, they are your potential attributes (Discard irrelevant ones) • Identify verbs, they are your potential behaviors (Discard irrelevant ones) • What is irrelevant! • Classes (Object types) • Map classes (Communication channels)

  13. Case study • A system is required that will allow users to login through their valid name and password. Users will have to register first to use the system. Users will be required to make their profile with their personal data as first name, last name, date of birth and city. Users should be able to add other users as friends. Users can send messages to their friends

  14. The evolution of OOP • Global Variables • Life time spans program execution • Local Variables • Life time limited to execution of a specific routine • Instance variables • Posses data of an object • Static Variables • Visible in single scope • Modules • Allow several subroutines to share a set of static variables • Module Types • Multiple instances of an abstraction • Classes • Families of related abstraction

  15. Why OOP • Reduces conceptual load by reducing amount of detail • Provides fault containment • Can’t use components e.g (class ) in inappropriate ways • Provides independence between components • Design development can be done by more than one person

  16. Keys to OOP • An instance of a class is called object • Languages that are based on classes are called object oriented languages • For example C++ • Java • Microsoft .NET framework languages C#, VC++

  17. Benefits of OOP • Promote code reuse • Reduces code maintenance • Simplifies extending applications

  18. Methods • Functions still do the work in OO • But now they • Just know what they need to know • Generally contain less code

  19. Keys to OO Programming • Encapsulation (Data Hiding) • Enable programmer to group data and subroutines (methods) together, hiding irrelevant details from users • Inheritance • Enables a new abstraction ie a derived class to be defined as an extension of an existing abstraction, retaining key characteristics • Dynamic data binding • Enabling use of new abstraction i.e derived classes to exhibit new behavior in context of old abstraction

  20. Initialization and Finalization of Objects • Choosing a constructor • How are constructors supported in the language • Execution order of initialization • E.g with derived classes • Garbage collection • Destructors

  21. Classes and objects • Objects are actors in your application • Refers to individual pieces of data • A class define the data and behavior of object • Objects in your application are instances of a class

  22. Objects • An object is a thing • More precisely an object is the representation of a thing • Has characteristics • We call these attributes or properties • Properties are just variables rebranded • Those things which the objecthas • Has behavior • We call these methods • Methods are just functions rebranded • Those things which the object does

  23. Inheritance • Defines subclasses • Creates ‘is a’ relationship • E.g Nokia is a cell phone • Resuse common functionality • Specialization • Extend or override common functionality for specific needs

  24. Encapsulation • Treat each object as a black box • Well defined interface of data and methods • Must use this interface in the application • All data is private • Methods can be public, private or protected

More Related