Agile Software Development# 07 What is Agile Design?
7.What is Agile Design?
📌What is "The Design"?
UML diagram
"The Design"
Source code
"The Design"
The design of a software is abstract. You CAN'T list every details of the software. Therefore, the source code is "The Design". You can only understand fully and truly by reading source codes.
📌Design Smell - The Odors of Rotting Software🤮
You can smell the following odors when software rotting...
- 1️⃣Rigidity - the system is hard to change since every change forces other changes as well
- 2️⃣Fragility - changes cause the system to break in places
- 3️⃣Immobility - it is hard to disentangle1 the system into components that can be reused in other systems
- 4️⃣Viscosity2 - Doing things right is harder than doing things wrong
- 5️⃣Needless Complexity - The design contains infrastructure that adds no direct benefits
- 6️⃣Needless Repetition3 - the design contains repeating structures that could be unified under a single abstraction
- 7️⃣Opacity - it is hard to read and understand. it does not express its intent well
📌What Stimulates the Software to Rot?
The answer is "CHANGES"! Bit by bit, as the changes continue, these violations accumulate, and the design begins to smell.
📌We Can't Blame on Changes!
Why? Because the requirements are the most volatile elements in the project.
So? We should make our designs resilient to such changes and employ practices that protect them from rotting.
📌Story 1 - Regular Developers Encounter Changes
Customer Requirement Ver_1:
Write a program that copies characters from the keyboard.
Code Designed Ver_1:
The program can be divided into 3 modules:
- 1️⃣ the
ReadKeyboard
module - 2️⃣ the
Copy
program which fetcheschar
fromReadKeyboard
and routes them to theWritePrinter
module - 3️⃣ the
WritePrinter
module
xxxxxxxxxx
void Copy()
{
int c;
while ((c=RdKbd()) != EOF)
WrtPrt(c);
}
Customer Requirement Ver_2:
The program reads characters from the paper tape reader from time to time...
Code Designed Ver_2:
You use bool
to encounter such changes.
xxxxxxxxxx
bool ptFlag = false;
// remember to reset this flag
void Copy()
{
int c;
while ((c=(ptflag ? RdPt() : RdKbd())) != EOF)
WrtPrt(c);
}
Customer Requirement Ver_3:
The Copy program needs output to the paper tape punch.
Code Designed Ver_3:
You continue the last modification philosophy and make a bool
for the output as well.
xxxxxxxxxx
bool ptFlag = false;
bool punchFlag = false;
// remember to reset these flags
void Copy()
{
int c;
while ((c=(ptflag ? RdPt() : RdKbd())) != EOF)
punchFlag ? WrtPunch(c) : WrtPrt(c);
}
Summary
During this whole process, you complained again and again...😡 You almost want to leave the job...
📌Story 2 - Agile Developers Encounter Changes
The difference begins at the first incoming modification when the agile developers were asked to make the program read from the paper tape reader:
Code Design Ver_2:
The team has followed the Open–Closed Principle (OCP). This principle helps the program can be extended without modification. In the future, you can add more Reader
.
xxxxxxxxxx
class Reader
{
public:
virtual int read() = 0;
};
class KeyboardReader : public Reader
{
public:
virtual int read() {return RdKbd();}
};
From the Copy
program perspective, you can use select different Reader
xxxxxxxxxx
KeyboardReader GdefaultReader;
void Copy(Reader& reader = GdefaultReader)
{
int c;
while ((c=reader.read()) != EOF)
WrtPrt(c);
}
Why no similar implementation on the ouput?
The reason is simple. Because the change has not been encountered! You only modify your code once needed, otherwise the code would be Needless Complexity.
📌How Did the Agile Developers Know What to Do?
1️⃣They detected the problem by following agile practices
2️⃣They diagnosed the problem by applying design principles
3️⃣They solved the problem by applying the appropriate design pattern.
The interplay between these 3 aspects of software development is the act of design.
📌Conclusion
Agile design is a process, not an event.