Section 14b

OOP as Tool Making


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Power Tools, by OOP

With a couple of exceptions here and there, to this point you have been conducting procedural programming. As it turns out, OOP really isn't much of a departure from procedural programming except that some of the running program happens inside objects instead of directly inside the current code. That said, there is a significant difference in the way OOP is conducted, and then used.

As mentioned in the previous section, objects are coding quantities that usually hold some data and manipulate it in various ways. There could be a student class that stores information about students and has the tools to manipulate any and all of the data. There could be a car sales class that stores all the cars to be sold and provides tools for entering, editing, and/or retrieving data related to a specified car. The examples go on and on.

However, the code you write in Object Oriented form are just data managing classes. They don't actually solve problems or create solutions like a program naturally would. They are just tools - powerful, but just tools. Consider the situation that you are building a house. You will need a hammer somewhere along the way and someone made a hammer class out of which hammers could be instantiated (created). You will need a saw. Same story. Someone built a saw design for instantiating saws and it was yours by stopping by your hardware store and dropping some cash. However, in no case does creating a hammer, a saw, a screwdriver, a ladder, or any other construction-area tools actually build your house.

In a nutshell, creating classes -- Object Oriented Programming -- does not solve problems or create solutions. When you are creating classes, you are developing tools for other programmers who will use your classes (as objects) to solve problems or create solutions. You are a toolmaker.

For this reason, the classes you develop will not have main functions in them, and they will be separate files from the main file for the same reason that a bakery is its own part of the grocery store. Once a bakery class is created, any grocery store maker should be able to use the bakery class to instantiate bakeries in each of several stores. It is the store manager or store chain executives that use the bakery class to create their own unique bakeries. They wouldn't want to use a bakery class if it was already associated with another store. Thus, when you create objects from classes, you just create the module that will fit in other people's programs, you won't give them a program they don't need.

This is all that needs to be said about OOP as tool building. As you continue in your programming journey, this will become very clear, and it will become one of the many supporting components you will lean on to develop cool programs.