Java_OOP Additional notes.pdf

Java_OOP Additional notes.pdf - Object Oriented Programming...

Info icon This preview shows pages 1–3. Sign up to view the full content.

Object Oriented Programming in Java Introduction to Object Oriented Programming in Java What is Object Oriented Programming (OOP)? A software design method that models the characteristics of real or abstract objects using software classes and objects. Characteristics of objects: o State (what the objects have) o Behavior (what the objects do) o Identity (what makes them unique) Definition: an object is a software bundle of related fields (variables) and methods . In OOP, a program is a collection of objects that act on one another (vs. procedures). For example, a car is an object. Its state includes current: Speed RPM Gear Direction Fuel level Engine temperature Its behaviors include: Change Gear Go faster/slower Go in reverse Stop Shut-off Its identity is: VIN License Plate Why OOP? Modularity — Separating entities into separate logical units makes them easier to code, understand, analyze, test, and maintain. Data hiding ( encapsulation ) — The implementation of an object’s private data and actions can change without affecting other objects that depend on it.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Code reuse through: o Composition — Objects can contain other objects o Inheritance — Objects can inherit state and behavior of other objects Easier design due to natural modeling Even though OOP takes some getting used to, its main benefit is to make it easier to solve real-world problems by modeling natural objects in software objects. The OO thought process is more intuitive than procedural, especially for tackling complex problems. Although a lot of great software is implemented in procedural languages like C, OO languages typically scale better for taking on medium to large software projects. Class vs. Object A class is a template or blueprint for how to build an object. o A class is a prototype that defines state placeholders and behavior common to all objects of its kind. o Each object is a member of a single class — there is no multiple inheritance in Java. An object is an instance of a particular class. o There are typically many object instances for any one given class (or type). o Each object of a given class has the same built-in behavior but possibly a different state (data). o Objects are instantiated (created). For example, each car starts of with a design that defines its features and properties. It is the design that is used to build a car of a particular type or class. When the physical cars roll off the assembly line, those cars are instances (concrete objects) of that class. Many people can have a 2007 BMW 335i, but there is typically only one design for that particular class of cars. As we will see later, classification of objects is a powerful idea, especially when it comes to inheritance — or classification hierarchy.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '16

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern