| 1 |
\chapter{Development with NoTA}\label{chap:development} |
| 2 |
\section{Introduction} |
| 3 |
In the previous chapters, we discussed the major NoTA building blocks. That |
| 4 |
should provide us with an excellent background to create our own NoTA |
| 5 |
services. In this chapter, we will go through the development of an example |
| 6 |
NoTA client and server. The complete code is available in Appendix |
| 7 |
\ref{chap:example}. |
| 8 |
|
| 9 |
\section{Design} |
| 10 |
Before implementing NoTA services (ANs and SNn), it's important to think about |
| 11 |
the {\em design}\index{design} first. A full discussion of interface design |
| 12 |
goes beyond the scope of this guide, but we will gives some tips. |
| 13 |
|
| 14 |
For example, when defining the service interfaces, it's important to consider: |
| 15 |
\begin{itemize} |
| 16 |
\item Make interfaces\index{interface} as simple as possible; not simpler. Try |
| 17 |
to limit the number of entry points to a minimum of orthogonal functions; |
| 18 |
\item Choose clear names for your functions, and make the names in an |
| 19 |
interface consistent; |
| 20 |
\item Remember the '{\em Rule of the least surprise}'\cite{Raymond03}; |
| 21 |
\item Limit the number of parameters, and keep the parameters simple; |
| 22 |
\item Version\index{versioning} your interfaces (add a number), so you can |
| 23 |
evolve in the future without breaking clients of older versions; |
| 24 |
\item NoTA services are \emph{asynchronous} - multiple \texttt{\_req}s and |
| 25 |
\texttt{\_rsp}s might be underway at any time. So make sure you can |
| 26 |
determine which \texttt{\_rsp} refers to whic h\texttt{\_req}; |
| 27 |
\item Taking it one step further: there is no guarantee that messages arrive in |
| 28 |
the same order as they were sent. Therefore, don't make services that depend |
| 29 |
on that. |
| 30 |
\end{itemize} |
| 31 |
|
| 32 |
We also heartily recommend you to read \cite{Vinoski2008} and \cite{Kendall94} |
| 33 |
about the common pitfalls when designing distributed systems. The common |
| 34 |
fallacies applicable to NoTA can be summarized: |
| 35 |
\begin{enumerate} |
| 36 |
\item The network is reliable. |
| 37 |
\item Latency\index{latency} is zero. |
| 38 |
\item Bandwidth is infinite. |
| 39 |
\item The network is secure. |
| 40 |
\item Transport cost is zero. |
| 41 |
\item System clocks are identical. |
| 42 |
\end{enumerate} |
| 43 |
To make it clear: {\bf none of these are true}. When designing a NoTA-based |
| 44 |
system, it is good to keep that in mind. Another valuable source for design |
| 45 |
advice you might want to consult is {\em The Art of UNIX |
| 46 |
Programming}\cite{Raymond03}. |
| 47 |
|
| 48 |
\section{Naming and handling} |
| 49 |
The naming of functions and variables is to some extent a matter of |
| 50 |
taste. Some people prefer {\tt DoThisNow()}, while others like {\tt |
| 51 |
doThisNow} better. The author prefers {\tt do\_this\_now()}. |
| 52 |
|
| 53 |
Although that conflict cannot be solved here, we recommend some |
| 54 |
common suffices for the message/signals, in accordance with common usage. If |
| 55 |
you use these, for example in your WSDL descriptions, it's clear for the |
| 56 |
(human) users of the specifications what they mean. In particular, they |
| 57 |
clarify the role of both application node (AN) and service node (SN). |
| 58 |
|
| 59 |
\begin{itemize} |
| 60 |
\item {\tt \_req} should be used for {\em requests}, where an AN is |
| 61 |
\emph{requesting} something from a service node. {\tt \_req}-messages are |
| 62 |
handled (implemented) by service nodes; |
| 63 |
\item {\tt \_cnf} should be used for {\em |
| 64 |
confirmations} from the SN in response to some request from the AN; {\tt |
| 65 |
\_cnf}-messages are to be handled (implemented) by the AN; |
| 66 |
\item {\tt \_ind} should be used for {\em indications}, i.e., |
| 67 |
responses which are not direct response to requests; {\tt \_ind}-messages |
| 68 |
are sent by the SN to the AN and are to be handled (implemented) by the |
| 69 |
latter; |
| 70 |
\item {\tt \_rsp} should be used for {\em responses} to {\tt \_ind}-messages, |
| 71 |
and are sent by the AN to the SN. Thus, the SN needs to handle (implement) these. |
| 72 |
\end{itemize} |
| 73 |
|
| 74 |
\section{Implementation} |
| 75 |
In addition to all the other wise lessons already mentioned, we'd like to add |
| 76 |
a couple more, based on some common misconceptions / errors when implementing |
| 77 |
NoTA-systems. FIXME |
| 78 |
|
| 79 |
\section{Questions} |
| 80 |
To test your understanding of this chapter, some questions are provided. You |
| 81 |
can find the answers in appendix~\ref{chap:answers}. |
| 82 |
\begin{enumerate} |
| 83 |
\item Can you list the use cases for the {\tt \_req}, {\tt \_cnf}, {\tt \_ind} |
| 84 |
and {\tt \_rsp}? |
| 85 |
\end{enumerate} |