I am a strong believer in thinking object oriented. Given a real life problem, the solution becomes clearer when it is broken down using the OOAD principles Abstraction, Polymorphism, Inheritence and Encapsulation (A PIE).
Although several books and materials on the internet explain these concepts in a more technical manner, I think that things are clearer if we looked at it from a layman's perspective using an example of a small business.
Abstracion: To be more specific lets look at the payroll processing system in a small business. Any payroll processing system would have some common operations such as check balance and process payroll. These general operations could be classified as abstraction.
Polymorphism: In the payroll processing system the operation process payroll could be handled in different ways. The first one being process payroll using direct deposit and the second being process payroll with check. This could be classified as polymorphism.
Inheritence: In the payroll processing system there could be two different branches one in Arizona and the other in New York. Both the branches would process payroll by inheriting the common behavior from the parent but implement the payroll processing in different ways (as the state taxes etc. could be different). This could be classified as inheritence.
Encapsulation: In the payroll processing system when the payrols is being processed for an employee the information such as state taxes would be encapsulated. Such a data hiding technique could be classified as encapsulation.
As we can see the complex payroll processing system in not so complex anymore when looked at using the "A PIE" principle of OOAD.
No comments:
Post a Comment