This chapter describes how OCL expressions can be implemented in code. Although the Java language is used in the examples, the principles explained can be applied using any object-oriented programming language as target language. Even a non-object-oriented language could be used, but the process would be more cumbersome. The process of mapping OCL expressions to code can be perfomed manually or by automated tools. Several available tools can translate OCL to code. Because the tool market is rapidly changing, we do not provide a list of tools in this book; it would be outdated quickly. Instead, on the Web site http://www.klasse.nl/ocl/ you can find an up-to-date list of tools that are currently available. This chapter does not systematically treat the mapping of all OCL constructs. A systematic treatment would basically be a specification of an OCL compiler which would be very space consuming and to some extent boring to read. Instead, this chapter describes the main challenges and solutions of implementing OCL. |