In: Computer Science
What is the difference among the principles of modularization, abstraction, encapsulation, and separation of interface and implementation. Please provide with related examples.
#Course: Software Engineering
principles of modularization
The modularity principle is the most basic principle in engineering. It states: Systems should be built from cohesive, loosely coupled components (modules).
A cohesive component has a well defined function or purpose.
Components are loosely coupled if their interdependencies are minimized.
Cohesive, loosely coupled components are easy to understand, reuse, and replace
principles of abstraction
The Abstraction Principle is one of the most fundamental principles in engineering. It states:
The interface of a component should be independent of its implementation.
A component could be a hardware or software component.
The interface of a component is the user's view of the component, while the implementation is the developer's view. If a component is designed following the Abstraction Principle, then the user doesn't need to understand how a component works in order to use the component and the developer can modify the implementation without notifying the user.
Example
The classical example of the Abstraction Principle is a car. We can regard the interface as the dashboard, pedals, and shifter. The implementation is the engine and transmission. Think about how difficult it would be if drivers needed to understand engines in order to drive and had to relearn to drive each time a mechanic replaced an engine part.
principles of encapsulation
Encapsulation is one of the fundamentals of OOP (object-oriented programming). It refers to the bundling of data with the methods that operate on that data. Encapsulation is used to hide the values or state of a structured data object inside a class, preventing unauthorized parties’ direct access to them. Publicly accessible methods are generally provided in the class (so-called getters and setters) to access the values, and other client classes call these methods to retrieve and modify the values within the object.
Encapsulation is a good idea for several reasons:
principles of separation of interface and implementation
An Interface defines a set of method signatures, while a Class defines the structure and behavior of its instances. A class may match several interfaces, if it implements the methods defined by each interface. Classes are instantiable, while interfaces are not. In contrast, we propose a different separation of interface and implementation, based on the properties supported by the context relation. A base class defines the structure and interface (method signatures) of its instances, and may provide implementations for the interface as well. If an implementation of a method is not provided directly in the base class, the implementation may be separately given in one or more classes that are context-related to the base class. In contrast to the notion of Interface in Java, a base class that defines only interfaces may still be instantiated. To prevent a method resolution error at run-time, we require an implementation of the method to either exist directly in the base class or to exist in some context-related class that is declared to be the default implementation.
Note: Plzzz don' t give dislike.....Plzzz comment if u have any problem i will try to resolve it.......