Viewable data wrapper


When you explore data with a platform such as GT, the views you obtain reflect the low-level data structures used to represent the data, not the underlying domain concepts. How can we add appropriate high-level views to the 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.


Wrap each kind of data in a dedicated class reflecting the problem domain. As you explore the data, introduce custom views 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.

Related patterns

As you explore the wrapped data, you can prototype new behavior from the Contextual playground and introduce a Viewable entity for each new kind of information you discover.