Naked Objects
By Richard Pawson and Robert Matthews


Most people who believe they are doing object-oriented design and development are doing no such thing, because they are ignoring the most important principle of object-orientation. We describe that principle as 'behavioural completeness': an object should completely model the behaviour of the thing that it represents. Instead, most people continue to design business systems that separate procedure from data, albeit dressed up in the language and technology of object-orientation.

Why is this distinction important? Because behavioural completeness is the key to realising the principal benefit of object-orientation: the ability to cope with unforeseen changes in requirements.

We suggest that even where there is a will to design behaviourally-complete objects, there are subtle forces that push back towards data and procedure. We have identified five such forces:

  • Business process orientation
  • Task-optimised user interfaces
  • Use-case driven methodologies
  • The Model-View-Controller pattern
  • Component-based software development.

The problem is that not only are all five considered to be best practices, but they also have the status of sacred cows amongst the software development community. We are not suggesting that any of them is itself a bad thing, but we are suggesting that they hinder good object-oriented design.

Naked Objects is an open-source Java-based framework designed specifically to encourage the creation of business systems from behaviourally-complete business objects. In fact, with the Naked Objects framework you have no alternative but to make your business objects behaviourally-complete. The reason is that the framework exposes your core business objects, such as Customer, Product and Order, directly to the user. All user actions consist of invoking methods directly upon those business objects, or sometimes upon the object's class. There are no scripts, no controllers, nor even any dialog boxes in between the user and the 'naked' objects. (Note: Wherever 'Naked Objects' is capitalized we are referring to the Java framework itself, and the term is singular. Where it is uncapitalized we are referring to business objects (plural) that are designed to work with the framework, and so are exposed directly to the user.)

Systems built using the Naked Objects framework are agile, meaning that they can accommodate changing business requirements, because behaviourally-complete objects carve the functionality of the system at its natural joints. Moreover, the lack of additional constructs around the naked business objects means that there will be fewer things to change.

The resulting systems are also more empowering from the user perspective. Giving the users direct access to the naked objects, instead of constraining their interaction through scripted tasks, means they have a strong sense of direct engagement. This is reinforced by the extensive use of drag and drop gestures that the framework provides automatically. The net effect is that business systems designed this way feel more like using a spreadsheet or a drawing program than a conventional transactional system: they treat the user as a problem solver, not merely as a process follower. This can have significant benefits not only in terms of employee motivation, but in improved customer service and operational decision making.

Even more significant than the improvements to the resulting systems is the impact on the development process. The naked objects provide a common language between the developer and the user, which significantly improves communication during the process of exploring requirements. And because the user presentation is auto-generated from the business object definitions, the developer does not need to write a single line of code to do with the user interface. In fact the whole conventional notion of a user interface just disappears. This facilitates very rapid prototyping. But unlike other forms of rapid prototyping, you are not merely prototyping the user interface - you are simultaneously prototyping the core object model.

The aim of this book is to introduce you to the concept of designing business systems from naked objects, and to enable you to start building such systems using the Naked Objects framework. The book will appeal primarily to two kinds of reader: object modellers who have at least some knowledge of Java programming (or want to acquire it), and Java developers who have some knowledge of object modelling (or want to acquire it). Indeed one of the messages in this book is that the notions of business object modelling and object-oriented programming are much more synergistic than is conventionally realised.

Structure of the book

Section 1 of this book provides a brief history of object-orientation and an analysis of the practices that tend to force the separation of procedure from data in business systems design. It concludes with a set of new design principles that we might call the 'naked object manifesto'. You don't need to read this history and analysis in order to get the benefits of using Naked Objects - you can skip straight on to the practical sections if you prefer - but you may find that this background deepens your understanding of the nature of object orientation and why current practice deviates so far from the original intent.

Section 1 is followed by a Case study on the Irish government's Department of Social and Family Affairs (DSFA). This was our first opportunity to apply the design principles to a mission-critical business system, and it was a big success. The DSFA used a very early and crude version of our framework to prototype its system, but had to commission its own dedicated architecture to implement the resulting design. This was one of the things that spurred us into redeveloping Naked Objects to make it suitable for full-scale development.

Section 2 provides a high-level overview of the Naked Object framework and describes the main benefits that you can realise from using it, in terms of both the qualities of the resulting systems, and improvements to the design and development process. This section concludes with a collection of Frequently Asked Questions (perhaps we ought to call them Frequently Raised Objections) that we have encountered over the last couple of years.

The second Case study shows an early prototype for a reservations system for Executive Car Services. This case provides a visual explanation of the close correspondence between the user's view of the naked objects and the structure of the underlying application written in Java. If you want a very rapid introduction to what the framework does, this is a good place to start.

Section 3 provides an introduction to programming with the Naked Objects framework. This section is written for Java programmers. Where possible the programming techniques are illustrated using the system described in the previous case study, the complete code for which is provided with the Naked Objects framework.

The next Case study describes the experience of Safeway Stores, the fourth largest supermarket chain in the UK. Safeway initially started exploring Naked Objects as a means to strengthening the object-modelling skills of its Java developers, and has since gone on to use the framework both for application prototyping and for implementation. The case describes how Safeway interfaced Naked Objects to Enterprise Java Beans and has deployed this combination with performance levels approaching that of traditional mainframe-based transaction-processing systems.

Section 4 looks at the design and development process for a Naked Objects project. We recommend that you manage the project in three phases: exploration, specification, delivery. The last two can be managed within the context of an existing methodology, be it the Unified Process or Extreme Programming (though we highlight a number of specific synergies with the latter). However, our particular approach to Exploration is unique - and can deliver some extraordinary benefits in its own right.

This is followed by a Case study describing some experiences from such an exploration phase conducted at a large bank. In particular this case looks at how naked objects fare in a domain that traditionally has been dominated by a process-oriented view of the business.

Section 5 takes a brief look at what the future holds for Naked Objects. The framework is constantly being improved and new facilities added, driven by the needs of the user community and developed by interested open source developers. We explain where to look for more information, how to get involved in the development process, and various ways in which the framework might be extended.

The final Case study concerns a Norwegian conglomerate, Norsk Hydro, that used the Naked Objects framework to build a highly graphical prototype, in which all user actions were invoked on objects within a map representation of the European electricity network. This involved adding another viewing type to the framework, but once that was done the entire business application was written without a single line of code referring to the user interface.

At the back of the book are a number of useful Appendices, the first of which takes you through the process of installing the framework and building an ultra-simple application step by step.

You can download the Naked Objects framework and further documentation from our website. The Naked Objects framework is evolving rapidly. We've restricted the contents of this book to the aspects of the framework that we believe are now reasonably stable. Any necessary updates will be provided on the website.

As an open source project we hope that you will not only make use of the framework and its associated techniques, but think about contributing in some way to its ongoing development. In the meantime: enjoy!