Moldable Data Wrapper


You are working in a domain with existing data that you want to turn into an explainable system.


How do you develop custom tools for existing data?


When we explore data, we represent them using suitable low-level data structures.

Data structures (lists, dictionaries) reflect the representation of data, not their interpretation.

To analyze and explore data, we need higher-level views that reflect our understanding of the data.


W rap each kind of data using a dedicated class reflecting the problem domain entity. As you explore the data, introduce custom tools (views etc.) to the domain class that reflect answers to questions you ask about the data.


Extract the data of interest. This might be data sitting in your file system (for example, a CSV file), or data retrieved from a website.

A classical example can be seen in Working with a REST API: the GitHub case study .

We obtain a Dictionary representation of JSON data about the feenk GitHub organization:

url := ''.
json := ZnClient new get: url.
dictionary := STON fromString: json.

If we explore this object, we just see the keys and values of the raw downloaded data. From this view, of course we can explore the data by navigating the Dictionary views, or by programatically exploring other paths using the Inspector Playground, but we cannot add or tailor views to specifically support the GitHub Organization domain.

We address these problems by wrapping the raw data as a dedicated GhOrganization GhEntity subclass: #GhOrganization instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-Demo-GitHubAPI-Model' object, as follows:

GhOrganization new rawData: dictionary.

Now we can add custom views specific to this domain, for example, listing the Repositories of an organization, or the most recent GitHub events. For each new domain concept, we introduce a dedicated wrapper object, so we can navigate the entire model via the domain concepts.


By wrapping the raw domain data, you obtain a moldable object that can be customized to form part of an explainable system. Each time you navigate to other data representing further domain entities, wrap them as well, to build an explorable domain model. In case custom tools of the underlying data objects are useful, you can always recycle them and make them available to the wrapped objects as well.

Related patterns

As you explore the wrapped data, you can prototype new behavior from the Contextual Playground and introduce a Custom View for each new kind of information you discover.