Podcast
Questions and Answers
Which of the following is NOT a defining characteristic of engineering design according to the CEAB definition?
Which of the following is NOT a defining characteristic of engineering design according to the CEAB definition?
- Simple and straightforward (correct)
- Open-ended
- Multidisciplinary
- Iterative
According to the engineering triangle, it is possible to achieve 'Good, Fast, and Economical' results simultaneously.
According to the engineering triangle, it is possible to achieve 'Good, Fast, and Economical' results simultaneously.
False (B)
In the context Software Engineering, briefly describe what a 'Fault' is within a program?
In the context Software Engineering, briefly describe what a 'Fault' is within a program?
A hidden problem in the program
In the progression of Fault, Error, and Failure, an observable problem is referred to as a ______.
In the progression of Fault, Error, and Failure, an observable problem is referred to as a ______.
A company wants to develop a new software application. They need it to be high quality and they have a limited budget. According to the 'Engineering Triangle', what is the most likely consequence?
A company wants to develop a new software application. They need it to be high quality and they have a limited budget. According to the 'Engineering Triangle', what is the most likely consequence?
Software engineering focuses solely on the coding aspect of software production.
Software engineering focuses solely on the coding aspect of software production.
State one of the reasons provided for why software systems can be complex.
State one of the reasons provided for why software systems can be complex.
Match the following terms with their correct definitions in the context of software faults:
Match the following terms with their correct definitions in the context of software faults:
Which characteristic distinguishes static polymorphism from dynamic polymorphism?
Which characteristic distinguishes static polymorphism from dynamic polymorphism?
Cyclomatic complexity is a measure of the number of unique paths through the code.
Cyclomatic complexity is a measure of the number of unique paths through the code.
In Agile methodology, what is a sprint?
In Agile methodology, what is a sprint?
In Scrum, the individual who represents the customer’s interests is known as the ______.
In Scrum, the individual who represents the customer’s interests is known as the ______.
Which of the following is a primary benefit of DevOps?
Which of the following is a primary benefit of DevOps?
UML class diagrams serve as blueprints for software by illustrating its structure and relationships.
UML class diagrams serve as blueprints for software by illustrating its structure and relationships.
What are the three sections of a class represented as in a UML class diagram?
What are the three sections of a class represented as in a UML class diagram?
The Waterfall model of software development is best suited for projects with ______ requirements.
The Waterfall model of software development is best suited for projects with ______ requirements.
Which model emphasizes verification and validation at each development stage?
Which model emphasizes verification and validation at each development stage?
In Agile, comprehensive documentation is considered the primary measure of progress.
In Agile, comprehensive documentation is considered the primary measure of progress.
What is 'Planning Poker' used for in the Scrum process?
What is 'Planning Poker' used for in the Scrum process?
A _____ is a solid line between two classes in a UML Class Diagram.
A _____ is a solid line between two classes in a UML Class Diagram.
Which of the following is a disadvantage of the Spiral Model?
Which of the following is a disadvantage of the Spiral Model?
Match the following code smells with their descriptions:
Match the following code smells with their descriptions:
What does velocity
measure in Scrum?
What does velocity
measure in Scrum?
Which of the following best describes the purpose of a model in software engineering?
Which of the following best describes the purpose of a model in software engineering?
Domain-specific languages (DSLs) are designed to be versatile and applicable to a wide range of problems, similar to general-purpose programming languages.
Domain-specific languages (DSLs) are designed to be versatile and applicable to a wide range of problems, similar to general-purpose programming languages.
What does UML stand for, and what is its primary purpose in software development?
What does UML stand for, and what is its primary purpose in software development?
Developing the 'right product' focuses on meeting user needs, while 'developing the product _______' ensures maintainability, safety, and efficiency.
Developing the 'right product' focuses on meeting user needs, while 'developing the product _______' ensures maintainability, safety, and efficiency.
What are the likely outcomes of focusing solely on business value without considering technical aspects in product development?
What are the likely outcomes of focusing solely on business value without considering technical aspects in product development?
Technical debt always results in immediate and visible negative value, similar to bugs in the software.
Technical debt always results in immediate and visible negative value, similar to bugs in the software.
What is the 'Boy Scout' rule in the context of managing technical debt, and why is it important?
What is the 'Boy Scout' rule in the context of managing technical debt, and why is it important?
Match the following delivery approaches with their descriptions:
Match the following delivery approaches with their descriptions:
A system has a class ReportGenerator
that is responsible for generating reports in PDF, Excel, and CSV formats. Which SOLID principle is most clearly violated by this design?
A system has a class ReportGenerator
that is responsible for generating reports in PDF, Excel, and CSV formats. Which SOLID principle is most clearly violated by this design?
According to the risk formula provided, what factor can software engineers directly influence to manage risk?
According to the risk formula provided, what factor can software engineers directly influence to manage risk?
In iterative development, each _______ refines the product and incorporates feedback from previous cycles.
In iterative development, each _______ refines the product and incorporates feedback from previous cycles.
Technical debt always refers to intentionally poor design choices made to meet a deadline.
Technical debt always refers to intentionally poor design choices made to meet a deadline.
An MVP (Minimum Viable Product) includes all possible features to fully satisfy the needs of early adopters.
An MVP (Minimum Viable Product) includes all possible features to fully satisfy the needs of early adopters.
What is the primary difference between overriding
and overloading
in object-oriented programming?
What is the primary difference between overriding
and overloading
in object-oriented programming?
Which UML relationship is characterized by a weak 'has-a' relationship, where the contained object can exist independently of the container?
Which UML relationship is characterized by a weak 'has-a' relationship, where the contained object can exist independently of the container?
In object-oriented programming, a shallow copy ensures that all changes made to the copied object do not affect the original object.
In object-oriented programming, a shallow copy ensures that all changes made to the copied object do not affect the original object.
Name two key enablers for successful iterative and incremental design.
Name two key enablers for successful iterative and incremental design.
In UML, a ______ diagram shows the types of objects in the system and the various kinds of static relationships that exist among them.
In UML, a ______ diagram shows the types of objects in the system and the various kinds of static relationships that exist among them.
What is the key benefit of encapsulation in terms of data protection?
What is the key benefit of encapsulation in terms of data protection?
Match the SOLID principles with their descriptions:
Match the SOLID principles with their descriptions:
Which perspective in McCall's Quality Model focuses on aspects like maintainability and testability?
Which perspective in McCall's Quality Model focuses on aspects like maintainability and testability?
Refactoring is a disciplined way of improving existing code's internal structure without affecting its _______.
Refactoring is a disciplined way of improving existing code's internal structure without affecting its _______.
The principle that states a class should have only one reason to change is known as the __________.
The principle that states a class should have only one reason to change is known as the __________.
How does polymorphism help in software design, particularly in relation to switch statements?
How does polymorphism help in software design, particularly in relation to switch statements?
Match each SOLID principle to its corresponding description:
Match each SOLID principle to its corresponding description:
Which of the following best describes the purpose of abstraction in object-oriented programming?
Which of the following best describes the purpose of abstraction in object-oriented programming?
Composition is represented in UML with a hollow diamond at the container class end.
Composition is represented in UML with a hollow diamond at the container class end.
What does cardinality in UML relationships indicate?
What does cardinality in UML relationships indicate?
The 'is-a' relationship between classes indicates that _________ is being used.
The 'is-a' relationship between classes indicates that _________ is being used.
What is the primary benefit of using a Card
class with Value
and Color
attributes instead of integers to represent cards in a game?
What is the primary benefit of using a Card
class with Value
and Color
attributes instead of integers to represent cards in a game?
Overusing getters and setters always enhances encapsulation and prevents leaky abstractions.
Overusing getters and setters always enhances encapsulation and prevents leaky abstractions.
In terms of copying techniques, which ensures the safety of shared data by creating independent duplicates of objects?
In terms of copying techniques, which ensures the safety of shared data by creating independent duplicates of objects?
According to the SOLID principles, the letter 'O' stands for the _________.
According to the SOLID principles, the letter 'O' stands for the _________.
Which UML relationship is represented by a dashed line with a hollow triangle?
Which UML relationship is represented by a dashed line with a hollow triangle?
What type of relationship is best described by the statement: 'A file needs a directory to exist'?
What type of relationship is best described by the statement: 'A file needs a directory to exist'?
Which of the following best describes the primary difference between an interface and a class?
Which of the following best describes the primary difference between an interface and a class?
The YAGNI principle suggests adding functionality preemptively for potential future requirements.
The YAGNI principle suggests adding functionality preemptively for potential future requirements.
What is the primary goal of using composition in software design?
What is the primary goal of using composition in software design?
A poorly structured, messy codebase is often referred to as a 'Big Ball of ______'.
A poorly structured, messy codebase is often referred to as a 'Big Ball of ______'.
Match the UML relationships with their correct descriptions:
Match the UML relationships with their correct descriptions:
Which of the following is a key characteristic of composition compared to aggregation?
Which of the following is a key characteristic of composition compared to aggregation?
Which of the following statements is true regarding naming conventions for Aggregation?
Which of the following statements is true regarding naming conventions for Aggregation?
What should you use if reusable wheels are needed across multiple cars?
What should you use if reusable wheels are needed across multiple cars?
What is the primary advantage of behavioral composition?
What is the primary advantage of behavioral composition?
Which of the following is a potential drawback of behavioral composition?
Which of the following is a potential drawback of behavioral composition?
Which principle states that a class should be open for extension but closed for modification?
Which principle states that a class should be open for extension but closed for modification?
The Liskov Substitution Principle (LSP) implies that subclasses should always be able to replace their base classes without altering the correctness of the program.
The Liskov Substitution Principle (LSP) implies that subclasses should always be able to replace their base classes without altering the correctness of the program.
What is the primary goal of the Interface Segregation Principle (ISP)?
What is the primary goal of the Interface Segregation Principle (ISP)?
The Dependency Inversion Principle (DIP) advises depending on ______ rather than concrete implementations.
The Dependency Inversion Principle (DIP) advises depending on ______ rather than concrete implementations.
Which principle, when violated, leads to tight coupling and makes code harder to change?
Which principle, when violated, leads to tight coupling and makes code harder to change?
High cohesion is generally considered a bad design principle because it leads to classes performing multiple unrelated tasks.
High cohesion is generally considered a bad design principle because it leads to classes performing multiple unrelated tasks.
What does GRASP stand for, in the context of object-oriented design?
What does GRASP stand for, in the context of object-oriented design?
According to the Expert pattern, responsibility should be assigned to the class that has the most ______ information to fulfill it.
According to the Expert pattern, responsibility should be assigned to the class that has the most ______ information to fulfill it.
According to Creator Pattern, under what circumstance should class B create instance of class A?
According to Creator Pattern, under what circumstance should class B create instance of class A?
High coupling between classes is desirable as it increases flexibility and reduces interdependence.
High coupling between classes is desirable as it increases flexibility and reduces interdependence.
Match the GRASP principle to its description.
Match the GRASP principle to its description.
In the context of the Pure Fabrication pattern, why might you create a class that doesn't represent a real-world entity?
In the context of the Pure Fabrication pattern, why might you create a class that doesn't represent a real-world entity?
What is the major distinction between classes and types in OOP?
What is the major distinction between classes and types in OOP?
Classes and Types are the same?
Classes and Types are the same?
A class defines an object's ______ structure and implementation details; a type (interface) defines an object’s ______.
A class defines an object's ______ structure and implementation details; a type (interface) defines an object’s ______.
Flashcards
Engineering Design
Engineering Design
Solving problems creatively balancing technical knowledge and practical constraints.
Engineering Triangle
Engineering Triangle
Good, Fast, Economical - you can only pick two.
Software Engineering
Software Engineering
Systematic approach to designing and maintaining software.
Causes of Software Complexity
Causes of Software Complexity
Signup and view all the flashcards
Fault
Fault
Signup and view all the flashcards
Error
Error
Signup and view all the flashcards
Failure
Failure
Signup and view all the flashcards
Fault -> Error -> Failure
Fault -> Error -> Failure
Signup and view all the flashcards
Technical Debt
Technical Debt
Signup and view all the flashcards
UML Class Diagram
UML Class Diagram
Signup and view all the flashcards
UML Diagram Types
UML Diagram Types
Signup and view all the flashcards
Realization vs. Inheritance
Realization vs. Inheritance
Signup and view all the flashcards
Polymorphism
Polymorphism
Signup and view all the flashcards
Interface (Type)
Interface (Type)
Signup and view all the flashcards
YAGNI Principle
YAGNI Principle
Signup and view all the flashcards
Decomposition and Recomposition
Decomposition and Recomposition
Signup and view all the flashcards
"Big Ball of Mud"
"Big Ball of Mud"
Signup and view all the flashcards
Association (UML)
Association (UML)
Signup and view all the flashcards
Aggregation (UML)
Aggregation (UML)
Signup and view all the flashcards
Composition (UML)
Composition (UML)
Signup and view all the flashcards
Unidirectional Relationships
Unidirectional Relationships
Signup and view all the flashcards
Behavioral Composition
Behavioral Composition
Signup and view all the flashcards
Pros and cons of Behavioral Composition
Pros and cons of Behavioral Composition
Signup and view all the flashcards
Reduction in Modeling
Reduction in Modeling
Signup and view all the flashcards
Pragmatism in Modeling
Pragmatism in Modeling
Signup and view all the flashcards
Domain-Specific Languages (DSLs)
Domain-Specific Languages (DSLs)
Signup and view all the flashcards
Twofold Product Challenge
Twofold Product Challenge
Signup and view all the flashcards
Iterative Development
Iterative Development
Signup and view all the flashcards
Mitigating Risks with Prototypes
Mitigating Risks with Prototypes
Signup and view all the flashcards
Minimum Viable Product (MVP)
Minimum Viable Product (MVP)
Signup and view all the flashcards
Key Enablers of Iterative Design
Key Enablers of Iterative Design
Signup and view all the flashcards
McCall's Quality Model
McCall's Quality Model
Signup and view all the flashcards
Refactoring
Refactoring
Signup and view all the flashcards
Duplicated Code
Duplicated Code
Signup and view all the flashcards
Shotgun Surgery
Shotgun Surgery
Signup and view all the flashcards
Static Polymorphism
Static Polymorphism
Signup and view all the flashcards
Dynamic Polymorphism
Dynamic Polymorphism
Signup and view all the flashcards
Static Code Analysis
Static Code Analysis
Signup and view all the flashcards
Cyclomatic Complexity
Cyclomatic Complexity
Signup and view all the flashcards
Waterfall Model
Waterfall Model
Signup and view all the flashcards
V-Model
V-Model
Signup and view all the flashcards
W-Model
W-Model
Signup and view all the flashcards
Spiral Model
Spiral Model
Signup and view all the flashcards
Agile Methodology
Agile Methodology
Signup and view all the flashcards
Scrum Master
Scrum Master
Signup and view all the flashcards
Product Owner (PO)
Product Owner (PO)
Signup and view all the flashcards
Backlog
Backlog
Signup and view all the flashcards
Velocity
Velocity
Signup and view all the flashcards
DevOps
DevOps
Signup and view all the flashcards
Sustainable DevOps (SusDevOps)
Sustainable DevOps (SusDevOps)
Signup and view all the flashcards
Inheritance
Inheritance
Signup and view all the flashcards
Realization
Realization
Signup and view all the flashcards
Cardinality
Cardinality
Signup and view all the flashcards
Aggregation
Aggregation
Signup and view all the flashcards
Composition
Composition
Signup and view all the flashcards
Encapsulation
Encapsulation
Signup and view all the flashcards
Abstraction
Abstraction
Signup and view all the flashcards
Shallow Copy
Shallow Copy
Signup and view all the flashcards
Deep Copy
Deep Copy
Signup and view all the flashcards
Read-Only Copy
Read-Only Copy
Signup and view all the flashcards
Single Responsibility Principle (SRP)
Single Responsibility Principle (SRP)
Signup and view all the flashcards
Inheritance (UML)
Inheritance (UML)
Signup and view all the flashcards
Open/Closed Principle (OCP)
Open/Closed Principle (OCP)
Signup and view all the flashcards
Liskov Substitution Principle (LSP)
Liskov Substitution Principle (LSP)
Signup and view all the flashcards
Interface Segregation Principle (ISP)
Interface Segregation Principle (ISP)
Signup and view all the flashcards
Dependency Inversion Principle (DIP)
Dependency Inversion Principle (DIP)
Signup and view all the flashcards
Responsibility
Responsibility
Signup and view all the flashcards
SRP (Single Responsibility Principle)
SRP (Single Responsibility Principle)
Signup and view all the flashcards
GRASP
GRASP
Signup and view all the flashcards
Information Specialist (Expert)
Information Specialist (Expert)
Signup and view all the flashcards
Creator Pattern
Creator Pattern
Signup and view all the flashcards
Coupling
Coupling
Signup and view all the flashcards
Cohesion
Cohesion
Signup and view all the flashcards
Pure Fabrication
Pure Fabrication
Signup and view all the flashcards
Primitive Types
Primitive Types
Signup and view all the flashcards
Non-Primitive Types
Non-Primitive Types
Signup and view all the flashcards
Type (Interface)
Type (Interface)
Signup and view all the flashcards
Study Notes
Engineering Design (CEAB Definition)
- The process of engineering design involves creatively solving problems while carefully considering both technical knowledge and practical limitations.
- Engineering problems are complex, open-ended, iterative, and multidisciplinary; they may have multiple solutions, require several attempts, and involve various areas of expertise.
- Informed decisions rely on the use of science and mathematics to determine the most effective solutions.
- Design constraints include factors like health, safety, cost, environmental impact, and regulatory compliance.
The Engineering Triangle
- The engineering triangle illustrates a common trade-off where you can only prioritize two of the following attributes: good, fast, and economical.
- "Good" and "Fast" results in higher expenses.
- "Good" and "Economical" results in longer development time.
- "Fast" and "Economical" results in compromised quality.
Definitions of Software Engineering
- IEEE/ISO defines it as the systematic application of knowledge and methods for software design and maintenance.
- Sommerville states that it encompasses all aspects of software production.
- Bauer defines it as the application of engineering principles to create reliable, efficient, and cost-effective software.
Cause of Complexity
- Software systems are inherently complex due to many components, potentially leading to more points of failure.
- Multiple stakeholders with differing perspectives and needs increase the complexity of software systems.
- Emergent behavior, characterized by unexpected interactions between components, further contributes to the complexity of software systems.
- Engineering systematically manages this complexity.
Fault, Error, and Failure
- A fault is a hidden problem within the program, like an incorrect default setting.
- An error is a flawed state that occurs while the program is running, such as encountering a null value when one is not expected.
- A failure is an observable issue resulting from the error, such as when the program crashes.
- The progression is: Fault -> Error -> Failure.
What makes a Model useful?
- Modeling involves three main principles: mapping, reduction, and pragmatism.
- Mapping ensures the model accurately reflects real-world elements.
- Reduction simplifies the model to only include essential details.
- Pragmatism ensures the model is created with a specific purpose in mind.
- Models help in addressing the complexity of large systems by simplifying and focusing on the most critical aspects.
Languages for Models
- Programming languages, such as Python and Java, are different from modeling languages like UML.
- General-purpose languages are suitable for various problems, while domain-specific languages (DSLs) are designed for use in very specific fields.
UML Class Diagrams
- UML is a tool used to model systems.
- A class diagram shows classes and their relationships.
- Classes (e.g., Car) possess attributes (e.g., make, model) etc.
- Relationships, for example: a Car is driven by a Driver.
UML
- Class diagrams show the structure of a system.
- Sequence diagrams show how objects interact over time.
- Activity diagrams represent workflows.
- UML serves as a universal language for software engineers to exchange design ideas.
Delivering Value
- Developing a product involves both developing the right product, to ensure it meets user requirements, and developing the product right, to make sure that it is maintainable, safe, and efficient.
Balancing Business and Technical Value
- Focusing only on business value may result in poor performance, maintenance difficulties, and a lack of technical sustainability.
- Focusing only on technical value may result in excellent code but a product that does not meet user needs.
- Balancing both aspects is ideal but challenging, particularly with strict deadlines.
Characterising Value
- Features add visible positive value.
- Design choices add invisible but positive value.
- Bugs are those things imparting a visible, negative value.
- Technical debt is any invisible but negative value.
Delivering Value Over Time
- There are three delivery approaches: continuous delivery, a release approach, and a "You Only Live Once" (YOLO) approach.
- Continuous delivery is the most valuable and lowest risk approach
Relation to Risk Management
- Risk equals costs minus value delivered over time,
Risk = Costs – Value Delivered Over Time
. - Software engineers have limited control over costs but can influence how quickly and effectively value is delivered.
Technical Debt
- Technical debt is the future cost of rework caused by suboptimal design or shortcuts taken during development.
- It occurs due to poor design decisions, rushed or untested code, and prioritizing speed over quality.
- Repercussions include increased entropy (disorder) in the codebase and higher costs for new features or fixes.
How to Manage Technical Debt
- Follow the Boy Scout rule: Always leave the code better than you found it.
- Follow the Broken Window principle By ensuring code is clean and maintained.
Iterative Development
- Building software in small cycles (iterations).
- Each iteration refines the product and incorporates feedback from previous cycles.
Iterative and Incremental Development
- Iterative development allows gradual understanding of the problem and refinement of the solution.
- Incremental development adds small, functional pieces to the system.
Benefits
- Mitigating risks through early prototypes.
- Addressing technical debt early.
Minimum Viable Product (MVP)
- An MVP is a basic version of the product with minimal features and must be viable/functional enough to validate its usefulness.
MVP Goal:
- To get feedback from users, and improve the product through iterations.
Key Enablers of Iterative Design
- Maintainability, test coverage, and version control.
- Refactor code (without breaking functionality) ensuring it can be added to easily.
- Write tests to avoid breaking existing code.
- Use tools like Git to track changes effectively.
McCall's Quality Model Triangle
- It breaks down software quality into three perspectives: product operation, product revision, and product transition.
- Includes efficiency and reliability
- Includes maintainability and testability
- Includes portability and interoperability
Refactoring
- Refactoring improves existing code in a disciplined way.
- It changes the internal structure without affecting external behavior.
- Refactoring improves maintainability.
- Refactoring helps makes the code easier to read and modify.
Refactoring 101
- It involves small steps to minimize errors.
- The system remains functional after every change.
- Examples: Simplify long methods, remove duplicate code, and reduce unnecessary complexity.
Patterns That Need Refactoring
- Duplicated code, long methods, shotgun surgery (making a single change requires edits in many places), and feature envy (when one class relies heavily on another class’s data).
Polymorphism
- Polymorphism allows a single interface to represent different types or behaviors, which can replace switch statements.
Static Polymorphism
- The method that gets called is determined at compile time.
- Achieved through: method overloading and operator overloading.
Dynamic Polymorphism
- The method that gets called is determined at runtime.
- Achieved through: method overriding.
Static Code Analysis
- Examining the code without running it.
- Measures lines of code (LOC).
- Simplicity over excessive length.
- Cyclomatic complexity tracks the number of unique paths through the code.
Cyclomatic Complexity
- This metric counts the number of edges and nodes in a control flow graph.
- It measures how complicated the logic is.
Managing Code Quality
- Always use braces for clarity, even in simple conditions.
- Avoid confusing ternary operators.
Waterfall Model
- A linear, sequential approach.
- Each phase depends on the completion of the previous one.
Advantages:
- Simple and easy to follow.
Disadvantages
- Difficult to make changes once a phase is completed, slow value delivery because value isn’t delivered until the very end.
V-Model
- Similar to the Waterfall model but emphasizes verification and validation (V&V) at each stage.
Advantages;
- A strong focus on testing.
Disadvantages:
- Still rigid and slow.
- Late value delivery.
W-Model
- Testing occurs earlier, reducing late-stage issues.
- Tracking progress is harder.
Spiral Model
- A combination of iterative development with systematic risk assessment.
Advantages:
- Better risk management.
Disadvantages
- Continuous value delivery through increments, requires skilled customer interaction, and can be costly and complex.
Agile Methodology
- Breaking projects into sprints.
- Sprint examples include collaboration and continuous improvement.
Advantages:
- Flexible.
Examples:
- Scrum, Extreme Programming (XP).
Agile Frameworks: Scrum
- Key Concepts include:
- Scrum Master
- Product Owner (PO)
- Backlog
- Velocity
Agile Challenges
- Agile principles are often misused or misunderstood.
- Internal and external misalignments between principles and practices.
Agile
- It promotes working software as the primary measure of progress, instead of extensive documentation.
- It reduces risk through frequent delivery and adapting to changes.
- Not always suitable for projects requiring heavy certification.
Scrum Process
- Planning poker and Daily stand ups
DevOps
- Integrates software development (Dev) with IT operations (Ops) to automate workflows and foster collaboration.
Benefits:
- Complements Agile practices.
Sustainable DevOps (SusDevOps)
- Incorporates sustainability as a first-class principle in software delivery while retaining Agile principles.
Introduction to UML Class Diagrams
- UML gives a standard way to visualize system design.
- Class diagrams are blueprints for software, revealing its structure and relationships.
UML include:
- Class Diagrams
- Sequence Diagrams
- Activity Diagrams
- Use-Case Diagrams
- State Machine Diagrams
General vs. Domain-Specific Languages
- General-purpose languages (Java, Python) work for every problem.
- Domain-specific languages (SQL) are tailored for specific problems.
UML Class Diagram - Entities
- Classes (name, attributes, methods)
- Objects are instances of a class.
Perspectives in Class Diagrams
- UML can be conceptual, logical, and implementational.
- Conceptual (high-level representation of entities).
- Logical (shows relationships and interactions).
- Implementation (details like database tables or code structure).
Relationships in UML
- Association, inheritance (generalization), aggregation, composition, dependency.
Association
- Solid line between two classes.
- Example: A
Person
owns aCar
.
Inheritance (Generalization):
Hollow triangle
- Example:
Dog
inherits fromAnimal
.
Aggregation
Hollow diamond
- Example: A
Team
containsPlayers
.
Composition
Filled diamond
- Example: A
House
containsRooms
.
Dependency
Dashed line
- Example: A
Student
depends onLibrary
.
Inheritance
- One class shares the behavior of another.
- Vehicle, car, bike examples .
Realization
- A class implements an interface.
- Represented by a dashed line with a hollow triangle.
Cardinality in Relationships
- Cardinality indicates how many objects are associated.
1..1
: Exactly one.0..*
: Zero or many.1..*
: One or more.
Aggregation vs. Composition
- Aggregation is a weak "has-a" relationship.
- Classrooms have students, but students can exist without the classroom.
- Composition is a strong "part-of" relationship.
- Houses have rooms, and rooms cannot exist without the house.
Encapsulation
- Encapsulation is about bundling data (attributes) and behavior (methods) into a class, ensuring integrity by hiding internal details and defining visibility rules.
Problems Without Encapsulation
- Tight coupling with internal representation can lead to data corruption and difficulty maintaining code.
Benefits of Encapsulation
- Eliminates primitive obsession, access control ensures no uncontrolled modification of private data.
Encapsulation of Behaviour
- A
CardPile
defines business logic to shuffle and draw cards. - Users don’t need to know how the cards are stored; they just use the services provided by the
CardPile
class.
Information Hiding and Trade-offs
- Overusing getters can lead to leaky abstractions, exposing internal data and violating invariants.
Abstractions
- Abstraction focuses on what an object does rather than how it does it.
- A
Shape
class might have an abstract methoddraw()
. - The implementation of
draw()
will differ for subclasses likeCircle
andRectangle
.
Copying and Encapsulation
- Copying techniques ensure the safety of shared data: shallow copy, deep copy, and read-only copy.
UML Relationships
- Inheritance children get some properties from the parent
- Association key word is "uses" or "associates"
- Composition has the "has a" key word with a strong relationship
- Aggregation has the "has a" key word with a weak relationship
Recap of Foundational OOP Mechanisms
- Polymorphism (one interface, multiple implementations), encapsulation, and abstraction.
- Inheritance enables reuse of code by extending classes.
- These principles are the building blocks of the SOLID design principles.
- The SOLID principles help developers create understandable, flexible, and maintainable software.
What does SOLID stand for?
- Single Responsibility Principle (SRP), Open/Closed Principle (OCP), Liskov Substitution Principle (LSP), Interface Segregation Principle (ISP), and Dependency Inversion Principle (DIP).
Single Responsibility Principle (SRP)
- A class should have only one reason to change.
- Break
Library
class intoBookCollection
,UserRegistry
, andFeeTracker
classes. - Benefits include easier maintenance, more testability, and flexibility.
Open/Closed Principle (OCP)
- A class should be open for extension but closed for modification.
- Use polymorphism: Create a
Vehicle
interface with a method likemove()
.
Liskov Substitution Principle (LSP)
- Ensure predictability when using subclasses and avoid bugs due to unexpected behavior.
Interface Segregation Principle (ISP)
- A class should not be forced to implement interfaces it doesn’t use.
- Split the
Searchable
interface into smaller, more specific interfaces. - Reduces unnecessary dependencies and improves modularity and flexibility.
Dependency Inversion Principle (DIP)
- Depend on abstractions, not on concrete implementations.
- Use an abstraction like
BookDataSource
(interface). - Improves testability by mocking dependencies.
Responsibility
- A task or function that an object performs.
- "Who should do what" is the fundamental question in object-oriented design.
GRASP
- GRASP is a set of principles, in object oriented programming, to help decide where to assign responsibilities.
- Stand for General Responsibility Assignment Software Patterns
List of GRASP patterns:
- Information Specialist (Expert)
- Creator
- Controller
- Indirection
- Low Coupling
- High Cohesion
- Polymorphism
- Protected Variations
- Pure Fabrication
Information Specialist (Expert Pattern)
- Give responsibility to the class that has the required data.
Example
- Board should handle tile-related operations (e.g., finding a tile).
Creator Pattern
- Object (B) should create another object (A) when:
- B contains A.
- B closely uses A.
- B has the necessary initialization information.
Low Coupling
- Avoid tight dependency between classes to increase flexibility.
High Cohesion
- Keep classes focused on one task to improve reusability and readability.
Pure Fabrication
- Create helper classes when needed to keep cohesion high and coupling low.
Types in OOP
- Primitives:
int, double, float
. - Non-primitive, custom objects in Java:
Car, Cat, Dog
. - Classes define implementation.
- Types define behavior.
Classes vs. Types
- Classes define an object’s internal structure and implementation details.
- Types (interfaces) define an object’s behavior.
Key takeaway
- Interfaces defines what can be done, while classes define how it is done.
- Use interfaces as return types whenever possible.
YAGNI Principle (You Aren't Gonna Need It)
- Don't write code for future, uncertain requirements
- Avoid writing unnecessary code based on anticipated future needs.
Why Composition Matters?
- Decomposition and recomposition are effective problem-solving approaches.
The Big Ball of Mud (Bad Design)
- "Big Ball of Mud" refers to a messy codebase with no clear separation of concerns.
- Spaghetti code has no clear structure, making it hard to debug and maintain.
- Use composition to create well-structured relationships.
Composition As A Special Form
Composition == Stronger Ownership than Aggregation
UML Notation for Relationships
- Prefer unidirectional relationships whenever possible to reduce coupling.
Behavioral Composition
- Structural composition deals with data relationships.
- Behavioral composition combines behaviors dynamically.
Why
- Delegates behavior (does not repeat), can be changed at runtime, and follows SRP.
Behavioral Composition Key Tradeoffs
- Pros: low coupling, no if-else clutter, runtime flexibility.
- Cons: requires many small objects.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Comprehensive software engineering quiz covering design characteristics, the engineering triangle, faults, errors, failures, and polymorphism. It explores complexity in software systems and cyclomatic complexity measurements. This assessment tests understanding of core software engineering principles.