James Ray Anderson

James Ray Anderson
James Ray Anderson
0 comments

Quick and Easy OOP - Part I - Overview

8:00 PM
What is OOP?
The term OOP refers to Object Oriented Programming

What is Object Oriented Programming?
It is a way of writing code in smaller, more maintainable pieces, rather than one giant piece of monolithic code.  When programming was first started the programs were coded from end-to-end in a single program.  As programs got more complex and did more tasks - the code became lengthy - some called it bloated.  The problem with the style of "throw it all in one program without any kind of separation" is that it becomes difficult to update, difficult to navigate, and difficult the re-use portions of the code.

Think of it as a junk box.  You know - the one with everything in it.  It seems fine at first until you need to get something specific out of it so you can use it somewhere else.  Dig, dig, dig.

Imagine if books were written this way - you wouldn't like it much.  No index, no titles, no chapters, no page numbers, no bookmarks.  The human brain likes to compartmentalize things.  It likes to know when something starts and when it ends.  This is because your gray matter is a phenomenal recording device and it wants "markers" and wants to organize information in a way that it can access the data.

Goal of OOP
The main goal of OOP is to take things and logically lump them together into an "object".  Think of an object as a box for which you put things into it.  However, instead of a catch-all "junk box" you separate out what each box does and you keep it focused.  Use one box for batteries, one for wires, one for office supplies, etc.  Now when you want to get a battery - you know exactly where to start. 

OOP Terms
There are some terms that relate to how you go about designing your object-oriented-ness.  Don't get overwhelmed by them.  Just understand their primary purpose and usage.

There will be separate posts on each type of OOP term.

Objects and Classes
What is a Class?  A class is a blueprint or template from which objects are created.

What is an Object?  An object is a bundle of code that has methods and properties.  These methods and properties provide behavior (methods) and state (via properties). 

Objects
Some of the benefits of Objects are:
1.  Modularity.  Objects can be designed to perform whole sets of tasks independent of other objects.  When you need to utilize this, you can invoke the object.  If you don't need it - you don't have to use or include it.
2.  Reusability.  Objects can be re-used if designed properly.  Think about Files.  You can have an object that does nothing but file-based operations such as reading, writing, changing dates, etc.
3.  Easier Maintenance.  Objects can be removed, replaced, upgraded without having to replace all of the other objects. 
4.  Obfuscation.  You can hide the details of how the object does what it does and provide simpler and more precise methods and properties. 

0 comments:

 
Toggle Footer
Top