Classes and OOP Concepts

Modularity:

  • Classes encapsulate methods which encapsulate procedures
  • These ‘modules’ can be used in different programs without having to understand how they’ve been implemented

Encapsulation:

  • Def:  names (of variables and methods) are stored in locations that then have to be accessed, called namespaces or environments.

Substitution Principle:

  • When we create a subclass, we want it to inherit a lot of behaviors of the parent class. For example, when we have classes ‘Student’ and ‘Parent’ (the first being a child class of the latter), we would expect students to behave as people for any piece of code.  In other words, we want the subclass to be able to be used in any context. This saves saves us from having to rewrite code for particular behaviors of different subclasses.

Generator:

Inheritance:

  • Def: The ability to define a new class as a modified version of an existing class
  • The new class (i.e. subclass or ‘child’ class) inherits the methods of the  existing (i.e. ‘parent’ or super class); however, if the subclass uses the same name for a function which has also been used in the superclass, it will only use the subclass definition of that function.

Abstract data type:

  • Def: A set of objects and the operations on those objects.
  • ADT are purely theoretical entities that are defined indirectly, only by the operations that may be performed on it and by mathematical constraints on the effects/cost of those operations
  • Used to simplify the description of abstract algorithms, to classify and evaluate data structures
  • May be implemented in many ways and in many programming languages
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s