Accelerating Your Success TM L100: Private Cloud Immersion - Envision.
Architecture refactoring - accelerating business success
-
Upload
ganesh-samarthyam -
Category
Software
-
view
213 -
download
0
Transcript of Architecture refactoring - accelerating business success
![Page 1: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/1.jpg)
Architecture Refactoring Accelerating Business Success
Ganesh Samarthyam, Corporate Trainer and Author www.designsmells.com
![Page 2: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/2.jpg)
Architecture is all about realising business needs
Abstract business need (requirements)
Concrete implementation (code)
Architecture & Design
![Page 3: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/3.jpg)
… but business needs keep changing!
![Page 4: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/4.jpg)
…with that we need to adapt the software
![Page 5: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/5.jpg)
City metaphor
“Cities grow, cities evolve, cities have parts that simply die while other
parts flourish; each city has to be renewed in order to meet the needs of its populace… Software-intensive systems
are like that. They grow, they evolve, sometimes they wither away, and
sometimes they flourish…”
Grady Booch in the foreword for “Refactoring for Software Design Smells: Managing Technical Debt”, Girish Suryanarayana, Ganesh Samarthyam, Tushar Sharma, Morgan Kaufmann/Elsevier, 2014.
![Page 6: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/6.jpg)
What is architecture debt?
…
Architecture)debt)
Architecture)smells)
Architecture)viola2ons)
Design)debt)
Design)smells)
Viola2ons)of)design)rules)
Test)debt)
Lack)of)tests)
Inadequate)test)coverage)
Code)debt)
Sta2c)analysis)tool)viola2ons)
Inconsistent)coding)style)
![Page 7: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/7.jpg)
Key reasons for architecture refactoring
Address new business
needs
Increase feature velocity
Address architecture
decay
Realizing NFRs
Modernize
Reduce costs
![Page 8: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/8.jpg)
Code refactoring
margin = c.getMargin();
if (c instanceof AbstractButton) {
margin = ((AbstractButton)c).getMargin();
} else if (c instanceof JToolBar) {
margin = ((JToolBar)c).getMargin();
} else if (c instanceof JTextComponent) {
margin = ((JTextComponent)c).getMargin();
}
![Page 9: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/9.jpg)
Example: Refactoring for design smells
![Page 10: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/10.jpg)
Earlier (relatively) mature work
![Page 11: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/11.jpg)
Natural extension: Refactoring for architectural smells
The$red$lines$in$this$dependency$diagram$shows$
circular$dependencies$
![Page 12: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/12.jpg)
Code refactoring Architecture refactoring
A module-level or class-level concern A system level concern that cuts across modules or sub-systems
Impact of refactoring is within a team Impact of refactoring is often across teams
Typically performed to improve the internal structure of the code
Performed for various reasons: cost, regulatory, security, performance, availability, …
Management buy-in typically not required Management buy-in is typically required
Upfront planning is typically (relatively) limited
Upfront planning and co-ordination (sometimes between teams) is often required
Unit tests are important to ensure that “behaviour is preserved”
Unit tests, integration tests, system tests, NFR tests, … are required
Risk of breaking the working software is relatively low
Risk of breaking the working software is relatively high
Real-world analogy: “fixing potholes”
Real-world analogy: “metro construction”
![Page 13: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/13.jpg)
COTS(Commercial Off The Shelf)
FOSS(Free and Open Source Software)
Make Buy / Reuse
Proven technologies
Cutting-edge technologies
Architecting: the process of taking design decisions!
![Page 14: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/14.jpg)
Cross-cutting concerns
Error/Exception handling
ConcurrencyPersistence
Event handling
Interaction and presentation
Source: SWEBOK v3
![Page 15: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/15.jpg)
Case study: Using Structured EH
Source: https://msdn.microsoft.com/en-us/library/windows/desktop/ms681409(v=vs.85).aspx
Structured Exception Handling in VC++
Standard Exception Handling supported in modern C++ compilers
bool SafeDiv(Number dividend, Number divisor, Number &result) {
try { result = dividend / divisor;
} catch(Number::divide_by_zero ex) { return false;
} return true;
}
BOOL SafeDiv(Number dividend, Number divisor, Number &result) {
__try { result = dividend / divisor;
} __catch(GetExceptionCode() == EXCEPTION_INT_DIVIDE_BY_ZERO ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { return FALSE;
} return TRUE;
}
![Page 16: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/16.jpg)
Handling persistence
Oracle DB
Component-1
Component-2
Component-N
[establish connection, SQL
queries, close connection…]
No clone within a component, but
duplication of code across components
How to support different databases?
[establish connection, SQL
queries, close connection…]
[establish connection, SQL
queries, close connection…]
![Page 17: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/17.jpg)
Handling persistence
Component-1
Component-2
Component-N
Service layer / DAL
![Page 18: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/18.jpg)
Case Study #1: Refactoring Windows
![Page 19: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/19.jpg)
Refactoring Windows
![Page 20: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/20.jpg)
Refactoring Windows
“A large number of dependencies at the module level could be reduced and optimized to: * make modular reasoning of the system more efficient* maximize parallel development efficiency* avoid unwanted parallel change interference* selectively rebuild and retest subsystems effectively”
Refactoring performed to reduce and optimize dependencies - by creating and enforcing layering
Source: Kim, Miryung, Thomas Zimmermann, and Nachiappan Nagappan. "An Empirical Study of RefactoringChallenges and Benefits at Microsoft." IEEE Transactions on Software Engineering 7 (2014): 1-1.
![Page 21: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/21.jpg)
Refactoring Windows: Significant Characteristics
Refactoring decisions made after substantial analysis of existing dependency structure
Refactoring effort was centralized and top down with designated team for refactoring
Use of custom refactoring tools (MaX) and processes (quality gate check)
Source: Kim, Miryung, Thomas Zimmermann, and Nachiappan Nagappan. "An Empirical Study of RefactoringChallenges and Benefits at Microsoft." IEEE Transactions on Software Engineering 7 (2014): 1-1.
![Page 22: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/22.jpg)
Refactoring Windows
Source: Kim, Miryung, Thomas Zimmermann, and Nachiappan Nagappan. "An Empirical Study of RefactoringChallenges and Benefits at Microsoft." IEEE Transactions on Software Engineering 7 (2014): 1-1.
![Page 23: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/23.jpg)
Case Study #2: Refactoring Date & Time
support in JDK
![Page 24: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/24.jpg)
Poor API design in JDK for date/time
e.g., in java.util.Date class, days start at 0,
months start at 1, years start at 1900!
Prior to Java 8, API design for date and time in JDK was poor
![Page 25: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/25.jpg)
Date/Time related woes
// 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!
![Page 26: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/26.jpg)
Example of a design smell in Date class
“Refused bequest” smell
![Page 27: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/27.jpg)
Joda API & JSR 310
JSR 310: Java Date and Time API
Stephen Colebourne
![Page 28: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/28.jpg)
LocalDate in java.time package
// using java.time.LocalDate LocalDate today = LocalDate.now();System.out.println(today);
$ java DateUse 2015-12-02
I can use (and hence depend upon) only date related functionality (not
time, zone, etc)
![Page 29: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/29.jpg)
LocalDate in java.time package
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);
LocalDateTime todayAndNow = LocalDateTime.now(); System.out.println(todayAndNow);
ZonedDateTime todayAndNowInTokyo = ZonedDateTime.now(ZoneId.of("Asia/Tokyo")); System.out.println(todayAndNowInTokyo);
2015-12-02 17:37:22.647 2015-12-02T17:37:22.648 2015-12-02T21:07:22.649+09:00[Asia/Tokyo]
![Page 30: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/30.jpg)
Many useful classes in java.time
![Page 31: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/31.jpg)
Case Study #3: Refactoring JDK!
![Page 32: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/32.jpg)
Tangles in JDK
![Page 33: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/33.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved
![Page 34: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/34.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved
![Page 35: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/35.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved
![Page 36: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/36.jpg)
Project Jigsaw in Java 9
Modularize JDK & JRE
Hide platform internal details such as sun.misc
Provide a module system for Java developers
![Page 37: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/37.jpg)
Case Study #4: Linux Kernel
![Page 38: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/38.jpg)
Linux: Intended Architecture
![Page 39: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/39.jpg)
Linux: Extracted Architecture
![Page 40: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/40.jpg)
Key challenges in architecture refactoring
Getting management
buy-in
Fear of breaking working software
Lack of tool support
Merge process problems
![Page 41: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/41.jpg)
Using tools for architecture refactoring
![Page 42: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/42.jpg)
![Page 43: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/43.jpg)
![Page 44: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/44.jpg)
![Page 45: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/45.jpg)
Key take-awaysArchitecture refactoring plays a key role in enabling business success
Architecture smells and violations contribute to technical debt (known as architecture debt)
Code refactoring and architecture refactoring are altogether different ballgames
We can learn from rich experience available on architecture refactoring
Refactoring for architecture smells is an effective way to learn software architecture!
![Page 46: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/46.jpg)
“Architecture refactoring accelerates business success”
![Page 47: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/47.jpg)
Image credits• http://sustainablecitiescollective.com/pratik-dave/244831/bangalore-exclusive-metro-india-having-profit-making-public-
transport-system
• http://www.medsoftwaresys.com/mss/wp-content/uploads/2012/04/reengineering.png
• http://topnews.in/files/Bangalore-Metro-Rail-Corporation-Ltd.jpg
• https://www.itdp.org/wp-content/uploads/2014/07/Chennai-Rendering.jpg
• http://www.vectors4all.net/preview/database-clip-art.jpg
• http://static.planetminecraft.com/files/resource_media/screenshot/1231/Windows-Vs-Mac_3072108.jpg
• http://manuel.midoriparadise.com/public_html/icons/linux-icon.png
• http://mortalpowers.com/posse/1280x1280/0DSC03205.JPG
• http://images.clipartpanda.com/server-computer-clipart-1216179635943364667jcartier_central_computer_1.svg.hi.png
• http://images.clipartpanda.com/cloud-icon-png-clouds.png
• http://www.clipartbest.com/cliparts/dc6/M5L/dc6M5LBc9.jpeg
• http://cdn.ttgtmedia.com/rms/computerweekly/refactor.jpg
• http://yellowairplane.com/Adventures/Falkland_Islands_War_Guestbook/Falkands_War_Malvinas_War_Photos/Jet_Fighter_Mirage_2000_Takeoff_Argentina.jpg
![Page 48: Architecture refactoring - accelerating business success](https://reader035.fdocuments.net/reader035/viewer/2022070519/58f2ad051a28ab1b658b4593/html5/thumbnails/48.jpg)
www.designsmells.com bit.ly/sgganesh @GSamarthyam