Developer Forums | About Us | Site Map
Search  
HOME > TUTORIALS > SERVER SIDE CODING > PERL TUTORIALS > THE ROAD TO BETTER PROGRAMMING: CHAPTER 5 MODULES AND OBJECTS


Sponsors





Useful Lists

Web Host
site hosted by netplex

Online Manuals

The road to better programming: Chapter 5 Modules and objects
By Teodor Zlatanov - 2004-03-01 Page:  1 2 3 4 5 6 7 8

Benefits of OOP

The benefits of OOP are too many to list in this article, and as I mentioned before, many books have been written on the subject. A small subset is: ease of code reuse, code quality improvements, consistent interfaces, and adaptability.

Because OOP rests on the foundation of classes and objects, reusing OO code means simply importing the classes when needed. Code reuse is, by far, the single most important reason for using OOP, and the reason why OOP has gained importance and popularity in today's industry.

There are some pitfalls here. For instance, solutions to previous problems may not be ideal for the current situation, and badly documented libraries can take as long to understand and use as it would take to write them anew. The system architect's job is to see and avoid these pitfalls.

Code quality is improved with OOP because encapsulation cuts down on data corruption ("friendly fire"), while inheritance and polymorphism decrease the amount and complexity of new code that has to be written. There is a delicate balance between code quality and programming innovation that is best left to the team to discover, as it depends entirely on the team's makeup and purpose.

OOP inheritance and reuse facilitate consistent interfaces in code, but it's not a foregone conclusion that all OO code will have consistent interfaces. The programmers still have to adhere to a general architecture. For instance, the team should agree on the format and interface for error logging, preferably through a modular interface that allows future expansion and is extremely easy to use. Only then will every programmer commit to using that interface instead of erratic print statements because they will realize that the investment of learning that interface will not be wasted when the next error logging function comes along.

Adaptability is a somewhat nebulous concept in programming. I would define it as the acceptance and anticipation of environment and usage changes. Adaptability is important to well-written software because all software must evolve with the world around it. Well-written software should evolve gracefully. OOP facilitates this with modular design, improved code quality, and consistent interfaces that ensure that a new operating system or a new report format will not require radical changes to the core of the architecture.



View The road to better programming: Chapter 5 Modules and objects Discussion

Page:  1 2 3 4 5 6 7 8 Next Page: How to use OOP in Perl

First published by IBM developerWorks


Copyright 2004-2024 GrindingGears.com. All rights reserved.
Article copyright and all rights retained by the author.