Selaa lähdekoodia

Small improvements

stripped-german
Julian Ospald 9 vuotta sitten
vanhempi
commit
56aa6c1d71
No known key found for this signature in database GPG Key ID: 220CD1C5BDEED020
1 muutettua tiedostoa jossa 7 lisäystä ja 5 poistoa
  1. +7
    -5
      VL1.tex

+ 7
- 5
VL1.tex Näytä tiedosto

@@ -70,7 +70,7 @@ Regular C functions in real-world (omitting examples on purpose):
\begin{itemize}
\item 100+ LOC
\item at least 7 ifs, 4 whiles, 12 variables, 1 goto
\item access both static and global variables
\item accesses both static and global variables
\item indenting level of 5 or more
\item a lot of memory management and custom-made error handling
\end{itemize}
@@ -85,9 +85,11 @@ You need to change only one single line in such a C function. You have to know:
\item does it change the state of static or global variables?
\item does it implicitly change the state of out-parameters?
\item if it changes any of those states, is the function still correct?
\item does the program flow break? Do we have unreachable codepaths now?
\item what happens if the program flow reaches this codepath with variable X in that particular state, while variable Z is NULL, and...
\item did you just nuke a small former Soviet state?
\end{itemize}
\vspace{\baselineskip}
Conclusion: you really need to understand the complete environment of that line/function.
\end{frame}

\begin{frame}
@@ -95,13 +97,13 @@ You need to change only one single line in such a C function. You have to know:
But java helps! Does it?
Sort of, because:
\begin{itemize}
\item it improves APIs compared to C, since you can hide information in the state of an object (but... it's hidden now)
\item it has a garbage collector, so you don't need to worry too much about memory... unless it doesn't work OOTB anymore
\item it improves APIs compared to C, since you can hide or encapsulate information in the state of an object
\item it has a garbage collector, so you don't need to worry too much about memory
\end{itemize}
Unfortunately, we:
\begin{itemize}
\item now got even more states to keep track of (intellectual complexity?)
\item have clouded the program flow... it's now about object-interaction with their implicit states
\item have clouded the program flow... it's now about object-interaction with their explicit and implicit states
\item still have \textbf{side effects} everywhere: one object changes the state of another and vice versa, may arbitrarily write to the hard drive, do kernel calls or launch a missle
\end{itemize}
Some parts of the implicit state machine have been made explicit by modelling classes, but it's still there and we have to deal with it, because we are modelling everything around states. Wouldn't it be nice if we could just forget about the global state machine? Maybe there is even a way to remove side effects and have more "predictability"? We are lucky. There is. It's called \textbf{Haskell}.


Ladataan…
Peruuta
Tallenna