Object oriented programming is the most preferred programming technique now a day only due to the flexibility of re usability. Re usability is actually an attribute that makes the object oriented programming more flexible and attractive.
As this programming is based on objects. Object is actually a collection of data and functions that are used to operate on that data. These objects are defined as independent entities because the data inside each object represents the attributes of object and functions are used to change these attributes as required by a program.
These objects act just like spare parts of any program. Thus, they are not limited to any specific program; rather they can be used in more than one application as required.
These objects are defined as an independent entity in a program, and afterward they can be used in any other program that needs the same functionality. This reuse of objects helps in reducing the development time of programs.
This reuse also plays a basic role in inheritance that is a characteristic of object oriented programming.In inheritance, new objects are defined that inherit the existing objects and provide extended functionality as required. It means that if we require some new object that also needs some functionality of existing one's then it is easy to inherit the existing one instead of writing all the required code once again.
Reusable software reduce design,coding,and testing cost by amortizing effort over several applications.reducing the amount of code also simplifies understanding,which increase the likelihood that the code is correct.there are 2 kinds of reuse:sharing of newly written code within an application and reuse of previously written code on new application.
Reusability can be achieved through
Define static class members with example?
A principal goal of object-oriented programming is to make the code you write as reusable as possible--to have it serve many different situations and applications--so that you can avoid reimplementing, even if in only slightly different form, something that's already been done.
Reusability is influenced by a variety of different factors, including:
How reliable and bug-free the code is
How clear the documentation is
How simple and straightforward the programming interface is
How efficiently the code performs its tasks
How full the feature set is
Clearly, these factors don't apply just to the object model. They can be used to judge the reusability of any code--standard C functions as well as class definitions. Efficient and well documented functions, for example, would be more reusable than undocumented and unreliable ones.
Nevertheless, a general comparison would show that class definitions lend themselves to reusable code in ways that functions do not. There are various things you can do to make functions more reusable--passing data as arguments rather than assuming specifically-named global variables, for example. Even so, it turns out that only a small subset of functions can be generalized beyond the applications they were originally designed for. Their reusability is inherently limited in at least three ways:
Function names are global variables; each function must have a unique name (except for those declared static). This makes it difficult to rely heavily on library code when building a complex system. The programming interface would be hard to learn and so extensive that it couldn't easily capture significant generalizations.
Classes, on the other hand, can share programming interfaces. When the same naming conventions are used over and over again, a great deal of functionality can be packaged with a relatively small and easy-to-understand interface.
Functions are selected from a library one at a time. It's up to programmers to pick and choose the individual functions they need.
In contrast, objects come as packages of functionality, not as individual methods and instance variables. They provide integrated services, so users of an object-oriented library won't get bogged down piecing together their own solutions to a problem.
Functions are typically tied to particular kinds of data structures devised for a specific program. The interaction between data and function is an unavoidable part of the interface. A function is useful only to those who agree to use the same kind of data structures it accepts as arguments.
Because it hides its data, an object doesn't have this problem. This is one of the principal reasons why classes can be reused more easily than functions.
An object's data is protected and won't be touched by any other part of the program. Methods can therefore trust its integrity. They can be sure that external access hasn't put it in an illogical or untenable state. This makes an object data structure more reliable than one passed to a function, so methods can depend on it more. Reusable methods are consequently easier to write.
Moreover, because an object's data is hidden, a class can be reimplemented to use a different data structure without affecting its interface. All programs that use the class can pick up the new version without changing any source code; no reprogramming is required.