some theory and practice on patterns – introduction · software design design ... design motifs...

153
Yann-Gaël Guéhéneuc This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 3.0 Unported License Some Theory and Practice on Patterns – Introduction NII, Tokyo, Japan 12/02/14

Upload: others

Post on 27-Mar-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

Yann-Gaël Guéhéneuc

This work is licensed under a Creative Commons Attribution-NonCommercial-

ShareAlike 3.0 Unported License

Some Theory and Practice on Patterns – Introduction

NII, Tokyo, Japan12/02/14

Page 2: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

2/153

Page 3: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

3/153

Typical software developers?

Page 4: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

4/153

Page 5: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

5/153

Software costs?

Page 6: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

6/153

Page 7: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

7/153

Page 8: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

8/153

Cost of bugshttp://www.di.unito.it/~damiani/ariane5rep.html

Page 9: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

9/153

Page 10: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

10/153

Page 11: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

11/153

Cost of qualityhttp://calleam.com/WTPF/?p=4914

Page 12: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

12/153

Agenda

QualityMaintainability

– Quality Models– Good Practices– Social Studies– Developers Studies

Impact of Quality Models Challenges with Multi-language Systems

Page 13: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

13/153

qual·i·ty noun \ˈkwä-lə-tē\ how good or bad something is a characteristic or feature that someone

or something has : something that can be noticed as a part of a person or thing

a high level of value or excellence—Merriam-Webster, 2013

Page 14: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

14/153

Quality

Division of software quality according to ISO/IEC 9126:2001, 25000:2005…– Process quality– Product quality– Quality in use

Page 15: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

15/153

Quality

Division of software quality according to ISO/IEC 9126:2001, 25000:2005…– Process quality– Product quality– Quality in use

Page 16: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

16/153

Quality

Dimensions of product quality– Functional vs. non-functional

• At runtime vs. structural– Internal vs. external

• Maintainability vs. usability– Metric-based vs. practice-based

• Objective vs. subjective

Page 17: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

17/153

Quality

Dimensions of product quality– Functional vs. non-functional

• At runtime vs. structural– Internal vs. external

• Maintainability vs. usability– Metric-based vs. practice-based

• Objective vs. subjective

Page 18: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

18/153

Quality

Definitions of internal quality characteristics– Maintainability– Flexibility– Portability– Re-usability– Readability– Testability– Understandability

Page 19: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

19/153

Quality

Definitions of internal quality characteristics– Maintainability– Flexibility– Portability– Re-usability– Readability– Testability– Understandability

Page 20: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

20/153

Maintainability is the ease with which a software system can be modified

—IEEE Standard Glossary of Software Engineering Terminology, 2013

Page 21: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

21/153

Maintainability

Quality Models Models

Good Practices Definition

Metrics

Detection Occurrences

Social Studies Characteristics

Developers Studies Behaviour

Factors

Measures

Page 22: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

22/153

Maintainability

Quality Models Models

Good Practices Definition

Metrics

Detection Occurrences

Social Studies Characteristics

Developers Studies Behaviour

Factors

Measures

Page 23: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

23/153

Quality model are models with the objective to describe, assess, and–or predict quality

—Deissenboeck et al., WOSQ, 2009(With minor adaptations)

Page 24: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

24/153

Quality Models

Division of quality models according to Deissenboeck et al.– Describe quality characteristics and their

relationships– Assess the quality characteristics of some

software systems– Predict the future quality of some software

systems

Page 25: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

25/153

Quality Models

Division of quality models according to Deissenboeck et al.– Describe quality characteristics and their

relationships– Assess the quality characteristics of some

software systems– Predict the future quality of some software

systems

Page 26: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

26/153

Quality Models

Basis for quality models – Software measures (aka metrics)– Relationships among characteristics and metrics

• Theoretical• Practical

Page 27: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

27/153

Quality Models

Metrics have been well researched– Chidamber and Kemerer– Hitz and Montazeri– Lorenz and Kidd– McCabe– …

(Do not miss Briand et al.’s surveys on cohesion and coupling metrics)

Page 28: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

28/153

Quality Models

Typical metrics– LOC– Fan-in and Fan-out– Cohesion and coupling– McCabe complexity– …

Typically computed automatically on source code or other intermediate representations

Page 29: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

29/153

Quality Models

Trend in computing metrics– Motoral– Samsung– SNCF– …

Dozens of tools– PMD– Sonar– …

Page 30: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

30/153

Page 31: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

31/153

Who needs models?

Page 32: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

32/153

Page 33: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

33/153

•130.0 Physics •129.0 Mathematics •128.5 Computer Science •128.0 Economics •127.5 Chemical engineering •127.0 Material science •126.0 Electrical engineering •125.5 Mechanical engineering •125.0 Philosophy •124.0 Chemistry •123.0 Earth sciences •122.0 Industrial engineering •122.0 Civil engineering •121.5 Biology •120.1 English/literature •120.0 Religion/theology •119.8 Political science •119.7 History •118.0 Art history •117.7 Anthropology/archeology•116.5 Architecture •116.0 Business •115.0 Sociology •114.0 Psychology •114.0 Medicine •112.0 Communication •109.0 Education •106.0 Public administration

Page 34: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

34/153

Page 35: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

35/153

Page 36: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

36/153

Measures without modelshttp://hardsci.wordpress.com/2013/09/17/the-hotness-iq-tradeoff-in-academia/

Page 37: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

37/153

Quality Models

Different input metrics, output characteristics– Menzies et al.’s models

• Code metrics• Defectiveness

– Zimmermann et al.’s models• Code and historical metrics• Fault-proneness

– Bansiya and Davis’ QMOOD• Design metrics• Maintainability-related characteristics

Page 38: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

38/153

Quality Models

Different input metrics, output characteristics– Menzies et al.’s models

• Code metrics• Defectiveness

– Zimmermann et al.’s models• Code and historical metrics• Fault-proneness

– Bansiya and Davis’ QMOOD• Design metrics• Maintainability-related characteristics

Page 39: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

39/153

Quality Models

Menzies et al.’s models– Characteristics of defectiveness

• Was the class/module involved in one fault or more?

– Three kinds of models• OneR• J48• Naïve Bayesian miner

Page 40: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

40/153

Quality Models

Menzies et al.’s models– Code metrics

• McCabe’s cyclomatic, design, essential complexities• LOC (total, blanks, comments…)• Halstead’s numbers of operands and operators (and

variations and combinations)

– Collection and validation using NASA MDP• 8 systems in C and Java

(No source code)

Page 41: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

41/153

Quality Models

Menzies et al.’s models

Page 42: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

42/153

Quality Models

Different input metrics, output characteristics– Menzies et al.’s models

• Code metrics• Defectiveness

– Zimmermann et al.’s models• Code and historical metrics• Fault-proneness

– Bansiya and Davis’ QMOOD• Design metrics• Maintainability-related characteristics

Page 43: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

43/153

Quality Models

Different input metrics, output characteristics– Menzies et al.’s models

• Code metrics• Defectiveness

– Zimmermann et al.’s models• Code and historical metrics• Fault-proneness

– Bansiya and Davis’ QMOOD• Design metrics• Maintainability-related characteristics

Page 44: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

44/153

Quality Models

Different input metrics, output characteristics– Menzies et al.’s models

• Code metrics• Defectiveness

– Zimmermann et al.’s models• Code and historical metrics• Fault-proneness

– Bansiya and Davis’ QMOOD• Design metrics• Maintainability-related characteristics

Page 45: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

45/153

Quality Models

Bansiya and Davis’ QMOOD– Characteristics of maintainability

• Effectiveness, extensibility, flexibility, functionality, reusability, and understandability

– Hierarchical model• Structural and behavioural design properties of

classes, objects, and their relationships

Page 46: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

46/153

Quality Models

Bansiya and Davis’ QMOOD– Object-oriented design metrics

• Encapsulation, modularity, coupling, and cohesion…• 11 metrics in total

– Validation using empirical and expert opinion on several large commercial systems

• 9 C++ libraries(Source code)

Page 47: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

47/153

Quality Models

Bansiya and Davis’ QMOOD

Page 48: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

48/153

Quality Models

Conclusions– Sound basis to measure different quality

characteristics

Limits– Relation between metrics and quality

characteristics, such as maintainability– Relation between metrics and what they are

expected to measure

Page 49: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

49/153

Quality Models

Limits– Relation between metrics and quality

characteristics, such as maintainability– Relation between metrics and what they are

expected to measure

Overcome by using more, diverse, unrelated information

Page 50: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

50/153

Quality Models

Feedback– Measures– Occurrences– Factors

to build “better” quality models

Page 51: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

51/153

Page 52: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

52/153

Maintainability

Quality Models Models

Good Practices Definition

Metrics

Detection Occurrences

Social Studies Characteristics

Developers Studies Behaviour

Factors

Measures

Page 53: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

53/153

Practice, practiceand practice more

Page 54: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

54/153

Page 55: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

55/153

Good Practices

Maintainers can follow good practices– SOLID– Design patterns– Design antipatterns– …

Page 56: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

56/153

Good Practices

Maintainers can follow good practices– SOLID– Design patterns– Design anti-patterns– …

Page 57: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

57/153

Each pattern describes a problem which occurs over and over in our environment, and then describes the core of the solution to that problem, in such way that you can use this solution a million times over, without ever doing it the same way twice.

—Christopher Alexander, 1977(With minor adaptations)

Page 58: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

58/153

Good Practices

Design patterns– A general reusable solution to a commonly

occurring problem within a given context in software design

Design antipatterns– A design pattern that may be commonly used

but is ineffective/counterproductive in practice

Page 59: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

59/153

Good Practices

Page 60: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

60/153

Design Patterns

Important assumptions– That patterns can be codified in such a way that

they can be shared between different designers– That reuse will lead to “better” designs. There is

an obvious question here of what constitutes “better”, but a key measure is maintainability

—Zhang and Budgen, 2012 (With minor adaptations)

Page 61: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

61/153

Design Patterns

Pattern solution = Motif which connotes anelegant architecture

Page 62: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

62/153

Design Patterns

Pattern solution = Motif which connotes anelegant architecture

Page 63: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

63/153

Design Patterns

Pattern solution = Motif which connotes anelegant architecture

Page 64: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

64/153

Design Patterns

We can identifyin the architectureof a systemsmicro-architectures similar todesign motifsto explain theproblem solved

Figure

CompositeFigureAttributeFigure PolyLineFigureDecoratorFigure

To compose objectsin a tree-like structureto describe whole–parthierarchies

Frame

DrawingEditor

Tool

Handle

Panel

DrawingView

Drawing

Figure

AbstractFigure

CompositeFigureAttributeFigure PolyLineFigureDecoratorFigure

Component

operation()

Leaf

operation()

Composite

add(Component)remove(Component)getComponent(int)operation()

ramification

For each componentscomponent.operation()

1..nClient

Page 65: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

65/153

Design Patterns

We can identifyin the architectureof a systemsmicro-architectures similar todesign motifsto explain theproblem solved

Figure

CompositeFigureAttributeFigure PolyLineFigureDecoratorFigure

To compose objectsin a tree-like structureto describe whole–parthierarchies

Frame

DrawingEditor

Tool

Handle

Panel

DrawingView

Drawing

Figure

AbstractFigure

CompositeFigureAttributeFigure PolyLineFigureDecoratorFigure

Component

operation()

Leaf

operation()

Composite

add(Component)remove(Component)getComponent(int)operation()

ramification

For each componentscomponent.operation()

1..nClient

Page 66: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

66/153

Design Patterns

We can identifyin the architectureof a systemsmicro-architectures similar todesign motifsto explain theproblem solved

Figure

CompositeFigureAttributeFigure PolyLineFigureDecoratorFigure

To compose objectsin a tree-like structureto describe whole–parthierarchies

Frame

DrawingEditor

Tool

Handle

Panel

DrawingView

Drawing

Figure

AbstractFigure

CompositeFigureAttributeFigure PolyLineFigureDecoratorFigure

Component

operation()

Leaf

operation()

Composite

add(Component)remove(Component)getComponent(int)operation()

ramification

For each componentscomponent.operation()

1..nClient

Page 67: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

67/153

Design Patterns

We can identifyin the architectureof a systemsmicro-architectures similar todesign motifsto explain theproblem solved

Figure

CompositeFigureAttributeFigure PolyLineFigureDecoratorFigure

To compose objectsin a tree-like structureto describe whole–parthierarchies

Frame

DrawingEditor

Tool

Handle

Panel

DrawingView

Drawing

Figure

AbstractFigure

CompositeFigureAttributeFigure PolyLineFigureDecoratorFigure

Component

operation()

Leaf

operation()

Composite

add(Component)remove(Component)getComponent(int)operation()

ramification

For each componentscomponent.operation()

1..nClient

Page 68: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

68/153

Design Patterns

Conclusions– Codify experts’ experience– Help train novice developers– Help developers’ communicate– Lead to improved quality

Page 69: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

69/153

Design Anti-patterns

Important assumptions– Poor design choices that are conjectured to

make object-oriented systems harder to maintain

– Yet, maybe the best and possibly only way to implement some requirements and–or some functionalities

Page 70: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

70/153

Design Anti-patterns

Problem– Problem recurring in object-oriented design

Poor solution– Initially may look like a good idea

Alternative solution– Repeatable (design pattern)– Effective

Page 71: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

71/153

Design Anti-patterns

Negatively impact– Fault proneness– Change proneness

– Comprehension

Page 72: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

72/153

Design Anti-patterns

Conclusions– Codify experts’ “bad” experience– Help train novice developers– Help developers’ communicate– Lead to improved quality

Page 73: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

73/153

Design Anti-patterns

Limits– So many patterns

– So many• Programming languages• Development contexts• Application domains• Expertises

Page 74: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

74/153

Maintainability

Quality Models Models

Good Practices Definition

Metrics

Detection Occurrences

Social Studies Characteristics

Developers Studies Behaviour

Factors

Measures

Page 75: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

75/153

Social Studies

Developers’ characteristics– Gender– Status – Expertise– Training– Processes– …

Page 76: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

76/153

Page 77: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

77/153

Agile programming,anyone?

Page 78: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

78/153

Page 79: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

79/153

Social Studies

Need for social studies, typically in the form of experiments– Independent variable (few)– Dependent variables (many)– Statistical analyses (few)

– Threats to validity (many)

Page 80: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

80/153

Social Studies

For example, impact on identifiers on program understandability– Identifier styles [Sharif, Binkley]

– Identifier quality [Lawrie]

– Developers’ gender and identifiers [Sharafi]

– …

Page 81: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

81/153

Social Studies

For example, impact on identifiers on program understandability– Identifier styles [Sharif, Binkley]

– Identifier quality [Lawrie]

– Developers’ gender and identifiers [Sharafi]

– …

Page 82: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

82/153

Social Studies

Independent variables– Gender: male vs. female– Identifier: camel case vs. underscore

Dependent variables– Accuracy

– Time

– Effort

Page 83: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

83/153

Social Studies

Subjects

Conclusions

Subjects’ Demography(24 Subjects)

Academic background GenderPh.D. M.Sc. B.Sc. Male Female

11 10 3 15 9

Accuracy Time Effort

Page 84: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

84/153

Social Studies

Importance

Limits– Confounding factors– Actionable results?

Page 85: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

85/153

Maintainability

Quality Models Models

Good Practices Definition

Metrics

Detection Occurrences

Social Studies Characteristics

Developers Studies Behaviour

Factors

Measures

Page 86: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

86/153

Developers Studies

Developers’ thought processes– Cognitive theories

• Brooks’• Von Mayrhauser’s• Pennington’s• Soloway’s

– Mental models• Gentner and Stevens’ mental models

– Memory theories• Kelly’s categories• Minsky’s frames• Piaget’s schema• Schank’s scripts

Page 87: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

87/153

Developers Studies

Studying developers’thought processes– Yarbus’ eye-movements

and vision studies– Just and Carpenter’s

eye–mind hypothesis– Palmer’s vision science– …

Page 88: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

88/153

Developers Studies

Picking into developers’ thought processes

Page 89: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

89/153

Developers Studies

Picking into developers’ thought processes

Page 90: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

90/153

Developers Studies

Picking into developers’ thought processes

Page 91: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

91/153

Developers Studies

Developers’ thought processes– Reading code– Reading design models

• Content• Form

– …

Page 92: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

92/153

Developers Studies

Developers’ thought processes– Reading code– Reading design models

• Content• Form

– …

Page 93: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

93/153

Developers Studies

Developers’ use of design pattern notations during program understandability– Strongly visual [Schauer and Keler]

– Strongly textual [Dong et al.]

– Mixed [Vlissides]

Page 94: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

94/153

Developers Studies

Independent variables– Design pattern notations– Tasks: Participation, Composition, Role

Dependent variables– Average fixation duration– Ratio of fixations– Ration of fixation times

Page 95: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

95/153

Developers Studies

Subjects– 24 Ph.D. and M.Sc. students

Conclusions– Stereotype-enhanced UML diagram [Dong et al.]

more efficient for Composition and Role– UML collaboration notation and the pattern-

enhanced class diagrams more efficient for Participation

Page 96: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

96/153

Developers Studies

Importance– Understand– Do better

Limits– Confounding factors– Actionable results?

Page 97: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

97/153

Impact of Quality Models

Usefulness of the feedback? Usefulness of the models?

Page 98: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

98/153

Feedback?

Trend to use more, diverse, unrelated information as input of quality models– Code source metrics– Historical metrics– Design metrics

– Historical metrics– Good practices– Social studies– Developers’ studies

Page 99: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

99/153

Page 100: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

100/153

Modeling formodeling's sake?

Page 101: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

101/153

Aristotle384 BC–Mar 7, 322 BC

Page 102: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

102/153

Aristotle384 BC–Mar 7, 322 BC

Galileo GalileiFeb 15, 1564–Jan 8, 1642

Page 103: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

103/153

Aristotle384 BC–Mar 7, 322 BC

Galileo GalileiFeb 15, 1564–Jan 8, 1642

Isaac NewtonDec 25, 1642–Mar 20, 1727

Page 104: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

104/153

Aristotle384 BC–Mar 7, 322 BC

Galileo GalileiFeb 15, 1564–Jan 8, 1642

Isaac NewtonDec 25, 1642–Mar 20, 1727

Max TegmarkMay 5, 1967–

Page 105: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

105/153

Aristotle384 BC–Mar 7, 322 BC

Galileo GalileiFeb 15, 1564–Jan 8, 1642

Usefulness?

Isaac NewtonDec 25, 1642–Mar 20, 1727

Max TegmarkMay 5, 1967–

Page 106: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

106/153

Usefulness?

DSIV– SNCF IT department– 1,000+ employees – 200+ millions Euros– Mainframes to assembly to J2EE

– 2003• Quality team

Page 107: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

107/153

Usefulness?

MQL– Dedicated measurement process

Page 108: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

108/153

Usefulness?

MQL– Web-based reports

Page 109: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

109/153

Usefulness?

Independent variables– Use of MQL or not– LOC; team size, maturity, and nature

Dependent variables– Maintainability, evolvability, reusability,

robustness, testability, and architecture quality– Corrective maintenance effort (in time)– Proportions of complex/unstructured code and of

commented methods/functions

Page 110: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

110/153

Usefulness?

Subjects– 44 systems

• 22 under MQL (QA=1)• 22 under ad-hoc processes (QA=0)

Page 111: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

111/153

Usefulness?

Page 112: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

112/153

Usefulness?

Page 113: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

113/153

Usefulness?

Page 114: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

114/153

Usefulness?

Page 115: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

115/153

Usefulness?

Conclusions– Impact on all dependent variables – Statistical practical significance

Limits– Applicability to today’s software systems

Page 116: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

116/153

Page 117: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

117/153

What’s with today’s systems?

Page 118: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

118/153

Page 119: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

119/153

Page 120: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

120/153

Page 121: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

121/153

Page 122: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

122/153

Page 123: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

123/153

Page 124: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

124/153

Page 125: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

125/153

Page 126: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

126/153

Page 127: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

127/153

Page 128: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

128/153

Multi-language Systems

Today’s systems are multi-languages– Facebook– Twitter– …

– Even your “regular” software system is now multi-language, typically a Web application

Page 129: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

129/153

Multi-language Systems

New problems– Different computational models– Complex interfaces (API)– Wrong assumptions– Wrong conversions– …

Page 130: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

130/153

Multi-language Systems

For example, control- and data-flows between Java and “native” C/C++ code

native methods in Java are used by Java classes but (typically) implemented in C/C++

Page 131: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

131/153

Multi-language Systems

Control-flow interactions– Java code calls native code– Native code calls Java methods– Native code can “throw” and must catch

exceptions Data-flow interactions

– Java code passes objects (pointers)– Native code creates objects– …

Page 132: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

132/153

Multi-language Systems

Different computational models

Page 133: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

133/153

Multi-language Systems

Different computational modelsstatic void *xmalloc(JNIEnv *env, size_t size) {

void *p = malloc(size);if (p == NULL)

JNU_ThrowOutOfMemoryError(env, NULL);return p;

}

#define NEW(type, n) ((type *) xmalloc(env, (n) * sizeof(type)))

static const char *const *splitPath(JNIEnv *env, const char *path) {...pathv = NEW(char *, count+1);pathv[count] = NULL;...

}

Page 134: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

134/153

Multi-language Systems

Different computational modelsstatic void *xmalloc(JNIEnv *env, size_t size) {

void *p = malloc(size);if (p == NULL)

JNU_ThrowOutOfMemoryError(env, NULL);return p;

}

#define NEW(type, n) ((type *) xmalloc(env, (n) * sizeof(type)))

static const char *const *splitPath(JNIEnv *env, const char *path) {...pathv = NEW(char *, count+1);pathv[count] = NULL;...

}

No diversion of control flow!

Page 135: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

135/153

Page 136: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

136/153

What challenges?

Page 137: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

137/153

Unbalanced focus on “mono”-language systems vs. multi-language systems

Page 138: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

138/153

Challenges

Maintainability– Quality models

• Metrics?• Relations?

– Good practices• “Border-line” practices?

– Social and developers’ studies• Independent variables?

Page 139: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

139/153

Challenges

Not only for quality assurance!(Just for examples…)

Page 140: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

140/153

Challenges

Not only for quality assurance!(Just for examples…)

Build systemsdescriptions

Page 141: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

141/153

Challenges

Not only for quality assurance!(Just for examples…)

Build systemsdescriptions

Legal issues dueto interrelations

Page 142: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

142/153

Challenges

Not only for quality assurance!(Just for examples…)

Clone definitionand detection

Build systemsdescriptions

Legal issues dueto interrelations

Page 143: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

143/153

Challenges

Not only for quality assurance!(Just for examples…)

Clone definitionand detection

Build systemsdescriptions

Legal issues dueto interrelations

Impact on studiesof large systems

Page 144: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

144/153

Page 145: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

145/153

Conclusion

Page 146: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

146/153

Page 147: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

147/153

Page 148: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

148/153

Page 149: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

149/153

Page 150: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

150/153

Future directions

Page 151: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

151/153

Page 152: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

152/153

Page 153: Some Theory and Practice on Patterns – Introduction · software design Design ... design motifs to explain the problem solved Figure AttributeFigure DecoratorFigure PolyLineFigure

153/153

Multi-language system quality characteristics

– Definition and modelling– Computation– Characterisation– Impact