Object Oriented Programming Flashcards
Object-Oriented Programming (OOP):
An approach to designing and building software applications that have flexibility, maintainability, and are designed around the interactions of ‘virtual objects’ rather than data.
Class:
A class is a portion of code that contains everything there is to be known about how to represent an object in the computer, what interactions it supports and how it can be manipulated. Good examples of classes are Customer, Contact, Purchase Order, Car, File-Manager and so on.
Object:
An instance of a class that is created at run-time. You can have a person class, then create or instantiate several instances. Bob, Mary, Jane etc. Each instance is unique for the lifetime of the application.
Property:
Code used to support the ‘getting’ and ‘setting’ of some data held within a class. A property or accessor method is used to control how that data can be changed. Properties might include Name, Age, Date of Birth, Account Number, Student ID etc.
Method:
Code used to define the functionality or actions within a class. Methods are the behavior of the class. Method such as ConfirmBooking and CalculateOverTime are good examples of multi-step processes being modeled within a class.
Method signature:
The syntax of a method that describes whether parameters are required or not. A parameter is the data passed into a method to be acted upon. A method may take in a number value and multiply by it by a known tax rate, then return the new value.
Overloading:
Methods can have the same name but a different number of incoming parameters. For example, consider these two method signatures:
· Public ConfirmBooking(int bookingId)
· Public ConfirmBooking(int bookingid, bool paymentmade)
The ConfirmBooking method in this example is said to have ‘two overloads’.
Contract:
A contract is the set of valid interactions a class will support through its properties and methods. This is also known as the ‘class interface’.
Abstraction:
The process of defining classes by only modeling those factors from the real world that are absolutely needed within the computer. For example, a person in the real world has a First Name, Last Name, Email Address and Favorite food. If your application is an email tracker, then you do not need to represent Favorite Food.
Encapsulation:
A way to restrict access to or ‘hide’ data and implementation details within a class. Preventing unauthorized use and concealing complexity. Data and methods can be visible to all (using public keyword) or not visible outside of the class itself (using private keyword).
Inheritance:
Defines the relationship between classes. Classes can sub-class another to extend their behaviors and properties. Known as child or derived classes. They by default inherit all of the members of the parent or base class. For example, a base class might be Vehicle, with child classes such as Car, MotorBike, Truck etc.
Polymorphism:
A term used to describe how one object can be treated like another. For example, consider a base class called Shape that has a draw method. Now add a Square class, A Circle Class and a CustomShape class. A method that accepts a Shape object as an argument can accept any of these shapes.
Inheritance-Based Polymorphism:
A variation on Polymorphism where the method is defined in a base class and behaves differently for each child class.
Interface-Based Polymorphism:
A variation on Polymorphism where the method is defined as an additional interface and behaves differently in each class that implements the interface.
Class
Definition, blueprint, template used to describe what a particular object would like and what behaviors it possess.
Formal way to classify a group of objects that share common features.
Like a cookie cutter, a description of what a single cookie or instance would look like.
Classes are simply used to logically organize and arrange your code for better maintainability.
A way to describe how items in the real world can be modeled in the computer.
Can describe attribute, action, behaviors and etc.