Professional Documents
Culture Documents
Design Quality SGI PS Day 1
Design Quality SGI PS Day 1
• During the proposed engagement for Design coaching, the emphasis will be on improvement and maturity of design
practices within the team.
• Mentors – Elroy, Girish, (Support: Himanshu/Shrinath)
100
Percentage Contribution
80
Adminstrative Errors
Documentation Errors
60
Bad Fixes
Coding Errors
40 Design Errors
Requirements Errors
20
0
IBM SPR TRW MITRE Nippon Electric
Corportation Corporation Corporation Corporation Corp
(MVS) (Client Studies)
Software Technical
Quality Debt
Quality
Definition
Attribute
Understandability The ease with which the design fragment can be comprehended.
The ease with which a design fragment can be modified (without causing ripple
Changeability
effects) when an existing functionality is changed.
The ease with which a design fragment can be enhanced or extended (without
Extensibility
ripple effects) for supporting new functionality.
The ease with which a design fragment can be used in a problem context other
Reusability
than the one for which the design fragment was originally developed.
The ease with which a design fragment supports the detection of defects within
Testability
it via testing.
The extent to which the design fragment supports the correct realization of the
Reliability
functionality and helps guard against the introduction of runtime problems.
Restricted © Siemens AG 2021
Page 5 Slide 5 T RDA SSI RSE-IN
Why care about technical debt?
Defects
Developer
Technical Debt
Restricted © Siemens AG 2021
Page 8 Slide 8 T RDA SSI RSE-IN
What constitutes technical debt?
Documentatio
Code debt Design debt Test debt
n debt
No
Static analysis Lack of tests documentation
…
Design smells
tool violations for important
concerns
Separation of Concerns
Anticipation of Change
There should never be more than one reason for a class to change
Let’s say we have to build an application that calculates the sum of area of
rectangles
Let’s say, now, the customer wants us to extend this to include area of circles as well
Let’s say, now, the customer asks “Can you extend this to calculate area of triangles?”
Though this may not be very hard, but we will need to modify our code again.
In real-world projects, requirements change frequently and modifying the class and
redeploying the binaries every time the requirements change is effort intensive and not
cost effective.
Software entities should be open for extension and closed for modification
Open for extension – extend with new behaviors
Closed for modification – extending behavior does not result in changes to source
code or binary code of module. .exe, DLL, .jar remain untouched!
Shape
double area()
Clients that use references (or pointers) to base abstractions must be able to use their
derived abstractions without knowing it
A is base class. B is derived type.
B bType = new B();
A aType = bType;
aType.print();
A subclass must be replaceable where its super class is referenced
Everything that is true of the base type should be true of the subtype
Restricted © Siemens AG 2021
Page 37 T RDA SSI RSE-IN
Applying LSP
Vehicle
void startEngine()
void accelerate()
Rectangle
Square
Issues:
•Square doesn’t need both itsWidth and itsHeight
•Having both SetWidth and SetHeight inappropriate
Restricted © Siemens AG 2021
Page 39 Slide 39 T RDA SSI RSE-IN
LSP Violation - example
Client Team A gets the new server and things are great
But Client Team B is now broken and must recompile and go through a round of regression testing
because a feature was added for another team
Interfaces may contain groups of methods, where each group serves a different set of
clients. Best to separate them.
Clients should not be forced to depend upon interfaces that they do not need
When a client A depends on a class that contains methods that it does not use, but
which other clients use, client A will be affected by changes those other clients
force upon the class
Don’t pollute interfaces
Avoid fat interfaces
Interfaces here do not mean Java Interfaces. They mean the public methods that are
exposed by a class
Button object has Poll method to determine whether or not user has “pressed” it.
The Button could be represented as an icon on GUI, home security system, physical
button, etc. The Poll method helps detect if the button is activated or deactivated.
Abstractions should not depend upon implementation details. Details should be dependent upon
abstractions.
<<interface>>
Button
SwitchableDevice
+ Poll()
+ turnOn()
+ turnOff()
Lamp
Don’t Repeat Yourself Principle (DRY) - “Every piece of knowledge must have a single,
unambiguous, authoritative representation within a system” [HT99].
Keep it simple Silly (KISS) – Avoid unnecessary complexity. Keep things simple since it helps
improve understandability and helps detect deficiencies easily.
Composition Preference Principle (CPP) - Shorter name for the principle “favor object
composition over class inheritance” [EGV94].
Variation Encapsulation Principle (VEP) – Information hiding wherein the concept that is
varying is encapsulated within a class or a hierarchy.
Acyclic Dependencies Principle – Dependencies between packages or classes must not form
cycles.
Restricted © Siemens AG 2021
Page 54 T RDA SSI RSE-IN
Thank you!
A
Q
Thank you!
Comprehension tools
Imagix 4D, Structure 101
Critique, code-clone detectors, and metric tools
Infusion, Designite, Ndepend
Simian, CPD
Understand, Source-monitor, Designite
Technical debt quantification and visualization tools
Sonar Qube
Refactoring tools
Refactoring inferencing tools – SCOUT, Jdeoderant
Refactoring performing tools – Eclipse, Resharper