-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2C-SE.tex
3035 lines (2664 loc) · 77.7 KB
/
2C-SE.tex
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[a4paper]{article}
\usepackage{tipa} % for IPA
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provides euro and other symbols
\else % if luatex or xelatex
\usepackage{unicode-math}
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\usepackage{hyperref}
\hypersetup{
pdfborder={0 0 0},
breaklinks=true}
\urlstyle{same} % don't use monospace font for urls
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{#1}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}}
\newcommand{\BuiltInTok}[1]{#1}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{#1}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{#1}}}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{#1}}
\newcommand{\ImportTok}[1]{#1}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
% set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\date{}
\usepackage{fancyhdr}
\pagestyle{fancy}
\rhead{Copyright \textcopyright\ 2018, Bora M. Alper}
\cfoot{\thepage}
\begin{document}
\hypertarget{2c-se---software-engineering---notes}{%
\section{2C (SE) - Software Engineering -
Notes}\label{2c-se---software-engineering---notes}}
Revision 2018-12-01T18:40Z
Based on \href{http://homepages.inf.ed.ac.uk/pbj/}{Paul Jackson}'s lecture slides.
\begin{description}
\item[\textit{caveat emptor} (/\textipa{[\textsecstress kæv\textepsilon\textscripta\textlengthmark t \textprimstress\textepsilon mpt\textopeno\textlengthmark r]}/)] ``Let the buyer beware.'' A principle in commerce: without a warranty the buyer takes the risk.
\end{description}
\vfill
\begin{center}
\includegraphics [width=2in] {2C-SE.assets/output1000.png}
\end{center}
\tableofcontents
\newpage
\hypertarget{18-september-2018}{%
\subsection{18 September 2018}\label{18-september-2018}}
\hypertarget{software-engineering-activities}{%
\subsubsection{Software Engineering
Activities}\label{software-engineering-activities}}
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
Requirements Capture
\item
Design
\item
Construction/Implementation
\item
Testing \& Debugging
\item
Maintenance/Evolution
\end{enumerate}
\hypertarget{4-october-2018}{%
\subsection{4 October 2018}\label{4-october-2018}}
\hypertarget{identifying-classes-and-operations}{%
\subsubsection{Identifying Classes and
Operations}\label{identifying-classes-and-operations}}
\begin{itemize}
\item
Identifying Classes
\begin{itemize}
\tightlist
\item
Ignore all non-nouns and instead focus on the \emph{nouns} in the
\emph{project description}.
\end{itemize}
\item
Identifying Operations
\item
Focus on \emph{verbs} instead.
\end{itemize}
\textbf{In both cases, use your judgement again to eliminate some
concepts for further simplicity and clarity.}
\textbf{Beware of subclassing/inheritance relationships between classes
(or of its concepts).}
\hypertarget{18-october-2018}{%
\subsection{18 October 2018}\label{18-october-2018}}
\hypertarget{software-configuration-management}{%
\subsubsection{Software Configuration
Management}\label{software-configuration-management}}
\begin{itemize}
\tightlist
\item
Version Control
\item
Compiling (and \emph{Building} as a general idea)
\end{itemize}
\hypertarget{version-control}{%
\subsubsection{Version Control}\label{version-control}}
\begin{itemize}
\item
Lock-Modify-Unlock Model \emph{{[}OLD{]}}
\begin{itemize}
\item
Advantages
\begin{itemize}
\tightlist
\item
Very simple.
\item
Central source of truth.
\end{itemize}
\item
Disadvantages
\begin{itemize}
\tightlist
\item
Multiple developers cannot work on the same file.
\item
Deadlocks might occur (especially if scripts are doing some
maintenance work on the repo for instance, say linting multiple
files).
\item
Requires access to repo at all times (\emph{e.g.} you cannot
checkout a file to modify it during the holiday, lest it will be
inaccessible for a week).
\end{itemize}
\end{itemize}
\item
Copy-Modify-Merge \emph{{[}NEW{]}}
\begin{itemize}
\item
Advantages
\begin{itemize}
\tightlist
\item
Multiple developers can work on the same file at the same time.
\item
Deadlocks cannot occur since there is no locking.
\item
Distributed repositories might be beneficial for certain
development. models (\emph{i.e.} open-source projects where every
contributor might want to have a full-access).
\item
Does not require access to repo at all times.
\end{itemize}
\item
Disadvantages
\begin{itemize}
\tightlist
\item
More complicated than Lock-Modify-Unlock model.
\item
Multiple sources of truth (though in reality there is often a
master repo).
\item
Merge conflicts happen, and they are not uncommon.
\item
Automatic merging used to be faulty sometimes but software are
getting better.
\item
Not every file-type is \emph{mergable}, such as photographs, PDF
documents, audio files, or spreadsheets.
\begin{itemize}
\tightlist
\item
\textbf{Merging requires certain assumptions about the file
semantics.}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\begin{itemize}
\item
Three-Way Merge
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
Original File:
\begin{verbatim}
Alpha
Bravo
Charlie
\end{verbatim}
\item
Tester 1 edits the Original File:
\begin{verbatim}
Alpha
Foxtrott
Charlie
\end{verbatim}
\item
Tester 2 edits the Original File:
\begin{verbatim}
Delta
Alpha
Echo
Charlie
\end{verbatim}
\item
Tester 2 commits changes.
\item
Tester 1's commit fails.
\item
Tester 1 updates and merge reports conflicts:
\begin{verbatim}
Delta
Alpha
<<<<<< .mine
Foxtrott
======
Echo
>>>>>> .r4
Charlie
\end{verbatim}
\item
Tester 1 now has to choose whether to retain her or Tester 2's
version.
\end{enumerate}
\end{itemize}
\hypertarget{compiling-and-building}{%
\subsubsection{Compiling and Building}\label{compiling-and-building}}
\begin{itemize}
\item
C
\begin{itemize}
\tightlist
\item
Make \emph{{[}OLD{]}}
\item
CMake \emph{{[}NEW{]}}
\end{itemize}
\item
Java
\begin{itemize}
\tightlist
\item
Ant \emph{{[}OLD{]}}
\item
Maven \emph{{[}NEW{]}}
\end{itemize}
\end{itemize}
\hypertarget{23-october-2018}{%
\subsection{23 October 2018}\label{23-october-2018}}
\hypertarget{refactoring}{%
\subsubsection{Refactoring}\label{refactoring}}
\begin{itemize}
\item
\textbf{As code evolves its quality naturally decays.}
\begin{itemize}
\tightlist
\item
Because \textbf{changes are often local, without full understanding
of the context.}
\end{itemize}
\item
\textbf{Refactoring}, is about restoring good design in a
\emph{disciplined way}.
\begin{itemize}
\tightlist
\item
There are \textbf{refactoring patterns}.
\begin{itemize}
\tightlist
\item
There are patterns for everything in Software Engineering...
\end{itemize}
\end{itemize}
\item
\emph{Refactoring is changing \textbf{internal} structure of software
to make it:}
\begin{itemize}
\tightlist
\item
\emph{easier to understand, and}
\item
\emph{cheaper to modify}
\end{itemize}
\emph{\textbf{without changing its observable behaviour.}}
\item
Refactoring was once seen as a kind of maintenance, but it can also be
an integral part of the development process!
\begin{itemize}
\tightlist
\item
Agile methodologies (\emph{e.g.} XP) advocate continual refactoring.
\end{itemize}
\item
\textbf{A refactoring is a \emph{small} transformation.}
\begin{itemize}
\tightlist
\item
Do NOT confuse it with \textbf{rewrite}.
\end{itemize}
\item
To ensure that refactoring hasn't \textbf{changed}/broken something?
\begin{itemize}
\tightlist
\item
\emph{test, refactor, test}
\end{itemize}
\end{itemize}
\hypertarget{bad-code-smells}{%
\subsubsection{Bad Code Smells}\label{bad-code-smells}}
\begin{itemize}
\tightlist
\item
Duplicated code
\item
Long methods
\item
Large classes
\item
Long parameter lists
\item
Lazy classes \emph{i.e.} Classes that are ridiculously small.
\item
Long message chains \emph{i.e.} Having too many (unnecessary)
indirections.
\end{itemize}
\hypertarget{25-october-2018}{%
\subsection{25 October 2018}\label{25-october-2018}}
\hypertarget{verification-validation-and-testing-vvt}{%
\subsubsection{Verification, Validation, and Testing
(VV\&T)}\label{verification-validation-and-testing-vvt}}
\begin{itemize}
\tightlist
\item
\textbf{VV\&T} generally refers to all techniques for improving
\textbf{product quality}.
\item
\textbf{Verification:} are we building the software \emph{right}?
\begin{itemize}
\tightlist
\item
Does software meet requirements?
\item
\emph{Static analysis, reviews, inspections, walk-throughs}
\end{itemize}
\item
\textbf{Validation:} are we building the \emph{right software}?
\begin{itemize}
\tightlist
\item
Does software accommodate customers' needs?
\item
\emph{Prototyping, early releases}
\item
Validation is more general than verification.
\end{itemize}
\item
\textbf{Testing is a useful technique for both.}
\end{itemize}
\hypertarget{testing}{%
\subsubsection{Testing}\label{testing}}
\begin{itemize}
\tightlist
\item
In essence, testing is
\begin{itemize}
\tightlist
\item
\emph{Generating stimulus} for a component
\item
\emph{Collecting outputs} from the component
\item
\emph{Checking} if \emph{actual} outputs are as \emph{expected}
\end{itemize}
\item
\textbf{Automation of tests is essential.}
\begin{itemize}
\tightlist
\item
Speeds up the whole testing process.
\item
\textbf{Makes tests deterministic.}
\begin{itemize}
\tightlist
\item
Not necessarily always, but definitely more deterministic than a
human being.
\end{itemize}
\end{itemize}
\item
\texttt{assert} statements are common to compare the actual results
and expectations.
\begin{itemize}
\tightlist
\item
\textbf{Checks can also be spread throughout the program code
itself.}
\end{itemize}
\end{itemize}
\hypertarget{kinds-of-tests}{%
\paragraph{Kinds of Tests}\label{kinds-of-tests}}
\begin{itemize}
\tightlist
\item
Testing approaches:
\begin{itemize}
\tightlist
\item
\textbf{Black-Box Testing} purely specification-based (treating the
component as a "black box")
\item
\textbf{White-Box Testing} also considers the internal structure
\end{itemize}
\item
Kinds of tests:
\begin{itemize}
\tightlist
\item
\textbf{Module (or Unit) Tests} for each class in OO software
\item
\textbf{Integration Tests} test components interact properly
\item
\textbf{System Tests} check if functional and non-functional
requirements met, \emph{verification}
\item
\textbf{Acceptance Tests} in customer environment, \emph{validation}
\item
\textbf{Stress Tests} look for graceful degradation, not catastrophe
\item
\textbf{Performance Tests} performance is often a non-functional
requirements (\emph{e.g.} in real-time systems)
\item
\textbf{Regression Tests} more like a testing methodology, repeated
full-tests after each modification
\end{itemize}
\end{itemize}
\hypertarget{how-to-test}{%
\paragraph{How to Test}\label{how-to-test}}
\begin{itemize}
\tightlist
\item
Tests should be
\begin{itemize}
\tightlist
\item
\textbf{repeatable}
\item
\textbf{documented} both the tests and the results
\item
\textbf{precise}
\item
\textbf{done on configuration-controlled software}
\end{itemize}
\item
\textbf{Ideally test spec should be written at the same time as the
requirements spec.}
\begin{itemize}
\tightlist
\item
Tests and requirement features can be cross-referenced!
\item
Use cases can suggest tests.
\item
\textbf{Also helps to ensure \emph{testability} of requirements.}
\end{itemize}
\end{itemize}
\hypertarget{preconditions-postconditions-invariants}{%
\subsubsection{Preconditions, Postconditions,
Invariants}\label{preconditions-postconditions-invariants}}
\begin{itemize}
\tightlist
\item
\textbf{Method Precondition} A condition that must be true when a
method is invoked.
\item
\textbf{Method Postcondition} A condition that the method guarantees
to be true when it finishes.
\item
\textbf{Class Invariant} A condition that should \emph{always} be true
for all the instances of a given class.
\begin{itemize}
\tightlist
\item
\emph{Always} as in all \emph{client-visible} states, that is,
whenever the object is not executing one of its methods!
\end{itemize}
\end{itemize}
\hypertarget{java-modelling-language-jml}{%
\paragraph{Java Modelling Language
(JML)}\label{java-modelling-language-jml}}
\begin{itemize}
\item
JML provides
\begin{itemize}
\tightlist
\item
A richer language (predicate logic) for writing boolean conditions
than Java boolean expressions (propositional logic), for example
allowing \emph{quantifiers} such as \texttt{\textbackslash{}forall}
and \texttt{\textbackslash{}exists}.
\item
Special comment syntax for common assertion types:
\begin{itemize}
\tightlist
\item
\textbf{Preconditions:}
\texttt{//@\ requires\ x\ \textgreater{}\ 0;}
\item
\textbf{Postconditions:}
\texttt{//@\ ensures\ \textbackslash{}result\ \%\ 2\ ==\ 0;}
\item
\textbf{Invariants:}
\texttt{//@invariant\ name.length\ \textless{}=\ 8;\ }
\item
\textbf{General assertions:} \texttt{//@\ assert\ i\ +\ j\ =\ 12;}
\end{itemize}
\end{itemize}
\item
Examples:
\begin{itemize}
\item
\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{//@ requires x >= 0.0}
\CommentTok{/*@ ensures JMLDouble}
\CommentTok{ @ .approximatelyEqualTo}
\CommentTok{ @ (x, \textbackslash{}result * \textbackslash{}result, eps);}
\CommentTok{ @*/}
\KeywordTok{public} \DataTypeTok{static} \DataTypeTok{double} \FunctionTok{sqrt}\NormalTok{(}\DataTypeTok{double}\NormalTok{ x) \{}
\CommentTok{/*...*/}
\NormalTok{\}}
\end{Highlighting}
\end{Shaded}
\item
\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{/*@ requires a != null}
\CommentTok{ @ && (\textbackslash{}forall int i;}
\CommentTok{ @ 0 < i && i < a.length;}
\CommentTok{ @ a[i-1] <= a[i]);}
\CommentTok{ @*/}
\DataTypeTok{int} \FunctionTok{binarySearch}\NormalTok{(}\DataTypeTok{int}\NormalTok{[] a, }\DataTypeTok{int}\NormalTok{ x) \{}
\CommentTok{// ...}
\NormalTok{\}}
\end{Highlighting}
\end{Shaded}
\begin{itemize}
\item
\begin{quote}
Note that this universally quantified expression in JML must have
parentheses around it, \texttt{(\textbackslash{}forall\ ...\ )}.
\end{quote}
\item
\begin{quote}
The range is optional, but if omitted, such a universally
quantified expression may not be executable; it can still be used
for documentation purposes, however.
\end{quote}
\end{itemize}
\end{itemize}
\item
\begin{quote}
In return for the benefit of faster understanding, modular reasoning
imposes a cost. This cost is that clients are not allowed to conclude
anything that is not justified by the contracts of the methods that
they call. Another way of looking at this is that, to allow modular
reasoning with contract specifications, \textbf{the client code must
work for every implementation that satisfies the contract.}
\end{quote}
\begin{itemize}
\item
\begin{quote}
Otherwise, the implementation would no longer be free to change the
algorithm used.
\end{quote}
\end{itemize}
\item
\begin{quote}
There are other good reasons not to use code as contracts.
\textbf{Code makes a poor contract, because by only using code one
cannot convey to readers what is intended (i.e., what the
\emph{essential properties} of the method are) and what parts are
merely implementation decisions (\emph{accidental features}).}
\end{quote}
\begin{itemize}
\item
\begin{quote}
For example, if the code for \texttt{sqrt} computes square roots to
7 decimal places, cannot this be changed in the next release?
Without some separate description of what is intended, the reader
can't tell if that 7 decimal places were intended, or just happened
to be computed; perhaps 4 decimal places are all that is necessary
for the rest of the program.
\end{quote}
\end{itemize}
\item
Some tools such as \emph{jmlc, jmlrac, etc.} compile and run
JML-annotated Java code into bytecode with specific \textbf{runtime
assertion checking}.
\item
\textbf{Assertions can also be used on \emph{inputs} to
\emph{constrain} the \emph{random generation of input data}.}
\begin{itemize}
\tightlist
\item
QuickCheck!
\end{itemize}
\end{itemize}
\emph{Quotes from:}
\href{http://www.eecs.ucf.edu/~leavens/JML//jmldbc.pdf}{http://www.eecs.ucf.edu/\textasciitilde{}leavens/JML//jmldbc.pdf}
\hypertarget{kinds-of-bugs}{%
\subsubsection{Kinds of Bugs}\label{kinds-of-bugs}}
\begin{itemize}
\item
In order of increasing severity:
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
\textbf{Mistake} A human action that produces a fault.
\item
\textbf{Fault (Defect)} An incorrect step, process, or data
definition in a computer program.
\item
\textbf{Error} A difference between some computed value and the
correct value.
\item
\textbf{Failure} The software (or whole system) failing to deliver
some service it is expected to deliver.
\end{enumerate}
\begin{itemize}
\tightlist
\item
\textbf{Faults do not necessarily lead to errors.}
\item
\textbf{Errors do not necessarily lead to failures.}
\end{itemize}
\end{itemize}
\hypertarget{test-first-development}{%
\subsubsection{Test-First Development}\label{test-first-development}}
\begin{itemize}
\item
\textbf{Motivation:} Tests implicitly define...
\begin{itemize}
\tightlist
\item
interface, and
\item
\textbf{specification of behaviour}
\end{itemize}
for the functionality being developed.
\item
\textbf{Writing tests first often clarifies requirements!}
\begin{itemize}
\tightlist
\item
Testing code demands more precision than an English specification.
\end{itemize}
\item
\textbf{Idea} is
\begin{itemize}
\tightlist
\item
write tests \textbf{before} writing the code they apply to,
\item
run tests as code is written.
\item
\emph{In an ideal world, the system will be complete when all your
tests pass. :)}
\item
\textbf{TFD avoids poor ambiguity resolution.}
\begin{itemize}
\tightlist
\item
Instead of choosing what is easiest to implement in the face of
ambiguity, you will implement the right thing (that your tests
check for).
\end{itemize}
\end{itemize}
\item
\textbf{Consequently}
\begin{itemize}
\tightlist
\item
bugs found at earliest possible point of development
\item
locating bugs are relatively easy (due to locality of tests)
\item
\textbf{TFD ensures adequate time for test writing.}
\begin{itemize}
\tightlist
\item
Often testing time is squeezed or eliminated.
\end{itemize}
\end{itemize}
\end{itemize}
\hypertarget{test-driven-development}{%
\subsubsection{Test-Driven Development}\label{test-driven-development}}
\begin{itemize}
\tightlist
\item
A subtly different term, covers the way that in Extreme Programming
detailed tests \emph{replace} a written specification.
\end{itemize}
\hypertarget{limitations-of-testing}{%
\subsubsection{Limitations of Testing}\label{limitations-of-testing}}
\begin{itemize}
\item
\textbf{Writing tests is time-consuming}
\item
\textbf{Coverage almost always limited} may happen not to exercise a
bug.
\item
\textbf{Difficult/impossible to emulate live environment perfectly}
\emph{e.g.} \emph{race conditions} that appear under real load
conditions can be hard to find by testing.
\item
\textbf{Can only test executable things} mainly code, or certain kinds
of model -- not high level design or requirements.
\end{itemize}
\hypertarget{reviews-walkthroughs-inspections}{%
\subsubsection{Reviews, Walkthroughs,
Inspections}\label{reviews-walkthroughs-inspections}}
\begin{itemize}
\tightlist
\item
\includegraphics{2C-SE.assets/1542636369213.png}
\item
\includegraphics{2C-SE.assets/1542636375661.png}
\end{itemize}
\hypertarget{static-analysis}{%
\subsubsection{Static Analysis}\label{static-analysis}}
\begin{itemize}
\tightlist
\item
Static analysis is \textbf{the inspection of the code to determine
properties of it \emph{without running it}.}
\begin{itemize}
\tightlist
\item
When contrasted with testing, testing is called \emph{dynamic
testing}.
\end{itemize}
\item
\textbf{Type-checking} during compilation is a basic kind of static
analysis.
\item
\textbf{Trade-offs}
\begin{itemize}
\tightlist
\item
As the properties checked get more complicated,
\begin{itemize}
\tightlist
\item
only smaller programs can be analysed.
\item
the process is less automated (\emph{e.g.} \textbf{annotations}
required).
\end{itemize}
\item
As tools are more automated and designed to work on larger programs,
they often \emph{cannot}
\begin{itemize}
\tightlist
\item
guarantee every problem flagged is a real error (\emph{i.e.}
false-positives)
\item
find every error (\emph{i.e.} false-negatives).
\end{itemize}
\item
The latter kind of tools are more to aid bug-hunting than ensuring
\emph{correctness}.
\end{itemize}
\end{itemize}
\hypertarget{1-november-2018}{%
\subsection{1 November 2018}\label{1-november-2018}}
\hypertarget{deployment}{%
\subsubsection{Deployment}\label{deployment}}
\begin{itemize}
\tightlist
\item
Getting software out of the hands of the developers into the hands of
the users.
\item
More than 50\% of commissioned software is not used, mostly because it
fails at deployment stage.
\end{itemize}
\hypertarget{key-issues}{%
\paragraph{Key Issues}\label{key-issues}}
\begin{itemize}
\item
\textbf{Business processes} Most large software systems require the
customer to change the way they work; has this been properly thought
through?
\item
\textbf{Training}
\item
\textbf{Deployment itself} How \emph{physically} to get the software
installed.
\item
\textbf{Equipment} Is the customers' hardware up to the job?
\item
\textbf{Expertise} Does the customer have the IT expertise to install
\& use the software?
\item
\textbf{Integration} How will the software integrate with other
systems of the customers'?
\item