shop.tex 2.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. \section{Shop}
  2. \label{shop}
  3. \label{sec:shop}
  4. \begin{figure}[ht]
  5. \centering
  6. \includegraphics[width=0.45\textwidth]{images/Shop_Overview.eps}
  7. \label{shop_overview}
  8. \caption{Shop - Class Overview}
  9. \end{figure}
  10. %TODO reference figure.
  11. %\subsection{\code{Shop} - Starting your SalesPoint-application}
  12. \code{Shop} is a central class in \salespoint{}; it holds references to all manager interfaces and a reference to the \code{Time} interface.
  13. There are six manager interfaces and interfaces aggregating (persistent) objects in \salespoint{}: \code{Accountancy}, \code{Calendar}, \code{Catalog}, \code{Inventory}, \code{OrderManager} and \code{UserManager}.
  14. Other classes use the \code{Shop} to access the manager interfaces, for example \code{Order.completeOrder()} uses \code{Shop.INSTANCE.getInventory()} for product removal.
  15. \code{PersistentCalendar} uses \code{Shop.INSTANCE.getTime()} for time based operations.
  16. There is also a convenience method to minimize boilerplate code\footnote{
  17. It was mentioned to us, that boilerplate code may also be called infrastructure code.
  18. We disagree, because we consider configuration files, (startup-) scripts, deployment scripts, etc infrastructure code.
  19. Wikipedia defines boilerplate code as follows:
  20. \begin{quote}
  21. In computer programming, boilerplate is the term used to describe sections of code that have to be included in many places with little or no alteration.
  22. It is more often used when referring to languages which are considered verbose, i.e. the programmer must write a lot of code to do minimal jobs.
  23. \end{quote}}
  24. \code{Shop.initializeShop()};
  25. it is used for setting all managers of \code{Shop} to Salespoints persistent class implementations and the time to \code{DefaultTime}.
  26. This behaviour is also known as \textit{convention over configuration}, which means reasonable default values are supplied, eliminating the need to explicitly specify those values in most cases.
  27. \code{Shop} is implemented as a singleton.
  28. Although \code{Shop} holds references to all managers and aggregating classes (see Section \ref{chap:components}), persistent implementations do not need to be singletons and are infact not.
  29. Moreover, a peculiarity of all managers and aggregating classes is, that a new instance can be created whenever one is needed.
  30. The reason for this behaviour is, that data is not stored inside the manager object itself, as it may be done with a collection-based implementation, but the manager class is merely a transparent interface to the JPA and database.\\