Top Banner
Bernhard Merkle „Stop the Software Architecture Erosion“ Page: 1 Bernhard Merkle Central Research & Development Software-Engineering SICK-AG Waldkirch mailto: [email protected] Contact on linkedin.com or xing.com Stop the Software Architecture Erosion
43
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 1

Bernhard Merkle

Central Research & Development

Software-Engineering

SICK-AG Waldkirch

mailto: [email protected]

Contact on linkedin.com or xing.com

Stop the Software

Architecture Erosion

Page 2: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 2

Bernhard Merkle

Central Research & Development

Software-Engineering

SICK-AG Waldkirch

mailto: [email protected]

Contact on linkedin.com or xing.com

Note:

this is only a subset of

the presentation slides !

Page 3: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 7

Traffic and Luggage Control

Page 4: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 8

Introduction / Overview

Levels of Static Analysis

– Code, Design, Architectural

– Examples

Architectural Analysis

– Use Cases

– Tool Support,

– Examples

– Pros/Cons

Summary

Page 5: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 9

Possible levels of Static Analysis:

Micro-Level

– Code

– =, ==, { },

Macro-Level

– Class-Design

– by reference, String concat, Exception-Handling

Architecture-Level:

– Layers, Graphs, Subsystems, Compoments, Interfaces

– Coupling, Dependency, etc…

Page 6: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 13

Tool Example Java: findbugs

Page 7: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 15

Software-Architecture: Definitions

IEEE 1471-2000:

– The fundamental organization of a system,

– embodied in its components,

– their relationship to each other and the environment,

– and the principles governing its design and evolution.

Kruchten: captured in two documents:

– Software Architecture Document

– Software Design Guidelines

Page 8: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 16

Erosion ALWAYS

happens– Prototypes become products

– Hacks. Architectural restrictions ignored

– Lack of understanding the “should architecture” (e.g. outsourcing)

– Time pressure leads to abbreviations

– impossible to detect manually only

Page 9: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 17

Architectural Erosion

“Sometimes the developers manage to

maintain this purity of design through the

initial development and into the first release.

More often something goes wrong.The

software starts to rot like a piece of bad

meat”.

Uncle Bob: “Agile Software Development”

Page 10: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 18

Architectural Erosion

Why should we care ?

– In (lots of) Projects, Architecture decay happens

– We are not alone, as we‘ve some good representatives… ;-)

Page 11: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 19

Findbugs

Is there a architecture ?

Is there a erosion ?

Do AA-Tool work well ?

do codelevel lints care about architecture ?

Page 12: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 25

ONE BIG Tangle…

1.3.8

(03/2009)

Page 13: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 26

Page 14: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 27

Modeling Subsystems:

Page 15: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 28

Fixing Architectural Violations

Page 16: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 31

Fixing Architectural Violations

Page 17: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 32

Fixing Architectural Violations

Page 18: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 33

Fixing Architectural Violations

Page 19: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 34

Findbugs:

and the next level of

checking ;-)

Page 20: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 35

Tools for Architecture-Analysis

– Sotograph

– Bauhaus

– Structure101

– SonarJ

– Lattix

– Klocwork K7

– Others:

• http://code.google.com/p/architecturerules/

• Semmlecode, CodeCrawler, SeeSoft, XRadar,…

http://se-radio.net/podcast/2008-10/episode-115-arc hitecture-analysis

Page 21: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 36

Basic Approaches

– Your makesystem…

– makedepend, jdepend

– RE code into UML model

– Eclipse (Java Build Path)

Page 22: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 37

Basic Approaches

PDE Dependency Visualization

Page 23: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 38

Missing in basic approaches

Architecture Analysis (Deviation)

Drill-Down+Aggregation

Displaying results

Monitoring changes, trends

Rating of Architecture

� Requirements for Architectural Analysis Tools

Page 24: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 39

Architecture Analysis (deviation)

Should-

Architecture

Requirements

Architecture-

Design

Comparison “Diff-”

ArchitectureActions

Extraction Is-

Architecture

Existing Code

•Violations•Conformance•Dependencies as exist

•Interfaces / Usage as exist•Subsystems

•Model Dependencies•Model Interfaces•Model Subsystems

•System SHOULD be: maintainable, easy to understand, extensible, independent

•System IS: …☺

Page 25: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 40

Drill-Down + Aggregation:Component � System � Package � Class � Src-Line

Page 26: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 41

Displaying results:Graphical and/or numerical

Page 27: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 42

Monitoring changes, trends (QA)

New artefacts

– Interface, Subsystem, Package, File, Class, Operation etc.

– Dependencies

– Architecture violations

Early, betimes correction of violations

Monitoring

– Trendreports

– “outsourcing” projects

Page 28: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 43

Rating of Architecture

NO Rating of external Requirements (Fullfillment)

Internal Quality:

– Cycles

– Coupling

– Stability

– Anti-Patterns, Bad Smells

Page 29: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 49

Eclipse: Architectural Analysis

– JDT

– CDT

Page 30: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 50

Eclipse Architecture

Page 31: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 51

Eclipse Architecture

Page 32: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 53

E3.4: Runtime ���� Update

Page 33: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 54

E3.4: Workbench ���� Text, Update, Help

Page 34: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 72

CDT:

Page 35: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 75

Interface Design

more than OSGI

Well balanced arragement of…

Layout/Visualize the

calling graph � key communication

inheritance � key abstractions

Page 36: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 77

Page 37: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 78

Dependent BaseClass

– Type:

• Design Problem

– Problem:

• one of more Methods shall implement different

• behavior, depending on the type, passed in

– Context:

• make “extensible” systems, frameworks

– Forces:

• Programming languages offer, instanceof/typeid funcs.

– Antipattern:

• Methods of the baseclass, depend on derived classes, e.g. accessing their

members, doing switch/case depending on type information

Page 38: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 80

AntiPatterns / Bad Smells:

Metrics/1000 Classes Eclipse JDK

Dependent Baseclass: 1 16

Multiple Interface Inher. 4 18

Abstractable Methods 80 60

Abstractable Attributes 45 170

Unused Classes 50 150

Unused Methods 950 2500

Unused Attributes 30 20

Page 39: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 81

Code Clones

Page 40: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 82

Code Clones

– identical Files• E2.0 JDT,CDT

– jdt\debug\internal\ui\dialogfields\ListDialogField.java

– cdt\debug\internal\ui\dialogfields\ListDialogField.java

• E3.4 CDT: identical packages– cdt\debug\internal\ui\dialogfields, cdt\debug\mi\internal\ui\dialogfields

– variation of former identical Files• E34 JDT,CDT

– jdt\debug\internal\ui\dialogfields\ListDialogField.java

– cdt\debug\internal\ui\dialogfields\ListDialogField.java

– identical behaviour in different Classes• e.g. Codegeneration ;-)

– Identical behaviour in same Class• swt.graphics.ImageData.java

– static void blit(…) // four variations

Page 41: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 88

Rating Eclipse Architecture

– VERY clean

– OSGI helps a lot

– API Police

– � Technology and People

Page 42: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 89

Rating Eclipse Architecture:

Process and Tools !

– Violations

• Upper layers

• Internal access

– OSGI is not enough

– Small amount of

• AntiPatterns

• CodeCones

Page 43: Eclipse Summit 2009 Bernhard Merkle Stop The Software Architecture Erosion

Bernhard Merkle „Stop the Software Architecture Erosio n“Page: 91

Pictures under CC license from flickr:

1191285966_d701fcb1c3_b_flickr_bluemeat.jpg

3425532267_bd74526b23_b_flickr_tiwo.jpg

1813471845_5a4be999dc_o_flickr_thatcanadiangrrl.jpg

2401122677_c25dea1233_b_flickr_EnglishGirlAbroad.jpg

501709581_f3729ceaeb_b_flickr.jpg