Download presentation
Presentation is loading. Please wait.
Published byMartha Kelley Modified over 9 years ago
1
Hirophysics.com Steven Jeffrey K irkup
2
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.
3
Hirophysics.com SO WHAT?
4
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
5
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.
6
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.”
7
Hirophysics.com OBJECTS (entities) CONSTRUCTOR (properties) METHODS (toolkit) ACTUAL PROGRAM
8
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.
9
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.
10
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
11
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....
12
Hirophysics.com...to this.
13
Hirophysics.com Converting from Procedural to OOP Turn data records into objects Break up behavior Move behavior into the objects
14
Hirophysics.com Volume of a sphere finding program converted to OOP
15
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.
16
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.
17
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.
18
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.