7.1 Modelling with objects
In object orientation, modelling is very much focused on constructing descriptions based on sets of interacting objects.
For instance, when exploring a real-world problem we identify the important objects which relate to that problem and build models in terms of these objects and their interactions. The purpose here is to get a better understanding of the domain, whether to elicit requirements or to understand the business needs that those requirements address. Ideally, the classes of object in our models should be chosen to correspond to natural categories of things in the real world – such as ‘customer’, ‘invoice’, ‘payment’, ‘bill’ – so that there will be a structural similarity between the real world and the software. This approach can lead to good traceability from problem descriptions and requirements through to code.
Later on, once we have assumed that a software system is needed to address the problem, we may start modelling elements of the solution as software representations of the real-world objects. Initially the emphasis is on the services provided by the software solution and not on how these services are provided.
As design progresses, modelling describes the software system in greater and greater detail, with the allocation of responsibilities to different software objects so that the functionality of the entire system is distributed among the classes. In object terms a design model will represent the software classes and objects, the messages exchanged between them and their order.
Note, however, that structuring the software around objects per se does not guarantee quality software as an outcome. This can only be achieved through the judicious application of sound design and construction principles, and indeed object orientation comes equipped with a rich set of principles and tried-and-tested design solutions to recurrent design problems.