title: Clean Code Fundamentals subtitle: Polly want a message ...
::: columns
:::: column
Chapter | Time |
---|---|
Design stamina hypothesis | 03:50 |
Procedures vs. OO | 05:59 |
Churn vs. complexity | 07:49 |
Design star anti-pattern | 11:04 |
Easy is the enemy of simple | 15:35 |
Affordances | 21:35 |
::::
:::: column
Chapter | Time |
---|---|
Anthropomorphic polymorphic | 24:24 |
Resolution | 29:55 |
Isolate thing you want to vary | 32:13 |
Push conditionals back on stack | 33:15 |
Dependency injection | 34:47 |
But, conditionals? | 35:24 |
::::
:::
Activity | Time |
---|---|
Warmup | 5 min |
Exercise 1 | 30 min |
Exercise 2 | 30 min |
Exercise 3 | 20 min |
Wrap up | 5 min |
- Do you have the "death star" anti-pattern examples from your code?
- Type in the meeting chat
- Prompt
- How object-oriented design principles can improve (or detract) the success of a project or application?
- Are there any similarities or differences between OOP and TDD?
- Time limit: 10 minutes
- Groups to share their findings
-
Pros
- Modularity and reusability
- Can reduce time and effort required to develop and maintain the code
- Abstraction and encapsulation
- Hides the implementation details, making the code more readable
- Flexibility and adaptability
- Loose coupling and polymorphism makes it easier to change or update individual objects without affecting the rest of the system
- Improved debugging and testing
- Makes it easier to isolate and debug individual objects
- Modularity and reusability
-
Cons
- If not properly applied, can lead to complex and hard-to-maintain code, or overly complex class hierarchies ("Faux OO")
- Not always the best fit for every type of problem or project
-
Dependency injection
- Design pattern that involves passing objects as dependencies to an object, rather than creating these dependencies within the object itself
-
Prompt
- Discuss the benefits and challenges of using dependency injection in a project that involves multiple objects that depend on each other
- Consider the following questions:
- How does dependency injection help decouple the objects in the project?
- What are the trade-offs of using dependency injection versus creating dependencies within the objects themselves?
- How does dependency injection impact the maintainability and scalability of the project?
- Can you think of a real-world example where dependency injection would be useful?
-
Time limit: 15 minutes
- Groups to share their findings
-
What is polymorphism
- The quality where different kinds of objects can respond to the same message
- Objects can take on many forms and behave differently based on context
-
Prompt
- How does polymorphism make code more expressive and modular?
- What are the trade-offs of using polymorphism, and how to mitigate them?
- How can you test code with polymorphism, and what are the challenges?
-
Time limit: 10 minutes
- Groups to share their findings
-
How does polymorphism make code more expressive and modular?
- Creates a more dynamic code, as the same message can have different effects on different objects
- Leads to more modular code, as different implementations of a message can be separated into different classes; easier to reuse and maintain the code
-
What are the trade-offs of using polymorphism, and how to mitigate them?
- Can make the code harder to understand and maintain since the same message can have different effects on different objects
- Can lead to runtime errors if the message is sent to an object that doesn't have an implementation of that message
-
How can you test code with polymorphism, and what are the challenges?
- Test the behavior of each implementation of a message
- Ensure that the code functions correctly when you send messages to objects of different types
- OOP affords ... objects
- Anthropomorphic
- The attribution of human traits, emotions or intentions to non-human entities
- Polymorphic
- The quality where different kinds of objects can respond to the same message
- Loosely-coupled
- Objects strive for independence
- Role-playing
- Objects are more players of their roles than instances of their types
- Factory-created
- Factories hide the rules of picking the right player for a role
- Message-sending
- "I know what I want, you know how to do it"
- Anthropomorphic
- Next session
- We will do dojo of participants' choice
- Expect an e-mail with instructions for upcoming coding dojo
Always leave the code better than you found it.
-- The Software Craftsmanship Rule