- Forward


An Introduction to Object Oriented Programming


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Object Oriented Programming
Back SMYC Forward
  • Use a responsibility-driven approach
    • Start by thinking about things and the way they are used
    • Describe things in terms of their responsibilities
  • Focus on understanding real-world concepts
    • A car carries people and things between locations
    • A music system organizes and plays songs
  • Think about data and processes together
The OOP Community
Back SMYC Forward
  • A Warning:
    • Some people/textbooks "lump" various concepts together in order to simplify the discussion
    • Some people/textbooks) "lump" concepts together becuase they actually do not understand the differences/distinctions/subtleties
  • What About JMU?
    • The faculty at JMU (generally) agree on what these concepts mean and how they should be used
    • You should feel free to disagree with the JMU "school of thought" if you can argue your case well
    • While you are here, you should follow the JMU "school of thought" (especially on graded assignments)
Key Concepts: Classes and Objects
Back SMYC Forward
  • Class:
    • A definition of a set written in terms of the characteristics of the elements (rather than by listing the elements)
  • Object:
    • A particular element (or instance) of the set
Key Concepts: Encapsulation
Back SMYC Forward
  • The Concept:
    • The process of combining the attributes and behaviors/activities/functionalities of an entity in a program unit
  • The History:
    • In the "early days", this wasn't done at all.
    • Abstract Data Types (ADTs) popularized this idea
Key Concepts: Abstraction
Back SMYC Forward
  • The Concept:
    • Focusing on the important characteristics for the problem/question at hand and ignore other characteristics
  • A Car Class for a Parking Application:
    • car-parking
  • A Car Class for an Ordering Application:
      car-ordering
Key Concepts: Information/Data Hiding
Back SMYC Forward
  • The Concept:
    • Hide the internal details of a component from all other components
  • Consider a Weight Class:
    • If we were to give a Weight class to someone they could use it improperly (e.g., assign negative values to ounces or pounds; assign 16 or greater to ounces)
  • A Related Term:
    • An Application Programmer's Interface (API) is the visible/accessible portion of a class
Key Concepts: Characteristics of Classes
Back SMYC Forward
  • A Reminder:
    • A class is a definition of a set using the characteristics of the elements
  • What About Characteristics of the Set?
    • Example: The jackpot for progressive slot machines
    • They are often called static characteristics
Final Thoughts
Back SMYC Forward
  • Where We Are:
    • We've discussed some of the concepts and principles that define the OOP paradigm
  • What's Left?
    • Inheritance
    • Polymorphism
    • Interfaces
    • Abstract Classes
    • Packaging
There's Always More to Learn
Back -