hirophysics.com steven jeffrey k irkup. hirophysics.com what is object oriented programming (oop)?...

18
Hirophysics.com Steven Jeffrey Kirkup

Upload: martha-kelley

Post on 05-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Steven Jeffrey Kirkup

Page 2: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

What is Object Oriented Programming (OOP)?

Essentially, OOP is a protocol that can be followed to build or compose a program other than the traditional way of writing them, called “procedural programming.”

Where procedural is a straightforward method of programming—involving commands, etc. written out whenever they’re needed,— OOP involves grouping pieces of the program into “objects,” and is considered a more advantageous and advanced method.

Page 3: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

SO WHAT?

Page 4: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

OOP is a way of programming that makes it easier for multiple people to work on creating a program without running the risk of damaging each other’s work.

For long, complex programs, the amount of writing involved in the program ends up being smaller, so...Less More

Page 5: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Objects?

Objects are the building blocks of OOP.

At the beginning of the program, you state what they are and define them.

An object can be anything you could need in a program: a variable or set of variables, a value or set of values, a calculation, an algorithm, an output/input method, etc.

Page 6: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Classes

Classes are what objects are grouped in. Multiple classes are helpful for long, complicated programs that may need certain calculations or procedures separate from the other data or data-collecting classes.

Within the classes, calculations and the like are defined as “methods”, and input/output commands and long algorithms are defined as “constructors.”

Page 7: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

OBJECTS (entities)

CONSTRUCTO

R(properties)

METHODS (toolkit)

ACTUAL PROGRAM

Page 8: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Constructor

Constructors are sections of the program that essentially “construct” objects. It’s sort of like the backbone of the program and its structure.

If a variable needs some initial value, that value would be introduced in a constructor.

If an object needs to follow certain parameters, those are attributed to it in a constructor.

Anytime the program calls upon an object, it must “look at” the constructor to see how to set the object up. This is very important for resetting values and not messing up the program.

Page 9: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Instances

When a program needs to use an object, it creates an instance of that object. Basically, and instance is a clone entity of the object that can be used by the program.

Once a clone has been made, the program must look at the constructor to set up the clone’s parameters.

Without the constructor, multiple instances of the same object couldn’t be unique and hold their own unique data.

Page 10: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Methods/Calculations

This section of the program is where calculations, algorithms, etc. are set up. They are considered objects, and their specific functions are depicted in this section.

Example: Input/output commands can be put in this section

Page 11: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Building onto a program

A major advantage of OOP is its smart, safe way of advancing/adding onto a program. This can be done by simply adding objects or classes of objects to the current list and adding the commands to use them in the “main” part of the program. For example, you can go from this....

Page 12: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

...to this.

Page 13: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Converting from Procedural to OOP Turn data records into objects Break up behavior Move behavior into the objects

Page 14: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Volume of a sphere finding

program converted to OOP

Page 15: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Problems I experienced

The overall understanding of where to group objects wasn’t very difficult

My biggest difficulty was getting the program language to work properly, specifically converting the “creating a data file” commands and keeping track of what to put in parentheses at the beginning of each section.

Page 16: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Essentially...

OOP is a way of programming that resembles putting together a puzzle.

The objects are your puzzle pieces. First you state what all your pieces

are and describe what they do. At the end of the program, you

finally fit them together.

Page 17: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Tips for getting into OOP If you’re interested in programming in OOP

or you have already tried and find it too complicated or tedious....

Don’t give up! A good strategy for advancing in OOP is to look at many example programs and try making a bunch of your own.

A good exercise is to convert a procedural program you have into an OOP.

With practice comes a better understanding.

Page 18: Hirophysics.com Steven Jeffrey K irkup. Hirophysics.com What is Object Oriented Programming (OOP)? Essentially, OOP is a protocol that can be followed

Hirophysics.com

Final Thoughts

I find the conceptual difference between procedural and OOP to be...

Procedural follows the logical order a program would follow

OOP breaks that order apart, but for advanced programming, the ultimate goal of your program is easier to attain. (It’s easier to keep track of “the bigger picture”)

As long as you understand the programming language, switching to OOP isn’t too difficult