forked from ohm-softa/ohm-softa.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
01s-intro.html
349 lines (219 loc) · 8.78 KB
/
01s-intro.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
---
layout: presentation
title: Introduction
permalink: /01s-intro/
---
layout: true
<footer>
<span class="icon github">
<svg version="1.1" class="github-icon-svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<path fill-rule="evenodd" clip-rule="evenodd" fill="#C2C2C2" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/>
</svg>
</span>
<a href="https://github.com/sikoried"><span class="username">sikoried</span></a>
</footer>
---
.skip[
# Softwarearchitektur
]
.skip[
Prof. Dr.-Ing. Korbinian Riedhammer
]
---
# Introduction
- Software Architecture: mandatory class for CS majors
- materials
- https://ohm-softa.github.io
- Github organization: https://github.com/ohm-softa (BIO)
- ...in English! ☺
- slides, lecture notes, assignments (with READMEs)
- class: Fridays at 11.30a **(HW.303)** (updated Mar 18)
- tutorials:
- Tuesdays at *9.45a* in HQ.306, starting Mar 21.
- Thursdays at *9.45a* on Zoom (until May), Starting Mar 23.
- Fridays at *9.45a* in HQ.406, starting Mar 24.
- _nota bene: assignments typically take longer than 90'!_
???
https://github.com/gnab/remark/wiki/Formatting
Materialien auf Englisch, Vorlesung aber auf Deutsch.
Github orga ist closed/BIO--by invitation only
Office hours: Übungen kann man nicht in 90' Programmieren.
---
# Credits (Leistungsnachweis)
- written exam (90') at the end of the term
- you may bring three (3) pages notes (stapled and signed)
- you must sign up for the exam
- theoretical and coding questions
---
# Review (what you should know by now!)
## Programmieren 1 (now: Prozedurale Programmierung)
- imperative programming
- constants, variables, expressions, functions, I/O
- basic data structures (fields, arrays, lists)
- pointers ☺
## Programmieren 2 (now: Objektorientierte Programmierung)
- OOP, classes and objects (and references! ☺)
- basic data structures (lists, maps, etc.)
- interfaces and inheritance
- errors, exceptions and how to deal with them
---
# Agenda for Software Architecture
See https://ohm-softa.github.io/ (Syllabus)
- modularity and component based development
- UML, mostly class, component and sequence diagrams
- programming patterns: idioms, design, architecture
- assignments: tools and toolkits
Assignments are one week "behind".
---
# About this Class
### I'd like you to become better programmers
### Some slides, but mostly hands-on live coding (plus lecture notes!)
.skip[
All examples are found in the `/examples/` directory of the [site's repository](https://github.com/ohm-softa/ohm-softa.github.io/tree/master/examples).
]
---
# A note on (programming) languages
- class materials are in English (so is most of the internet/SO)
- examples are (mostly) in Java...
- ...but translate to C#, C++, Python, Scala, etc.
- we'll focus on the concept, not the language
---
# Software Architecture
...is a craft.
- takes practice
- takes patience
- takes diligence
- takes experience
---
# Don't be that guy...
.center[
![Goto](/assets/xkcd292-goto.png)
]
.right[
<https://xkcd.com/292/>
]
---
# Speaking of `goto`
## Why would you use `goto`?
## Is it possible in C#?
## Is it possible in Java?
???
c#: yes, emulate while, break outer loops
Java: no; but break out of outer loops with labelled loops and labeled break/continue
---
.center[
<img src="/assets/xkcd844-good-code.png" width="45%">
]
.right[
<https://xkcd.com/844/>
]
---
# Agenda today
1. What is software architecture?
2. What is abstraction?
3. What is decomposition?
4. Clean Code
5. Tools
---
# Software Architecture
Thoughts?
---
# Software Architecture
## Complexity
- Ideal: linear process (analysis, draft, implementation, test, maintenance)
- Constrained by: features, budget, time
- Real world: somethings changes along the way...
## Architecture
- Result of the software development process
- Components, systems, subsystems, etc.
- V-model, agile, ..., typically recurrent at some stage
---
# Abstraction
Thoughts?
---
# Abstraction
## high level → low level
- drive to the airport
- → go straight, right, straight, left, ...
- →→ clutch, brake, ignition, put in drive, ...
.skip[
- reduce complexity by removing details
- goal: model a system from a specific point of view
]
???
see: H. Stachowiak: Allgemeine Modelltheorie, Springer Verlag, 1973
---
# Abstraction
## Example: programming
- hardware instructions
- assembler (low-level)
- c, fortran, java (high-level)
- code generators
---
# Decomposition
Thoughts?
---
# Stepwise Refinement
> [...] a sequence of design decisions concerning the decomposition of a task into subtasks and of data into data structures
N. Wirth, "[Program Development by Stepwise Refinement](https://dl.acm.org/citation.cfm?id=362577)", Comm. ACM, 1971
→ break problem down in simpler problems until solvable
---
# Functional Decomposition
- Thoughts follow the process
- Bottom-up/top-down
### Example: Withdraw cash at ATM
- insert debit card
- enter pin
- select amount
- process cash
- ...
---
# Object Oriented Decomposition
> it is almost always incorrect to begin the decomposition of a system into modules on the basis of a flowchart. We propose instead that one begins with a list of difficult design decisions or design decisions which are likely to change. Each module is then designed to hide such a decision from the others. Since, in most cases, design decisions transcend time of execution, modules will not correspond to steps in the processing.
D.L. Parnas, "[On the Criteria used in Decomposing Systems into Modules](https://dl.acm.org/citation.cfm?id=361623)", Comm. ACM, 1972
### Modularization and Encapsulation
> Every module [...] is characterized by its knowledge of a design decision which it hides from all others. Its interface or definition was chosen to reveal as little as possible about its inner workings.
→ Coherence and loose/tight coupling
???
probably one of the reasons OOP became so popular...
---
# Some Guidelines for Good (OO) Architecture
## High Cohesion, Low Coupling
There should be high cohesion within classes and packages, but low coupling between objects and across packages.
## Law of Demeter
In simple words: "Each unit should have only limited knowledge about other units: only units "closely" related to the current unit.".
K. Liebherr, I. Holland and A. Riel: "[Object-oriented programming: an objective sense of style](https://dl.acm.org/citation.cfm?id=62113)", Proc. OOPSLA, 1988
## High Fan-In, Low Fan-Out
---
# A Bit of "Historic" Context
- early days of programming (pre 60s!) focused on procedures
- the 1970s layed the ground work (see previously cited papers!)
- 1970: Smalltalk (Xerox PARC; object oriented language)
- 1973: ML (U Edinburgh; functional language)
- 90s and 2000s: OOP widely taught as "gold standard", FP often considered "academic"
- 2010s and onwards: heavy parallelization reintroduced FP (almost hype!)
- "old" languages introduce functional elements (Java, C++, ...)
- Scala
- Actor frameworks, e.g. Akka
---
# Clean Code
<http://www.netlib.org/clapack/cblas/dgemm.c>
---
# Clean Code
- Choose good naming conventions
- Methods should be short, concise and with few paramters
- Comments only where needed; rewrite bad code
- Java conventions?
- [Google Java Format](https://github.com/google/google-java-format)
- [Elasticsearch](https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md#contributing-to-the-elasticsearch-codebase)
- Please read "Clean Code" by Prof. Tavakoli (`Teams > General > Files`)
---
# Tools
- Your preferred search engine
- Your preferred interactive generative information system*)
- [Stack Overflow](https://stackoverflow.com/questions/tagged/java)
- [Java documentation](https://docs.oracle.com/javase/11/docs/)
- JetBrains [IntelliJ](https://www.jetbrains.com/idea/), Community Edition (free!*)
- [Git version control](https://git-scm.com/)
*) Mind you: assignments are not mandatory — copying a solution typically has zero benefit