OOPS: Decomposition and Abstraction

When we write a a program and if the the code is expected to be less than few hundred of lines then we can afford to write a monolithic program but if the number of lines increase it becomes difficult  to maintain that program or adding new features to that program.  so how to handle this ?

In order to write a program for a problem , the problem should be broken into multiple smaller problems and then each smaller problem should be solved  and make sure that solving all such smaller problem solves the actual , bigger problem. the process of breaking a problem into multiple smaller problem efficiently involves Decomposition and Abstraction.

Definitions
Decomposition- How to decompose large programming problems into small ones is called decomposition

Abstraction - Abstraction is a way to do decomposition productively by changing the
level of detail to be considered. In each iteration the irrelevant information can be removed. The process of abstraction can be seen as an application of a many-to-one mapping.

Abstraction Mechanism -
1.) Abstraction by Parameterization :Abstraction by parameterization abstracts away from the identity of the data by replacing them with parameters.

2.) Abstraction by Specification:  Abstraction by specification abstracts away from the implementation details to the behavior users can depend on.

Kind of Abstraction :

1.) Procedural Abstraction:
Abstraction by parameterization is an important means of achieving generality in programs. A sort routine that works on any array of integers is much more generally useful than one that works only on a particular array of integers. By further abstraction, we can achieve even more generality. For example, we might define a sort abstraction that works on arrays of reals as well as arrays of integers, or even one that works on arraylike structures in general.

2.) Data Abstraction :  The behavior—“what” is done—is relevant, while the method of realizing that behavior—“how” it is done—is irrelevant

3.) Iteration Abstraction :
Iteration abstraction allows us to iterate over items in a collection without revealing details of how the items are obtained.

Comments

Popular posts from this blog

Palindrome program in Java using BufferedReader