Skip to content

Commit c59d782

Browse files
committed
Update stereotypes
1 parent fdd51d3 commit c59d782

File tree

1 file changed

+139
-54
lines changed

1 file changed

+139
-54
lines changed

_notes/software-architecture/method/stereotypes.md

Lines changed: 139 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ layout: notes
1515
* Application: [Automatically Redocumenting Source Code with Method and Class Stereotypes](http://www.cs.kent.edu/~jmaletic/papers/DySDoc3-Stereotypes.pdf) (DySDoc3'18) Guarnera, D., Collard, M.L., Dragan, N., Maletic, J.I., Newman, C., Decker, M.
1616

1717
# Documentation
18-
19-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=AccessorGet.cpp"></script>
18+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=get.cpp"></script>
2019

2120
* Method stereotypes can be embedded in the source code as a comment
2221
* *documentation* if the identification is manual
@@ -34,120 +33,187 @@ layout: notes
3433

3534
| Stereotype | Description |
3635
|------------|-------------|
37-
| *get* | returns the value of a data member |
38-
| *predicate* | returns a Boolean result computed from data members |
39-
| *property* | returns information based on data member values |
40-
| *void-accessor* | returns information about data members through a parameter |
36+
| *get* | Returns a data member |
37+
| *predicate* | Returns a Boolean value that is not a data member |
38+
| *property* | Returns information about data members (non-Boolean) |
39+
| *void-accessor* | Returns information about data members through method parameters |
4140

4241
# Accessor::get
42+
> Returns a data member
4343
44-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=AccessorGet.cpp"></script>
45-
46-
* *Returns the value of a data member*
4744
* The purpose of the method is very simple and primitive
48-
* Direct access to the value of the data member
45+
* Direct access to the data member
4946
* C++ Rules:
5047
* method is const
5148
* returns a data member
52-
* return type is primitive or container of a primitive
49+
* return type is a primitive or a container of a primitive
50+
51+
# Accessor::get - C++
52+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=get.cpp"></script>
53+
54+
# Accessor::get - C#
55+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=get.cs"></script>
56+
57+
# Accessor::get - Java
58+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=get.java"></script>
5359

5460
# Accessor::predicate
55-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=AccessorPredicate.cpp"></script>
61+
> Returns a Boolean value that is not a data member
5662
57-
* *Returns a Boolean result computed from data members*
5863
* Result is not a direct data member, but a computation involving data members
5964
* C++ Rules:
6065
* method is const
6166
* returns a Boolean value that is not a data member
6267

68+
# Accessor::predicate - C++
69+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=predicate.cpp"></script>
70+
71+
# Accessor::predicate - C#
72+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=predicate.cs"></script>
73+
74+
# Accessor::predicate - Java
75+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=predicate.java"></script>
76+
6377
# Accessor::property
64-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=AccessorProperty.cpp"></script>
78+
> Returns information about data members (non-Boolean)
6579
66-
* *Returns information based on data member values*
6780
* C++ Rules:
6881
* method is const
6982
* does not return a data member
7083
* return type is primitive or container of primitives
7184
* return type is not Boolean
7285

86+
# Accessor::property - C++
87+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=property.cpp"></script>
88+
89+
# Accessor::property - C#
90+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=property.cs"></script>
91+
92+
# Accessor::property - Java
93+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=property.java"></script>
94+
7395
# Accessor::void-accessor
74-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=AccessorVoidAccessor.cpp"></script>
96+
> Returns information about data members through method parameters
97+
98+
# Accessor::void-accessor - C++
99+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=void-accessor.cpp"></script>
100+
101+
# Accessor::void-accessor - Cs
102+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=void-accessor.cs"></script>
75103

76-
* *Returns information about data members through a parameter*
104+
# Accessor::void-accessor - Java
105+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=void-accessor.java"></script>
77106

78107
# Mutators
79108

80109
| Stereotype | Description |
81110
|------------|-------------|
82-
| *set* | changes the value of a data member |
83-
| *command* | executes a complex change of the object’s state |
84-
| *non-void-command* | command which returns a value |
111+
| *set* | Modifies a data member |
112+
| *command* | Performs a complex change to the object’s state |
113+
| *non-void-command* | Command which returns a value |
85114

86115
# Mutator::set
87-
88-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=MutatorSet.cpp"></script>
89-
90-
* *Directly changes the value of a data member*
116+
> Directly modifies a data member
91117
* The parameter value is stored in the data member
92118
* C++ Rules:
93119
* method is not const
94120
* return type is void or Boolean
95121
* only one data member is changed
96122

97-
# Mutator::command
123+
# Mutator::set - C++
124+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=set.cpp"></script>
125+
126+
# Mutator::set - C#
127+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=set.cs"></script>
98128

99-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=MutatorCommand.cpp"></script>
129+
# Mutator::set - Java
130+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=set.java"></script>
100131

101-
* *Executes a complex change of the object’s state*
132+
# Mutator::command
133+
> Performs a complex change to the object’s state
102134
* The change may involve several data members
103135
* May change the data members either directly or indirectly with another mutator
104136
* C++ Rules:
105137
* method is not const
106138
* return type is void or Boolean
107139
* complex change to the object’s state is performed, e.g., more than one data member is changed
108140

109-
# Mutator::non-void-command
141+
# Mutator::command - C++
142+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=command.cpp"></script>
110143

111-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=MutatorNonVoidCommand.cpp"></script>
144+
# Mutator::command - C#
145+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=command.cs"></script>
112146

113-
* *Command which returns a value*
147+
# Mutator::command - Java
148+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=command.java"></script>
114149

115150
# Collaborational Methods
116151

117152
| Stereotype | Description |
118153
|------------|-------------|
119-
| *collaborator* | Works on objects of classes different from itself |
120-
| *controller* | Works only on objects of classes other from itself |
154+
| *collaborator* | Works with objects belonging to classes other than itself (parameter, local variable, data member, or return value) |
155+
| *controller* | Changes only an external object’s state (not this)|
156+
|wrapper|Does not change an object’s state. Has at least one free function call|
121157

122158
# Collaborational::Collaborator
123-
124-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=CollaboratorCollaborator.cpp"></script>
125-
126-
* *Works on objects of classes different from itself*
159+
> Works with objects belonging to classes other than itself (parameter, local variable, data member, or return value)
127160
* C++ Rules:
128161
* returns void and at least one of the method’s parameters or local variables is an object
129162
* returns a parameter or local variable that is an object
130163

164+
# Collaborational::Collaborator - C++
165+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=collaborator.cpp"></script>
166+
167+
# Collaborational::Collaborator - C#
168+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=collaborator.cs"></script>
169+
170+
# Collaborational::Collaborator - Java
171+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=collaborator.java"></script>
172+
131173
# Collaborational::Controller
174+
> Changes only an external object’s state (not this)
175+
176+
# Collaborational::Controller - C++
177+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=controller.cpp"></script>
178+
179+
# Collaborational::Controller - C#
180+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=controller.cs"></script>
132181

133-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=CollaboratorController.cpp"></script>
182+
# Collaborational::Controller - Java
183+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=controller.java"></script>
134184

135-
* *Works only on objects of classes different from itself*
185+
# Collaborational::Wrapper
186+
> Does not change an object’s state. Has at least one free function call
187+
188+
# Collaborational::Wrapper - C++
189+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=wrapper.cpp"></script>
190+
191+
# Collaborational::Wrapper - C#
192+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=wrapper.cs"></script>
193+
194+
# Collaborational::Wrapper - Java
195+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=wrapper.java"></script>
136196

137197
# Creational Methods
138198

139199
| Stereotype | Example/Description |
140200
|------------|-------------|
141-
| *constructor* |<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=CreationalConstructor.cpp"></script> |
142-
| *copy-constructor* | <script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=CreationalCopyConstructor.cpp"></script> |
143-
| *destructor* | <script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=CreationalDestructor.cpp"></script> |
201+
| *constructor* | Creates an object |
202+
| *copy-constructor* | Creates an object |
203+
| *destructor* | Destoyes an object |
144204
| *factory* | Object creation method |
145205

146206
# Creational::factory
207+
> Object creation method with the object returned to to the client
147208
148-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=CreationalFactory.cpp"></script>
209+
# Creational::factory - C++
210+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=factory.cpp"></script>
149211

150-
* *Object creation method with the object returned to to the client*
212+
# Creational::factory - C#
213+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=factory.cs"></script>
214+
215+
# Creational::factory - Java
216+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=factory.java"></script>
151217

152218
# Degenerate Methods
153219

@@ -158,45 +224,64 @@ layout: notes
158224
| *empty* | Method with no statements |
159225

160226
# Degenerate::incidental
227+
> Does not read/change the object state, and no calls to other methods of the same class
228+
229+
# Degenerate::incidental - C++
230+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=incidental.cpp"></script>
161231

162-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=DegenerateIncidental.cpp"></script>
232+
# Degenerate::incidental - C#
233+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=incidental.cs"></script>
163234

164-
* *Does not read/change the object state, and no calls to other methods of the same class*
235+
# Degenerate::incidental - Java
236+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=incidental.java"></script>
165237

166238
# Degenerate::stateless
239+
> Does not read/change the object state, with one call to other methods of the same class
167240
168-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=DegenerateStateless.cpp"></script>
241+
# Degenerate::stateless - C++
242+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=stateless.cpp"></script>
169243

170-
* *Does not read/change the object state, with one call to other methods of the same class*
244+
# Degenerate::stateless - C#
245+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=stateless.cs"></script>
171246

172-
# Degenerate::empty
247+
# Degenerate::stateless - Java
248+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=stateless.java"></script>
173249

174-
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=DegenerateEmpty.cpp"></script>
250+
# Degenerate::empty
251+
> Method with no statements
175252
176-
* *Method with no statements*
177253
* Typically part of an early implementation
178254
* Maybe due to functionality moving elsewhere
179255

180-
# Clear Design
256+
# Degenerate::empty - C++
257+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=empty.cpp"></script>
258+
259+
# Degenerate::empty - C#
260+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=empty.cs"></script>
261+
262+
# Degenerate::empty - Java
263+
<script src="https://gist.github.com/mjdecker/90d821299d8fb426a4add92699aa3245.js?file=empty.java"></script>
181264

265+
266+
# Clear Design
182267
<script src="https://gist.github.com/mlcollard/e7420f4dacc385e527940da67a8a43ec.js?file=StackInterface.cpp"></script>
183268

184269
* A method should have a single purpose, *single responsibility issue*
185270
* Conversely, a method should have a single primary *role*, i.e., *single role issue*
186271

187272
# Pop or Top vs. Pop and Top
188-
189273
<script src="https://gist.github.com/mlcollard/e7420f4dacc385e527940da67a8a43ec.js?file=StackTopAndPop.hpp"></script>
190274

191275
<script src="https://gist.github.com/mlcollard/e7420f4dacc385e527940da67a8a43ec.js?file=StackTopOrPop.hpp"></script>
192276

193277
# Automated Detection
194-
195278
<script src="https://gist.github.com/mlcollard/56f67dcea0ad6319d4f83949ac2a55b6.js?file=xpath.xml"></script>
196279

197280
* Tool, *stereocode*, automatically redocuments source code with stereotypes
198281
* *XPath* patterns with XPath extension functions
199282
* Very scalable as it redocuments large systems in minutes
200283

201284
# References
202-
* Adapted from https://mlcollard.net
285+
* Adapted from:
286+
* https://mlcollard.net
287+
* https://github.com/srcML/stereocode/wiki/Method-Stereotypes

0 commit comments

Comments
 (0)