Sanierung grosser Software Systeme - UZH00000000-0476-116c... · Sanierung grosser ! Software...
Transcript of Sanierung grosser Software Systeme - UZH00000000-0476-116c... · Sanierung grosser ! Software...
Sanierung grosser !Software Systeme!Sibylle Peter, Dr. Dieter Holz!Canoo Engineering AG!Basel, Switzerland!
www.canoo.com 2
Sibylle Peter Dieter Holz
www.canoo.com
Inhalt
๏ Einführung
๏ Die Fallstudie: Investionsberatung für Kundenberater
๏ Die Sanierung
๏ Wie wir arbeiten
๏ Wie wird ein Sanierungsprojekt ein Erfolg?
Einführung
www.canoo.com
Sanierungsprojekte
www.canoo.com
Sanierungsprojekte
6
www.canoo.com
Definition (Martin Fowler, Refactoring, pg. 53):
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 it‘s observable behavior
Sanierung durch Refactoring
www.canoo.com 8
www.canoo.com
Software Entropie
9
www.canoo.com
Software Entropie
10
www.canoo.com
Software Entropie
11
Die Fallstudie
www.canoo.com
www.canoo.com
Facts
๏ Produktiv und erfolgreich seit 2004
๏ Kontinuierlich weiterentwickelt
๏ 320 JSP Dateien, 1800 Klassen
๏ Ca 70. funktionale Tests
๏ Wenig Unit Tests
๏ Wenig Dokumentation
๏ Hohe Fluktation, hohe Kosten, Change Requests können nicht mehr implementiert werden.
Start: Erste Analyse
15
www.canoo.com
Abhängigkeiten
16
www.canoo.com
Objekttypen
17
Action
Java Beans
JSP
ServiceInvoker
Service
Worker
Controller Helper
Mapper
Container
HttpServlet
BusinessObject
HttpServlet
www.canoo.com
Masterplan
18
Action
Java Beans
JSP
Container
HttpServlet
BusinessObject
Facade TransferObject
HttpServlet
Util
Service Mapper
www.canoo.com
Masterplan
19
Java Beans
Service Mapper
Validator
Facade TransferObject
Action
JSP HttpServlet
Formatter
Aggregating Facade
Refactoring Teil 1
20
www.canoo.com
Ziel: Neues Service Layer
21
www.canoo.com
1. Schritt Strukturierung in Fassaden
22
www.canoo.com
2. Schritt: Einführung von Transfer Objekten (TO)
23
Presentation!Layer!
transfer objects!
JSP Java Bean Action HttpRequest
BusinessObject Converter
TransferObject
Facade
Service
Service!Layer!
www.canoo.com 24
public class User extends CoreObject { private String id; private Employee userIdentity; private RoleBUManager m_roleBUManager = new RoleBUManager(); private boolean isAllowed = false; private String eMailTask; private Timestamp mutTimestamp; private String mutId;
public final class UserTO { private final String fId; private final String fEamCode; private final String fBuCode; private final String fDepartment;
www.canoo.com 25
Presentation!Layer!JSP Java Bean Action HttpRequest
BusinessObject Converter
TransferObject Service!Layer!
ServiceObject
EJB Proxy
simple!
complex!
1:1!
1:n! Mapper
www.canoo.com 26
Presentation!Layer!JSP Java Bean Action HttpRequest
BusinessObject Converter
TransferObject Service!Layer!
ServiceObject
EJB Proxy
simple!
complex!
structural logic m:n!
1:1! Mapper
www.canoo.com
Validierung
27
public final class AARefCurrencyTO { ... public AARefCurrencyTO(UID<AARefCurrencyTO2> uid, String eamCode, final BigDecimal manual, BUCode buCode, MutSeqNr mutSeqNr, BigDecimal sortOrder, Long language, String name) { // Preconditions: if (uid == null) throw new IllegalArgumentException(...); ... if (language > 4) throw new IllegalArgumentException(...);
// Assignments: this.uid = uid; ... }
www.canoo.com
Fassaden Interface
28
public static FrontpageText getFrontpageText (CriteriaToGetFrontpageText criteria)
throws CoreException
public CriteriaToGetFrontpageText(String buCode, User user, int entryFrom)
public static FrontpageTextTO getFrontpageText (String buCode, UserTO user)
throws CoreException
www.canoo.com
3. Schritt: Neues Service Layer
29
inTO! outTO!
Service!
www.canoo.com
Service Interface und AbstractService
30
public interface IService<TOI, TOO> { public TOO execute(TOI toi) throws CoreException; }
public abstract class AbstractService<TOI, SOI, SOO, TOO> implements IService<TOI, TOO> { public final TOO execute(final TOI toi)
throws CoreException { if (toi == null) { throw new IllegalArgumentException(“'toi' must not
be null"); } SOI soi = mapInput(toi); SOO soo = innerExecute(soi); return mapOutput(soo); }
protected abstract SOI mapInput(TOI toi); protected abstract SOO innerExecute(SOI soi)
throws CoreException; protected abstract TOO mapOutput(SOO soo); }
www.canoo.com
Aggregierende Service Klassen
31
inTO! outTO!
Services!
inTO A! outTO A!
Service A!
Service!
inTO B! outTO B!
Service B!
www.canoo.com
4. Schritt: Einführung von Basis Typen
32
// Usage example: BUCode buCode = BUCode.getFlyweight("0012");
www.canoo.com
Fassaden Interface
33
public static FrontpageTextTO getFrontpageText(BUCode buCode, EAMCode eamCode, UserTO user) throws CoreException
public static FrontpageTextTO getFrontpageText(String buCode, String eamCode, UserTO user) throws CoreException
www.canoo.com
Resultat nach Teil 1
34
34
Old Presentationlayer
Converter
New Servicelayer Architecture!
Design Guidelines for - Services
- TransferObjects - Basetypes
New Feature:!
RiskAnalyzer!
Change Request:!CoSa!
Refactoring von Komponenten
www.canoo.com
Current State
36
New Servicelayer Architecture!
New Business Layer
Old Presentationlayer
Converter Presentation Layer
Domain Layer
Refactored Components New Features
Old GUI Framework
www.canoo.com
Domain Model Adapters
37
public class MonitoredHoldingDO extends AbstractHoldingDO implements IMonitoredHoldingDO {
public MonitoredHoldingDO(final Holding holding) { super(holding); }
@Override protected BOInfo getBOInfo() { return new BOInfo(getHolding().getWorkingTIS(), getAssetsFromHolding (), getSafekeepingAccountsFromHolding()); }
private ImmutableMap<Integer, Asset> getAssetsFromHolding() { return HoldingDOBuilderUtil.getTisIncludedAssetsFromHolding
(getHolding(), getHolding().getWorkingTIS()); } … }
www.canoo.com
Komponente Load Partner
38
www.canoo.com 39
Vorgehen
๏ Code aufräumen ‣ IDE Vorschläge umsetzen (Remove unused code etc)
๏ Überschaubare Einheiten erstellen ‣ Mit Extract Method Refactoring Methoden herausziehen ‣ Abhängigkeiten zu Attributen entfernen (static methods) ‣ Move Refactoring benutzen, um diese Methoden in einer Hilfklasse
zwischenzulagern
www.canoo.com 40
Vorgehen
๏ Analyse der neuen Einheiten und Design gemäss der Zielarchitektur
๏ Akzeptanz Tests definieren und mit BBD Frameworks implementieren
www.canoo.com
Akzeptanztest
41
scenario "DictionaryService can find the word 'Griffon'", { given "an instance of DictionaryService is available", { service = new DictionaryService() }
when "the word 'Griffon' is used as parameter", { result = service.findDefinition('Griffon') }
then "the definition should be found", { assert result == "Grails inspired desktop application development platform.” } }
www.canoo.com
Akzeptanztest mit EasyB
42
www.canoo.com 43
Vorgehen
๏ Refactoring ‣ Wenn noch nötig, Mikado Methode anwenden
๏ Messen der Code Qualität
www.canoo.com
Sonar Dashboard
44
Voraussetzungen für erfolgreiche Sanierungsprojekte?
www.canoo.com
Wie wir arbeiten
Daily standup meeting!
Regular workshops with the customer‘s lead engineer!
Retrospective in regular
intervalls!
Lightweigth, but intensive testing process with test
team
Monthly meeting with the project manager of the
customer
Weekly reporting with the lead engineer and
architect of the customer
www.canoo.com
Team
Experienced, dedicated developers
motivation
A disciplined approach
team size.
A lead engineer of the customers
side
www.canoo.com
Authorität und Flexibilität
48
Management support
Accepted by the team
The customers trust Flexible,
iterative planning
Involved in system design
www.canoo.com
Weitere Voraussetzungen
49
Continuous Integration
Assessment Master Plan
Automated Integration
Tests
Good Analysis Tools
www.canoo.com
Erkenntnisse oder Best Practices
๏ Entweder technisches oder logisches Refactoring
๏ Analyse – Implementierung – Stabilisation
๏ Früher Wissenstransfer zum Core Team
๏ Investition in automatische Regressionstest
๏ Abhängigkeiten zu anderen Systemen reduzieren
๏ Automatische Qualitätssicherung
๏ Manuelles Testing braucht Zeit – genügend Zeit einplanen
50
www.canoo.com
Nachhaltigkeit
๏ Code verbessern ist nicht genug
๏ Professionelle Ethik einführen
๏ Technische Schulden überwachen und ggf. beseitigen
๏ Continous Improvement: Retrospektiven
๏ Core Team muss unterstützt werden, damit neue Funktionalität in guter Qualität ausgeliefert wird.
51
www.canoo.com
Warum Sanierungsprojekte?
52
www.canoo.com
Bücher und Links
๏ Martin Fowler, Refactoring: Improving the Design of Existing Code
๏ Stephan Ducasse, Oscar Nierstrasz, Object Oriented Reengineering Patterns PDF: http://www.win.ua.ac.be/~sdemey/
๏ Joshua Kerievsky, Refactoring to Patterns
๏ Martin Lippert, Stefan Rook, Refactoring in Large Software Projects
๏ Behaviour Driven Development: ‣ EasyB: http://www.easyb.org/ ‣ Spock: http://code.google.com/p/spock/
๏ Sonar: http://www.sonarsource.org/
๏ Mikado Method: http://pragprog.com/magazines/2010-06/the-mikado-method
53
www.canoo.com
Master Thesis @ Canoo
54
www.canoo.com
Master Thesis @ Canoo
55