Study on Aspect Extraction and Program Analysis for Effective Software Development - PowerPoint PPT Presentation

About This Presentation
Title:

Study on Aspect Extraction and Program Analysis for Effective Software Development

Description:

Title: Study on Aspect Extraction and Program Analysis for Effective Software Development Author: t-isio Last modified by: t-isio Created Date – PowerPoint PPT presentation

Number of Views:84
Avg rating:3.0/5.0
Slides: 97
Provided by: tis58
Category:

less

Transcript and Presenter's Notes

Title: Study on Aspect Extraction and Program Analysis for Effective Software Development


1
Study on Aspect Extraction and Program
Analysisfor Effective Software Development
???????????????????????????????????
  • ?? ?
  • ?????D3
  • t-isio_at_ist.osaka-u.ac.jp

2
??????????????
  • Gregor Kiczales ??????? (ECOOP 1998)
  • ?? ???????????
  • Separation of Crosscutting Concerns
  • ????????????????????
  • AspectJ ??? Java ???????????
  • Java ?,????????????????????
  • ??????,???????????????????

3
?????
  • ??????????????,???
  • 1???????????1????????????
  • (?????) ????????????????
  • (???) ?????????????
  • (??????) ?????????????????
  • ??????
  • ???????,??????????????????????
  • ? ?????????????????????
  • ??????????????????????????

4
?????????????????
  • ?????????????
  • ????? ?????????????,?????????????

??????????? ??????????? logs ?????
Class Line setColor
Logging Aspect
Class Logger logs()
Class Circle setRadius setColor
????,Line, Circle ?????????????
5
?????????????????
  • ???,???????????????
  • ??????????????????????????????
  • ? ?????????????,?????????????
  • ???,?????????????????,??????????
  • ?????????????????????????????
  • ?????,??????????????
  • ? ???,???????

6
????????
  • Development Aspect
  • ????????????????????
  • ????,?????????
  • Production Aspect
  • ????????????????
  • ?????(??????),????????????
  • Runtime Aspect
  • ????????
  • ?????,???????

7
?????
  • ???????????????
  • Runtime Aspect ?????????????
  • ???????????????????,
  • ???????????????????????
  • Production Aspect ?????
  • ???,?????????????????????
  • Development Aspect ????????????
  • ????,???????????

8
???????
  • Development Aspect ???????????????
  • ????????,????????????????
  • ?????????????????????
  • ??,????????????,????????
  • ?Development Aspect ????????,
  • ????????????????????
  • 2????????????,????????????
  • ??????????
  • ?????????????

9
?????????
  • ???,?????????????????
  • ??????????????
  • Fragile Base-Code Problem
  • ???????????????????????????????
  • ? ?????????????,???????????
  • AspectJ ???,?????????
  • ?????????
  • Inter-aspect problem
  • ??????????????????????????????
  • (????????)

10
????????
  • ?
  • ?????????????????,
  • ????????????????????????,
  • ????????????????????,
  • ???????????????????????
  • ?????????,????????????

Logger
Logging
Database
call
A client
Encryption
11
?????
  • ??????????????
  • ????????,??????,?????????
  • ?????????????????
  • ????,????????(?????)??????????
  • ? ???????????????????????
  • ????????????????????????????
  • ?????????????????????????
  • ????????????,???????????????????????????

12
????????
  • 2?? Development Aspect ???
  • ??????????
  • ?????????????
  • ???????????????????????
  • ??????,??????????
  • ????????????????????
  • ??????????????????????
  • ?????????????????????
  • AspectJ ???????????????

13
?????
  • 1? Introduction
  • 2? Dynamic Analysis for Program Slicing using
    Aspect-Oriented Technique
  • ?? 2, 7
  • ???????????????????????
  • 3? Modularization of Assertions Crosscutting
    Objects
  • ?? 3, 6
  • ????????????????.
  • 4? Debugging Support for Aspect-Oriented Program
    Based on Program Slicing and Call Graph
  • ?? 1, 5
  • ??????????????????????
  • 5? Conclusions

14
????????(??) ??????
  • Development Aspect
  • ????????????????????
  • ????,?????????
  • Production Aspect
  • ????????????????
  • ?????(??????),????????????
  • Runtime Aspect
  • ????????
  • ?????,???????

15
???????? ??????
  • Homogeneous Aspect
  • ???????????
  • ?????????????????
  • ???,?????????,????????????
  • Heterogeneous Aspect
  • ????????????,?????????????
  • ???????????
  • ???????????????
  • ??????????
  • ???????????????
  • ??????????

1???????? ?????? ????
16
?????????? (1/2)
  • ?????
  • ?????????????????????
  • Role-based Design ?????
  • ? Observer ????????????????
  • Observer Role ? Subject Role ?????????
  • Subject ????????? Observer ?????
  • ?????????? Role ??????
  • Window ? Observer ?,File ? Subject ?
  • Role ????????????????
  • ??????????????????????

Tamai, T., Ubayashi, N. and Ichiyama, R. An
Adaptive Object Model with Dynamic Role Binding.
Proceedings of ICSE2005, St. Louis, Missouri,
USA, May, 2005.
17
?????????? (2/2)
  • ??????????????
  • ???????(?????)??????
  • ???????????????????????????
  • ????????????
  • ?????????????,??????????
  • ????????????????,??????????

??
??
??
??
??
Elisa Baniassad and Siobhan Clarke Theme An
Approach for Aspect-Oriented Analysis and Design.
Proceedings of ICSE 2004, pp.158-167, Edinburgh,
Scotland, UK, May 2004.
18
??????????????
  • ??????????????????????,
  • ????????
  • AspectJ ???????,???????????????????
  • ????????????,Java ?????????????
  • ?????,?????????????????
  • ???????????????????????????????????????????

19
????????? AspectJ
  • Java ?,??????????????????
  • ??????,???,???????????
  • ???????????????????????
  • ??
  • ??????? ??????????????
  • ????? set ?????????????????
  • ????? ?????????????
  • ?????,???????????????????
  • AspectJ ??????????,???????????????????????

20
??????????
  • ????????????????????????
  • ????????,Join Point ???????????
  • Join Point ?????????????
  • ?????????,Join Point ????????????
  • ?????? Join Point
  • ???????? (call)
  • ??????? (execution)
  • ???????? (get)
  • ????????? (set)
  • AspectJ ???,????,?????????????????????????????????
    ??

21
????????
  • ???????????????(????)????
  • ?????,????????? (before)
  • ?????,????????? (after)
  • ?????,????????? (around)
  • ??????????????????????
  • before() pointcut_definition

22
AspectJ ??????????
  • before() call( .set(..))
  • Logger.logs(thisJoinPoint.getSignature())

thisJoinPoint ? Join Point ? ???????????

???? set ????????? ????????
23
3? ??????????????
  • ??(??????)??
  • ?????????????????????

Java ???? Assert ? assert ( Boolean expression
) assert( true ) ?? assert( false )
?????,????????
24
????????????
  • ???,??????????(????,??????)?????????????

????
? double sqrt (int x) assert( x gt 0
) double result / ?? / assert( result
result lt x ) assert( result result gt x-1
) return result
????
25
?????
  • ??????????????
  • ??????? (Design by Contract)
  • ???????????????????
  • ?????,????????
  • ?????,???????
  • ??????????????????????????
  • ?????????????
  • ?????????????????????????
  • ????????????????????????
  • ?????,???????????????????

26
?????
  • ???????????????????????
  • ????????,???????
  • ??????????????
  • Observer ?????,?????
  • ???????,Observer ?????????????
  • ??????????????

27
Motivating Example Observer ????
Subject attach(observer) detach(observer)
Observer update()
attach, detach
update
? ?? ????
??????????? ??????
  • observer ? subject ????????
  • 2. subject ?,?????????, observer ?????
  • 3. observer ?,???????????????

28
1 subject -to- N observers ??
  • 1 subject to N observers ???
  • Observer 1?? ??? Subject ??????????
  • Observer ??????????????????
  • ? Subject ?,Observer ??????????????

????
Subject 1
Observer 1
Subject 2
Observer 2
29
??????????
  • Observer ?????????? subject ?????? Observer
    ????????
  • Subject.attach ???????????,???????????????????,???
    ??????????

30
???????????
  • Observer ???????????????
  • Subject ???? attach ????,detach ??????? Observer
    ???????????????
  • Observer ???????????????????

attach
Subject
Observer
must not modify
read/write
subject
31
???????????????
  • ?????????,????????
  • AspectJ ???????????,???????????????????
  • AspectJ ?????
  • ?????????
  • ???????????????????????????
  • ??????? ?????????????assert????,?????
  • ?????,?????,?????????
  • ???????,??????????????????
  • ???????????????????

32
???????????
  • Observer ?????????,
  • ???????????????????????

33
?????????????????
  • ???????,??????????,????????????????????
  • ????,?????????????????,?????????????????
  • Observer ????????,Observer ?????????? subject
    ?????
  • ?????????????,??????
  • subject ??????,????????????,???????????????
  • ? Observer ?????,Subject ????????????

34
?????????????
  • ??????????????????????
  • ??????????????????????????????????????
  • ????????????????????,?????????
  • ????????????????????????????

Experimental Code
Strict checking aspect
A component
Well-tested Component
35
??????????? (1/2)
  • ???????
  • ????,??/??????
  • ?????????????????,?????????
  • ??????????????
  • ????????????,??????????
  • AspectJ ?,?????????????
  • ??????????????????

36
??????????? (2/2)
  • ?????????????????
  • ?????????(????)???
  • ???????????,????????
  • ? ???????????????
  • ???,?Stack.push ?????????????
  • ???? ?Stack.size 0 ?? Stack.size gt 0 ???????

????? ????????
?????????
Size 0
Size gt 0
?????????????? ????????????
37
???????????????
  • ???????????
  • ?????????????????
  • AspectJ ???
  • ?????????????????????????
  • ??????? AspectJ ?????????????
  • ?????????????????????????
  • AOP Alliance
  • ???????????????????????
  • ????????????????????????

38
??????????
  • AspectJ ??????????????
  • ????????????????????????
  • ????????????,????,10???????
  • ???????????????????
  • ?????????????????????
  • ????????????????????
  • ????????????????????????

Erik Hilsdale, Jim Hugunin Advice Weaving in
AspectJ. Proceedings of AOSD 2004, pp.26-35,
Lancaster, UK, March 2004.
39
3?????
  • ????????????????????
  • ??????,???????????????
  • ???????,??????????????
  • ???????????????????
  • ???????1???????????????
  • ??????????????????,?????????

40
4? ????????????????????
  • ??????????
  • ????????????????????????????
  • ???????????????????????
  • ????????????????????
  • ????,??????????????????????????
  • ????????????,???????,???????????????,?????????????
    ????????,??????????

41
????????? (??)
  • ? ?????????????????,
  • ????????????????????????,
  • ????????????????????,
  • ???????????????????????
  • ?????????,????????????

Logger
Logging
Database
call
A client
Encryption
42
????????????
  • ???????????????,??????????????
  • ????
  • ????????????????????????,??????,?????????????????
  • ???????,??????????????????????????,??????????,????
    ????????

43
?????????????????
  • ?????,????????????????
  • AspectJ ?? precedence ????????
  • ????????????,????????????????????????
  • ?????????????
  • ???????????????????????,?????,????????,??????????
  • ?????,???????????????

44
????????????
  • ?????,???????????????????????????????????
  • ??????????????????????
  • ???????????????
  • ???,?????????
  • ?????????????????????????????????????????

45
??????????????
  • ???????????????????
  • ????????,?????????????????????,????????,????????
  • ?????????????
  • ?????????????
  • ?????????????????
  • ????????,????????????????????
  • ????????????????,????????,????????????????????????

46
????????????
  • ?????????s?????v(??????lts,vgt)??????????????
  • ?? ??-?? ??, if ???????
  • ?????????,??????????????

1 a 5 2 b a a 3 if (b gt 0) 4 c
a 5 6 d b
a
1 a 5 2 b a a 3 if (b gt 0) 4 c
a 5 6 d b
a
??lt 6, b gt
b
??
b
47
????????????
  • ???????
  • ??????? ?? ? ??
  • ?????(?????)? ?? ? ??
  • ??????
  • ????????? ? ??????
  • ??????????
  • ????????? ? ????????????
  • ????????????? ? ??????????????
  • ?????????? ? ?????????
  • ?????????? ? ????????????????

48
?????????????
Class Line setColor
Logging Aspect
??
Class Logger logs()
Class Circle setRadius setColor
Class Line setColor
Aspect Logging before_call()
??
???????????? ????????? ???????,????
Class Circle setRadius setColor
Class Logger logs()
49
???????
  • ??????????
  • ??????????????????????????
  • ??(???)?? ?????
  • ?????????,???????????????????

50
??????????
  • ?????? Eclipse ????
  • ????????????????
  • ???????????????????
  • ??????????????????
  • ?????????
  • ??????????????????
  • ????????????????????????
  • ???????????????????????

51
????????????????
?????????????
52
????
  • AspectJ ??????????????
  • 5????????????????
  • ??????,???????????????????????
  • ??12??????????
  • AspectJ ?????????????????
  • 4??????????1??,??1???????
  • 12??,6??,???????????????

53
?? (1/2)
  • ??????????,??????
  • ???????,???????????????????????
  • ???????????????????,??????????????
  • ????????,???????????????????
  • ??????????????????????
  • ??????,??,???????????????,????????????????????????
    ?

54
?? (2/2)
  • ???????????
  • ???????????,???????????
  • ????????????????????,?????????????????????,???????
    ?
  • ?????????
  • ??????????????????????????????,?????????????????
  • ? ???????,????????????????
  • ?????????????????????

???,?? ????????????????????????. ??????????????
????????????(PPL2005) ???.
55
4?????
  • ???????????????????
  • ??????????????
  • ?????,??????????????
  • ?????????,?????????????????
  • ????,??????????????????
  • ???????
  • ???????,????????????????????????????
  • ????????????????????????

56
???????????????
  • ?????????????????????
  • ?????????????????
  • ??????????????,??????????????
  • CK????????
  • ????? ? ?????????????
  • ??? Coupling Between Objects ???
  • 1????????????????????????,???????
  • ??? Lack of Cohesion ???
  • 1???????????????????????,?????????????????????????
    ???(???????)

Sant Anna, C., Garcia, A., Chavez, C., Lucena,
C. and Von Staa, A On the Reuse and Maintenance
of Aspect-Oriented Software An Assessment
Framework. Proceedings of XVII Brazilian
Symposium on Software Engineering, Manaus,
Brazil, 2003.
57
??????????
  • ????? ?????????
  • 1??????????????????????
  • ?????
  • 1????????????
  • ??????????
  • ??????????
  • ??????????
  • 1?????(?????)?
  • ????????????

Kassab, M., Ormandjieva, O. and Constantinides,
C. Providing Quality Measurement for
Aspect-Oriented Software development. Proceedings
of AO-ASIA Workshop, Taipei, Taiwan,
December 2005.
58
????????????
  • ??????????????
  • ???????????????,?????????
  • 1?????????????????????????
  • CK???????????????????
  • RFC (Response For a Class)
  • ????????????????????????
  • ???,????????
  • ??????????????
  • ??????????,????????????
  • ?????????????,????????

Shiu Lun Tsang, Siobhán Clarke, Elisa
Baniassad Object Metrics for Aspect Systems
Limiting Empirical Inference Based on Modularity.
Trinity College Dublin technical report. 2004.
59
???
  • ??????????????
  • ??????????????
  • ?????????????????
  • ???????? Development / Production / Runtime
    Aspect
  • Development Aspect ?????????????????
  • Development Aspect ?,?????????????????????
  • ??????????
  • ?????????????
  • Production / Runtime Aspect ??????,???????????????
  • ???????????????????????????????

60
???????????????????
  • ???????????????????????
  • ????????????????????????
  • ?????????????????????,????????
  • ?????????????????????????????????
  • ????????????????
  • ???????????????,???????????????????????
  • ????????????????????
  • ???,????????,??????????

61
?????
  • ????????????????
  • ????????????????
  • Early Aspects
  • ???????????
  • ????????????????????
  • Aspect-Oriented Modeling
  • ?????????
  • ???????????????
  • ????????????????
  • Aspect-Oriented Programming
  • ?????????????
  • ???????????

62
??????????
  • ???????????????
  • ? ??????????????????
  • ?????????,???,???????
  • ??????????????
  • ?????????????????????
  • ??????,??????????????????????
  • ????????,????????,?????????????????????

63
????
  • ??????/??
  • ???????????????
  • ??????,????????????????
  • ????????,???????????????
  • ???????????
  • 1??????????????????????????,
  • ????????????????????????
  • ???????????????????????????
  • ?????????????
  • ????????????????
  • ????????,??????????????????

64
?????????
  • ??1???????????,??????????????

Logger
Logging
Database
call
A client
Database
call
A client
Encryption
65
  • ?

66
(No Transcript)
67
  • ????

68
  • AOP??

69
???????????
  • ?????? ??????????????????
  • ??????????????????????
  • ? ??? set ????????????????

??????,????????
Class Line setColor
Logger.logs(methodName)
Class Logger logs()
Class Circle setRadius setColor
???????????? ? ?????????
70
????????????
  • ????????????????????????,
  • ?????????????????
  • ??????????????????????
  • ???????????????????????
  • Join Point Model ???

71
Join Point Model
  • Join Point ??????????????
  • ??????????Join Point ??????????
  • ????????,????????,??,...
  • Join Point ??????????????

72
??????????
  • ????? ???,?????? ??????
  • pointcut ????(join point)???
  • advice pointcut ?????????
  • Pointcut ???????????
  • Pointcut ???????????
  • Pointcut ???????????(??????????)
  • advice ??????,???????????????????
  • ?????????,???????????????
  • ??????,?????????????????
  • ????????????????????????????????

73
???????????????????
??????????????? ???????? Line.setP1, Line.setP2,
Point.setX ???,???
74
  • ??

75
????????????????
  • ????,?????,?????????????
  • ?????????????????????????
  • ???????????????
  • AspectJ ??????

pointcut sqrt_call(int x) call(double
aClass.sqrt(int)) args(x) before(int x)
sqrt_call(int x) assert( x gt 0 )
76
??????? Join point
  • Join Point Model
  • AspectJ ? Join Point Model ???
  • AspectJ ???????????????,????????????
  • ?????????????????????????????
  • Pointcut Join point ?????????
  • call pointcut ???
  • Context exposure ???
  • Context exposure ?????????????????,??????????????
    ??
  • AspectJ ???? this, target, args pointcuts
  • ?????? cflow pointcut ??????????????

77
???????????????
  • Advice
  • assert ??????????
  • 1??????????,????????????
  • ?????????????????
  • AspectJ ?? before/after ?????????
  • ?????????
  • ?????????????????????
  • ???????,?????????????????
  • ??????????????
  • ?? ???? ???????????

78
Aspect for Observer
Advice for Subject.attach (??????)
Advice for Subject.detach (??)
79
Advice for Subject.attach
80
?????????????????
  • ??????????????,1??????????
  • 1?????????????,?????????????
  • ??????,??????????????
  • ?????????,??????????
  • ?????????,?????????
  • ???????????????????
  • ??????,??????????????????????

81
  • ????

82
????????????????
  • ????????????
  • ????????????????,????????????????
  • ?????????????
  • ????????????
  • ?????????????????
  • ?????????????
  • ?????????,
  • ???????????,????????????????

83
??????????
  • ???,?????????????
  • ??????????????
  • ??????,????????
  • ????,??????????????????????
  • ??????????,??(?????)????????
  • ????????????
  • ????????????
  • ???????????????????

84
???????
  • ????????????????????????? AspectJ ???
  • ?????????,?????????,??????????????????????
  • ?????????????? ?????? ??????????
  • ????1000???????????????
  • ???????????????????????,??????????????????

85
??????????
  • Java ????????????
  • ????????????????????(?????)??
  • ?????,????????????
  • ????????????
  • ???????,???????????????????
  • Java Virtual Machine Debugger Interface
  • JVM ?????????????????????????
  • ????????????????????
  • ?????,JVM ????????????
  • JVM ??????????????
  • ???????????????

86
  • ???????????

87
??(1) ??????
  • ????
  • AspectJ ??????? 5??
  • ??????????????????
  • ???????????????500?
  • ????
  • ???????????,????????????????????
  • ????????????????????????
  • AJDE ????????????????????????

88
??(2) ?????????
  • ??????????
  • ????(????) 12?
  • ??? Java ??????,AspectJ ???????
  • ???? Eclipse AspectJ plug-in
  • ?????
  • Eclipse ???????
  • Eclipse ???? Java????????????(????1)
  • AspectJ ???????
  • Eclipse ???? AspectJ ?????????(????2)
  • Eclipse ???? AspectJ ??????????(??)
  • ???????? ??,6? ?????????????
  • ??????,??????

89
??????????
  • ?? ????????
  • ???? ( 4 3 ( 2 7 ) ( 2 7) ) ? 35
  • ???????????????????
  • ???5?(??????),?????4?,??340?
  • ??????????
  • ??????? (????2???????????)
  • ???????????????
  • ???????????????
  • ????????????????????????
  • ?? ???????????????,????????????????
  • ?????????
  • ???????????,???????????????????
  • ?3??????????,???????????????????

90
????????
????
???? ??/?? ?????
???
???
????
????????????
91
???????????
public aspect CachingAspect // member of this
Aspect static private Set workers new
HashSet() // add a member to Worker
class private boolean Worker.isAlreadyCalculated
false pointcut work_call() call(void
Worker.work()) pointcut first_work_call()
work_call() !cflowbelow(work_call()) void
around() work_call() Worker w
(Worker)thisJoinPoint.getTarget() if
(w.isAlreadyCalculated) return else
proceed() w.isAlreadyCalculated
true workers.add(w) // clear the
flag when calculation process is
finished after() first_work_call() for
(Iterator it workers.iterator() it.hasNext()
) Worker w (Worker)it.next() w.isAlread
yCalculated false workers.clear()
?????????? ???????
?????????, ??????????? ???????????
?????????? ???,???????
???????????? ??????????
92
??????
  • ??? (???2??????,??????)
  • ?????
  • ????
  • ??????????
  • ????????
  • ???????????
  • ?????????

93
????
  • Java??????????????????
  • ???? r 0.54
  • AspectJ ????????? Java ??????????????????????
  • ?????????
  • ????????????????????

??????? (?? ?)
???? ????1 (Java) ????2 (AspectJ) ?? (AspectJ)
1 150 186 200
2 200 210 190 (??????)
94
????????????????
????????????
  • void f1()
  • x f2()
  • int f2()
  • return doSomething()
  • int f3()
  • return doSomething2()
  • aspect redirectMethodCall
  • int around() call(f2)
  • return f3()

????????? ??????????
95
  • ??/?????

96
CK????? ??????(LCOM)
  • ?? ??????????,??????,???????????????????????????
    ????.
  • ?? ??? C1 ? n ?????? M1 Mn ???,????????????????
    ????? I1 In ???.
  • P (Ii, Ij) Ii n Ij f
  • ??????????????????????????
  • ???, I1 In ????f???? P f
  • Q (Ii, Ij) Ii n Ij ? f
  • LCOM P - Q if P gt Q, 0 otherwise.
  • ?????????????(??????????)
Write a Comment
User Comments (0)
About PowerShow.com