Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Object-Oriented Concepts

3,902 views

Published on

Published in: Technology

Object-Oriented Concepts

  1. 1. Object-Oriented Concepts By: Abdalla Mahmoud Java Instructor – Database Egypt [email_address] http://www.abdallamahmoud.com
  2. 2. Before we GO… <ul><li>The acts of the mind, wherein it exerts its power over simple ideas, are chiefly these three: </li></ul><ul><ul><li>Combining several simple ideas into one compound one, and thus all complex ideas are made. </li></ul></ul><ul><ul><li>The second is bringing two ideas, whether simple or complex, together, and setting them by one another so as to take a view of them at once, without uniting them into one, by which it gets all its ideas of relations. </li></ul></ul><ul><ul><li>The third is separating them from all other ideas that accompany them in their real existence: this is called abstraction, and thus all its general ideas are made. </li></ul></ul><ul><ul><ul><li>John Locke,  An Essay Concerning Human Understanding  (1690) </li></ul></ul></ul>
  3. 3. Contents <ul><li>Programming Paradigms. </li></ul><ul><li>Object-Oriented Paradigm. </li></ul><ul><li>Object-Oriented Concepts. </li></ul><ul><li>Exercises. </li></ul>
  4. 4. Programming Languages <ul><li>A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer. </li></ul><ul><li>Each programming language have some form of written specification of their syntax and semantics , since computers require precisely defined instructions. </li></ul><ul><li>They are not the same. </li></ul><ul><li>There’s nothing called “the best language”. </li></ul><ul><li>Languages most often characterized by their paradigm . </li></ul>
  5. 5. Programming Paradigm <ul><li>A programming paradigm is a fundamental style of computer programming. </li></ul><ul><li>Paradigms differ in: </li></ul><ul><ul><li>the concepts and abstractions used to represent the elements of a program </li></ul></ul><ul><ul><li>the steps that compose a computation. </li></ul></ul><ul><li>Examples </li></ul><ul><li>Event-Driven </li></ul><ul><li>Object-Oriented </li></ul><ul><li>Aspect-Oriented </li></ul><ul><li>Declarative </li></ul><ul><li>Imperative </li></ul><ul><li>Functional </li></ul><ul><li>Logic </li></ul>
  6. 6. Concepts or Practice?
  7. 7. Consequences!
  8. 8. Object-Oriented Paradigm <ul><li>Object-oriented programming (OOP) is a programming paradigm that uses &quot;Objects&quot; and their interactions to design applications and computer programs. </li></ul><ul><li>Everything around us are objects interacting with each others. </li></ul><ul><li>Each object has a set of features, including adjectives and verbs. </li></ul><ul><li>Object-oriented paradigms is sometimes thought to be a simulation of the real-world around us, which make it the paradigm of choice for most application domains: GUIs, games, business, etc. </li></ul>
  9. 9. Object-Oriented Paradigm 2
  10. 10. Objects
  11. 11. Classes Car Human
  12. 12. Classes 2 Man Suzuki Woman BMW
  13. 13. Abstraction & Inheritance Man Suzuki Woman BMW Car Human
  14. 14. Object and Their Interaction Program
  15. 15. Object and Their Interaction Program Tom, hold your sweep!
  16. 16. Object and Their Interaction Program Tom, hold your sweep! Tom, beat jerry!
  17. 17. Object and Their Interaction Program Tom.holdYourSweep() Tom.BeatJerry() IN PROGRAMMING
  18. 18. Object and Their Interaction Program Tom.holdYourSweep() Tom.BeatJerry() IN PROGRAMMING message
  19. 19. Object and Their Interaction Program Tom.holdYourSweep() Tom.BeatJerry() IN PROGRAMMING message message
  20. 20. OOP Concepts <ul><li>Class. </li></ul><ul><li>Object. </li></ul><ul><li>Instance. </li></ul><ul><li>State. </li></ul><ul><li>Method. </li></ul><ul><li>Encapsulation. </li></ul><ul><li>Inheritance. </li></ul><ul><li>Polymorphism. </li></ul>
  21. 21. Class <ul><li>A class is an abstract definition of an object. </li></ul><ul><li>Defines how would the object look like when created. </li></ul><ul><li>The object type . </li></ul><ul><li>Think of classes like the patents of actual inventions. </li></ul>
  22. 22. Object <ul><li>An object is the actual entity instance lives in memory and capable of doing real operations. </li></ul><ul><li>Created (instantiated) according to the abstract definition of a class. </li></ul><ul><li>Think of objects like some invention created according to some patent. </li></ul>
  23. 23. Object vs. Class <ul><li>Object </li></ul><ul><li>Class </li></ul>
  24. 24. State <ul><li>The value of an attribute (variable) of the object. </li></ul><ul><li>Describes some object’s characteristics. </li></ul><ul><li>Ex: Car.color = red </li></ul><ul><li>Adjectives . </li></ul>
  25. 25. Method <ul><li>An object’s ability to do some operation. </li></ul><ul><li>Implements some functionality. </li></ul><ul><li>Invoked by the same object or other interacting objects in the system. </li></ul><ul><li>Ex: car.accelerate() </li></ul><ul><li>Verbs . </li></ul>
  26. 26. Message Passing <ul><li>The process by which an object: </li></ul><ul><ul><li>Sends data to another object. </li></ul></ul><ul><ul><li>Asks the other object to invoke a method. </li></ul></ul><ul><li>In other words, objects talk to each others via messages. </li></ul>
  27. 27. Encapsulation <ul><li>Encapsulation is hiding the functional details from the object calling it. </li></ul><ul><li>Can you drive a car? </li></ul><ul><ul><li>Yes, I can! </li></ul></ul><ul><li>So, how does acceleration work? </li></ul><ul><ul><li>Huh? </li></ul></ul><ul><li>Details encapsulated (hidden) from the driver. </li></ul>
  28. 28. Inheritance <ul><li>Inheritance is the process of subclassing some class by inheriting all of its attributes and methods. </li></ul><ul><li>Parent class is called Superclass . </li></ul><ul><li>Child class is called Subclass . </li></ul><ul><li>Subclasses are more specialized version of a class. </li></ul>
  29. 29. Inheritance (2) <ul><li>Superclass </li></ul><ul><li>Subclass </li></ul>
  30. 30. Polymorphism <ul><li>Different objects share the same interface (e.g: same method names). </li></ul><ul><li>Different functionalities /implementations. </li></ul><ul><li>One object may have several interfaces. </li></ul><ul><li>One object can be treated as if it’s an instance from several types (classes). </li></ul>
  31. 31. OOAD <ul><li>Object-oriented analysis and design (OOAD) is a software engineering approach that models a system as a group of interacting objects. </li></ul><ul><li>Identifying what objects would we have in the system, and designing them. </li></ul><ul><li>Abstract Process </li></ul><ul><ul><li>Identify real entities (nouns)/ system entities. </li></ul></ul><ul><ul><li>Design entities attributes and methods. </li></ul></ul><ul><ul><li>Notate your design. </li></ul></ul>
  32. 32. Design Patterns <ul><li>A design pattern is a formal way of documenting a solution to a design problem in a particular field of expertise. </li></ul><ul><li>Best solutions for common problems. </li></ul><ul><li>Design Patterns (&quot;Gang-of-four book&quot;) by Erich Gamma et al, with patterns for object-oriented programming (software engineering). </li></ul>
  33. 33. UML <ul><li>The Unified/Universal Modeling Language (UML) is a standardized visual specification language for object modeling. </li></ul><ul><li>General-purpose modeling language that includes a graphical notation used to create an abstract model of a system, referred to as a UML model. </li></ul><ul><li>Example: Class Diagram </li></ul>
  34. 34. Exercises <ul><li>Develop an object-oriented model for a goal slice of a soccer game. </li></ul><ul><li>Develop an object-oriented model for the home-delivery slice in a fast food restaurant. </li></ul><ul><li>Identify the objects only in a banking system. </li></ul>

×