Awareness of design smells - indicators of common design problems - helps developers or software engineers understand mistakes made while designing and apply design principles for creating high-quality designs. This workshop provides insights gained from performing refactoring in real-world projects to improve refactoring and reduce the time and costs of managing software projects. The workshop also presents insightful anecdotes and case studies drawn from the trenches of real-world projects. By attending this workshop, you will know pragmatic techniques for refactoring design smells to manage technical debt and to create and maintain high-quality software in practice.
Contents overview:
* Why care about design principles, design quality, or design smells?
* Refactoring as the primary means for repaying technical debt
* Smells that violate abstraction, encapsulation, modularisation, or hierarchy
* Tools and techniques for refactoring
7. Poor software quality costs
more than $150 billion per year
in U.S. and greater than $500
billion per year worldwide
- Capers Jones
Why care? Reason #1
15. "... a delightful, engaging, actionable read... you have
in your hand a veritable field guide of smells... one
of the more interesting and complex expositions of
software smells you will ever find..."
- From the foreword by Grady Booch (IBM Fellow and Chief Scientist for
Software Engineering, IBM Research)
16. "We thought we were just programming on an airplane”
- Kent Beck
Why care? Reason #2
17. "This is a good book about ‘Design Smells’ – actually
a great book – nicely organized - clearly written with
plenty of examples and a fair sprinkling of
anecdotes."
- Will Tracz (Principal Research Scientist & Fellow,
Lockheed Martin)
(review in ACM SIGSOFT Software Engineering
Notes)
18. Fundamental principles in software design
Principles*
Abstrac/on*
Encapsula/on*
Modulariza/on*
Hierarchy*
19. Effective design: Java parallel streams
❖ Applies the principles of abstraction and encapsulation
effectively to significantly simplify concurrent
programming
Parallel code
Serial code
20. Parallel streams: example
import java.util.stream.LongStream;
class PrimeNumbers {
private static boolean isPrime(long val) {
for(long i = 2; i <= val/2; i++) {
if((val % i) == 0) {
return false;
}
}
return true;
}
public static void main(String []args) {
long numOfPrimes = LongStream.rangeClosed(2, 50_000)
.parallel()
.filter(PrimeNumbers::isPrime)
.count();
System.out.println(numOfPrimes);
}
}
21. long numOfPrimes = LongStream.rangeClosed(2, 100_000)
.filter(PrimeNumbers::isPrime)
.count();
System.out.println(numOfPrimes);
Prints 9592
2.510 seconds
27. What is refactoring?
Refactoring (noun): a change
made to the internal structure of
software to make it easier to
understand and cheaper to
modify without changing its
observable behavior
Refactor (verb): to restructure
software by applying a series
of refactorings without
changing its observable
behavior
33. Discussion example
// using java.util.Date
Date today = new Date();
System.out.println(today);
$ java DateUse
Wed Dec 02 17:17:08 IST 2015
Why should we get the
time and timezone details
if I only want a date? Can
I get rid of these parts?
No!
34. So what!
Date today = new Date();
System.out.println(today);
Date todayAgain = new Date();
System.out.println(todayAgain);
System.out.println(today.compareTo(todayAgain) == 0);
Thu Mar 17 13:21:55 IST 2016
Thu Mar 17 13:21:55 IST 2016
false
What is going
on here?
39. Refactored example …
You can use only date,
time, or even timezone,
and combine them as
needed!
LocalDate today = LocalDate.now();
System.out.println(today);
LocalTime now = LocalTime.now();
System.out.println(now);
ZoneId id = ZoneId.of("Asia/Tokyo");
System.out.println(id);
LocalDateTime todayAndNow = LocalDateTime.now();
System.out.println(todayAndNow);
ZonedDateTime todayAndNowInTokyo = ZonedDateTime.now(ZoneId.of("Asia/Tokyo"));
System.out.println(todayAndNowInTokyo);
2016-03-17
13:28:06.927
Asia/Tokyo
2016-03-17T13:28:06.928
2016-03-17T16:58:06.929+09:00[Asia/Tokyo]
46. Refactoring: Practical concerns
“Fear of breaking
working code”
Is management buy-in necessary for refactoring?
How to refactor code in legacy projects (no automated
tests, difficulty in understanding, lack of motivation, …)?
Where do I have time
for refactoring?