Custom View


You are exploring a live domain model and find some interesting information.


How do you make it easy to find interesting information again?


Navigating to the data you want to reach may entail a sequence of operations, either clicking in views, or evaluating Playground snippets, to reach a new Inspector instance.

The sequence of steps may be cumbersome to follow repeatedly.


Turn interesting data into a viewable entity . Extract the navigation steps into a new custom view for the moldable object you start navigating from. Possibly start with a simple forward view to an existing view of the target data, and later refine this into a dedicated view.


A simple example is the view of the state of the stack of the StackMachine.

In this example, we must navigate to the stack slot to see the stack items.

By creating a forwarding view, we “lift” the view we want to the StackMachine itself:

Pretty much any view can be seen as an example of this principle. Consider the example of Working with a REST API: the GitHub case study. In the example below, the Repositories view is obtained by navigating to a list of repositories that are created programmatically.

By lifting this code into the GhOrganization GhEntity subclass: #GhOrganization instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-Demo-GitHubAPI-Model' class and creating a dedicated view, we can explore the repositories without having to first navigate to a collection of repositories.

Similarly, in the GtLudoRecordingGame GtLudoGame subclass: #GtLudoRecordingGame instanceVariableNames: 'moves' classVariableNames: '' package: 'GToolkit-Demo-Ludo-Model' , many of the views are lifted from collaborating objects to eliminate the need for navigation when exploring. The views for Players , Squares , Tokens and Moves all replace the need for navigation.


A custom view exposes information about a domain that can otherwise be hard to find. Custom views become an intrinsic part of a software system, thus turning it into an Explainable System.

You need a Moldable Tool into which you can dynamically plug custom views.

Related patterns

Sometimes repeated navigation code does not lead to a view but rather an action that is performed. In this case, instead of adding a custom view, a Custom Action may be needed.