concept datum in category dart

appears as: data, data, The data
Dart in Action

This is an excerpt from Manning's book Dart in Action.

Figure 1.2. A single-page application runs in the browser, only requesting data from the server.

The single-page applications Google Mail, Google Instant Search, and Google Maps are typical of the type of web application that Dart was designed to build. The source code for the entire application (or at least all the use cases for a major portion of the application) is loaded by a single web page. This source code, running in the browser, is responsible for building a UI and requesting data from the server to populate that UI, as shown in figure 1.2.

Figure 1.2. A single-page application runs in the browser, only requesting data from the server.

A common reason to use indexers is to have a class implement a Map interface so that properties on the class can be read as though they were part of a map, when they actually form real properties. This method allows tools such as the JSON parser, which understands maps and lists, to convert your class into a JSON representation. When data is in a JSON format, it can be sent back and forth over the web. You can make your Role class implement a Map and convert it to JSON using the code shown in listing 8.14. Although the code has snipped some of the boilerplate methods required by the Map interface, you must provide all of them. Listing 8.14 also uses some of the other patterns you’ve seen in this chapter, such as returning list literals and returning typed and untyped generic collections.

8.1. Working with collections of data

Much of software development is concerned with moving and processing collections of data in a type-safe manner. In the example authentication service from chapter 7, the user Alice provided her logon details to an instance of an AuthService, which returned a User object. In this section, you’ll expand on this example by retrieving user permissions for two roles: Reader and Administrator. When Alice logs on to the company blogging application to write a news item, the system needs to be able to identify that, as an Administrator, she can create and edit posts. Other users are Readers and can only read, comment on, and share blog posts. You’ll use the class hierarchy shown in figure 8.1 to achieve this.