|
Answer» The main advantages of OOP are: - It is easy to model a real system as real objects are represented by programming objects in OOP.
- With the help of inheritance, we can reuse the existing class to derive a new class such that the repetition of code is eliminated and the use of the existing class is extended. This saves time and the cost of a program.
- In OOP, data can be made private to a class such that only member functions of the class can access the data. This principle of data hiding helps the programmer to build a secure program.
- With the help of polymorphism, the same function or same operator can be used for different purposes. This helps to manage software complexity easily.
- Large problems can be reduced to smaller and more manageable problems. It is easy to partition the work in a project based on objects.
- It is possible to have multiple instances of an object to co-exist without any interference i.e. each object has its own separate member data and function.
The few disadvantages of OOP are: 1. Size: Object-Oriented programs are much larger than other programs. In the early days of computing, space on hard drives, floppy drives and in memory was at a premium. Today we do not have these restrictions. 2. Effort: Object-Oriented programs require a lot of work to create. Specifically, a great deal of planning goes into an object-oriented program well before a single piece of code is ever written. Initially, this early effort was felt by many to be a waste of time. In addition, because the programs were larger (see above) coders had to spend more time while writing the program. 3. Speed: Object-Oriented programs are slower than other programs, partially because of their size. Other aspects of Object-Oriented programs also demand more system resources, thus further slowing down the program.
|