2 Code Conventions

The code conventions, which were used, can be distinguished in two parts. The first part describes the code style, while the second part describes good/best practices concerning the Java programming language in general.

The code style is based on the Google Java Style3. This style guide describes rules regarding the source file structure, the format of the code, the naming strategy and code comments. The guide is licensed under Creative Commons4 (CC BY 3.0) and was altered to fit this project. The current version of the style guide can be found in a separate coding conventions document here.

The good/best practices concerning the Java programming language in general are taken from the rule set described by Joshua Bloch in [1]. This rule set consists of 78 so called items that describe implementation details, which are considered valuable by experts, if Java is used as programming language [1, p. 1]. The items are sorted into categories, which are among others:

The items of the categories mentioned above were considered during the initial implementation, were possible. However, the different items are not further elaborated here. A detailed description of the various items can be found in [1]. A few very important items should be mentioned at this point though. Since jTNC is a software library, which should be used by other Java based applications, items regarding extensibility, encapsulation of data and information hiding such as the items one (s. [1, pp. 5-10]) and two (s. [1, pp. 11-16])are especially important. These items describe the separation of code between the creation of an object and its purpose. Further, the items 13 (s. [1, pp. 67-70]), 14 (s. [1, pp. 71-72]), 15 (s. [1, pp. 73-80]) and 16 (s. [1, pp. 81-86]) are important, because they contain recommendations about the accessibility of an object’s inner state and the visibility of objects and their data. For the use of constant values that are defined by the TNC-WG, the information about the usage of Enums in general and for constant values of the items 30 (s. [1, pp. 147-157]), 31 (s. [1, p. 158]), 32 (s. [1, pp. 159-160]) and 34 (s. [1, pp. 165-169]) are considered. The chapters seven (s. [1, pp. 181-208]) and eight [1, pp. 209-240]) are particularly helpful for programming with Java in general. Additionally, the items 26 (s. [1, pp. 124-128]), 27 (s. [1, pp. 129-133]) and 28 (s. [1, pp. 134-141]) about Generics as well as the items 61 (s. [1, pp. 250-251]) and 68 (s. [1, pp. 271-273]) about Exceptions and threading are important.

For the implementation of the items the author of [1] refers to design patterns from [2] often. The design patterns described in [2] were used for the implementation of jTNC also, to create software that is modular and to aid the reusability of the code. Because these design patterns are well known for software development, they are not explained in detail here. However, the most important patterns are mentioned in the following shortly. The patterns Builder, Abstract Factory and Factory Method as well as Singleton are used to control the creation of objects. The design pattern Adapter is used to abstract the requirements for the interfaces IF-IMC and IF-IMV of TNC, while the pattern Proxy is used to enforce rules specified by the TNC-WG for the interaction with these two interfaces. Additionally the design patterns Composite and Decorator are used to create objects, which can be combined to offer different functionality while adhering to the same base. The design pattern Visitor is used for the encoding and decoding of TNC data for transmission, while the pattern State is used to realize the state machine for an integrity handshake as described by IF-TNCCS. The design pattern Observer aids in the separation of the modules, described in the following sections, because it enabled an event based implementation of certain processes.

3Google Java Style: https://google-styleguide.googlecode.com/svn/trunk/javaguide.html

4CC BY 3.0: http://creativecommons.org/licenses/by/3.0/