Objected Oriented Programming Paper IT/218 May 13, 2012 Farhad Malek-Asghar When it comes to writing a program there are so many ways a person can approach the problem. Think of it this way, a chef following a recipe can look at the ingredients and decided to add more of one thing and less of another or the chef can follow the recipe exactly. As long as the chef uses common logic on blending foods the dish will come out correctly. The same is true when building a program. A programmer has many tools to choose from to make it more or less complicated. The programmer also has several tools to choose from to ensure the program runs.
So let me go over some of these essential tools right now and how they relate to one another. The first tool a programmer has to work with is called Structures. According to Cprogramming. com (1997), “Structures are a way of storing many different values in variables of potentially different types under the same name. This makes it a more modular program, which is easier to modify because its design makes things more compact”. So in retrospect they are inherently more useful when a lot of data needs to be grouped together like large databases. Next we have Classes. According to
Cprogramming. com (1997), “Classes are collections of data related to a single object type. Classes not only include information regarding the real world object, but also functions to access the data, and classes possess the ability to inherit from other classes”. Try to think of Classes as a television. Public parts of the classes can relate to the parts ofa television that people tend to use. An example of this would be the volume or channel changing buttons. Each function is essential in the overall operation of the television and so is true about Classes. Then you have Unions.
According to Microsoft (2012), “A Union is a structure like type that is provided in C to members, and read from them, in the same manner. However, members of a structure occupy adjacent areas of memory, but members of a union share the same data space”. Unions are a great way of saving memory, especially when running programs across multiple servers but they should be used cautiously due to that that assigning values to one Union can essentially affect the others. Next in your tool box is something called Inheritance which is an important feature of any class especially when it comes to object oriented programming.
Inheritance allows you to create a hierarchy of classes, with various classes of more specific natures inheriting the general aspects of more generalized classes (Cprogramming. com, 1997). Think of a Bear Class and how it relates toa Public Animal. From there you can Just add on to or take away from depending on which way you want to go. Then there is Objects and how they relate to the rest of the tools in the object oriented programming bag. Stroustrup (1992), ” In C++, an object is a region of storage with associated semantics. Objects are usually referred to by references, which are aliases for an object”.
If you think how Classes and Objects are related, they basically define the behavior of objects within a program. Finally you have Polymorphism which is a very powerful feature in object oriented programming. According to exforsys (2000), ” Polymorphism is the ability to use an operator or method in different ways. Polymorphism gives different meanings or functions to the operators or methods”. In short it refers to the operations, codes, or objects that are essentially different. When it comes to object oriented programming these are some of the important ools a programmer has in their arsenal.
Like I stated before at the beginning of my paper programming or writing a code is like a chef creating a dish from a recipe. Each ingredient or in this case tools add different flavors to the program or code. Essentially tying everything together allowing the program to run. It does not matter whether or not you are an experience chef or programmer to make it work. All you need to do is be organized in your thoughts and actions, utilizing the tools available to you. References Cprogramming. com. (1997). Structures in C++. Retrieved from http://