Swe 5
Swe 5
O
Construction
Concepts
1. A
bstraction: Focuses on exposing only the necessarydetails of an object while
hiding the complex background. Simplifies design by reducing complexity and
allowing designers to focus on higher-level problem-solving.
or example, using a car involves knowing how to drive, not the engine
F
mechanics. In software, abstraction enables developers to build complex systems
using simpler interfaces, creating models representing real-world entities in a
simplified manner.
2. M
odularity: Involves dividing a software system intoindependent modules that
can be developed, tested, and maintained separately. Each module has a specific
responsibility and interacts with others via well-defined interfaces. This enhances
maintainability, scalability, and reusability.
3. S
pecification: Defines what a module or componentshould do without
specifying how it does it. Typically done using interfaces or abstract classes
describing expected behavior. This allows for different implementations as long
as they adhere to the specification, acting as a contract between system parts.
This separation of interface and implementation facilitates changes and
maintenance without affecting other parts of the system.
4. E
ncapsulation: Bundles data (attributes) and methods(functions) into a single
unit or class. It restricts direct access to some components, essential for
protecting the object's integrity.
For example, making class variables private and providing public methods
for access and modification. Encapsulation helps maintain data control, ensuring
it's not modified unexpectedly. It enhances security and prevents external
interference.
5. Information Hiding: Hides internal details of a moduleor object from the outside
world, exposing only necessary aspects through a controlled interface. This
reduces system complexity and increases robustness by preventing external
components from relying on internal details.
or example, exposing a method to get a user's age but hiding how it's
F
calculated or stored. Information hiding reduces the impact of implementation
changes on other system parts.
Metrics evaluate design quality, such as coupling, cohesion, complexity, and readability.
● Coupling: Measures interdependence between modules;lower coupling
indicates a modular, flexible system.
● Cohesion: Measures relatedness of responsibilitieswithin a module; higher
cohesion indicates a well-defined module purpose.
● Complexity: Assesses difficulty in understanding andmaintaining code.
● Readability: Evaluates ease of reading and understandingcode by developers.
6. Concepts of Design Patterns:
Refactoring:
● D
RY (Don't Repeat Yourself): Avoid code duplicationby abstracting common
functionality, reducing redundancy, and making code easier to maintain.
● K
ISS (Keep It Simple, Stupid): Strive for simplicityin design, avoiding unnecessary
complexity, encouraging straightforward solutions, reducing bugs, and improving
maintainability.
Object-Oriented Metrics:
Metrics measure various aspects of an object-oriented system:
1. Coupling: Degree of interdependence between modules;lower coupling is desirable for
independence.
2. Cohesion: Degree to which elements within a modulebelong together; higher cohesion
indicates a well-defined purpose.
3. Depth of Inheritance Tree (DIT): Measures inheritancelevels; deeper trees indicate
more complexity and reuse potential.
4. N umber of Children (NOC): Counts immediate subclasses; a higher number indicates a
well-used base class but may suggest over-generalization.
5. Weighted Methods per Class (WMC): Measures class complexitybased on the
number and complexity of its methods; higher WMC suggests more functionality but
may indicate a class doing too much.