concept datum in category design

appears as: data, data
Object Design Style Guide

This is an excerpt from Manning's book Object Design Style Guide.

An object can contain data. This data will be stored in properties. A property will have a name and a type, and it can be populated at any moment after instantiation. A common place for assigning values to properties is inside the constructor.

Figure 2.1. This UML-style sequence diagram shows how services will call other services, passing along other types of objects as method arguments or return values. Inside a service method, such an object may be manipulated, or a service may retrieve data from it.

The rules described in this chapter apply to entities and value objects; we care a lot about the consistency and validity of the data that ends up inside such objects. These objects can only guarantee correct behavior if the data they use is correct too.

The way you can use such an object is, for example, by populating it with the data submitted with a form, and then passing it to a service, which will schedule the meetup for the user. An example implementation can be found in the following listing.

Listing 3.37. Populating the ScheduleMeetup DTO and passing it to a service
final class MeetupController
{
    public function scheduleMeetupAction(Request request): Response
    {
        formData = /* ... */;                        #1
 
        scheduleMeetup = new ScheduleMeetup();       #2
        scheduleMeetup.title = formData['title'];
        scheduleMeetup.date = formData['date'];

        this.scheduleMeetupService.execute(scheduleMeetup);

        // ...
    }
}

The service will create an entity and some value objects and eventually persist them. When instantiated, these objects will throw exceptions if anything is wrong with the data that was provided to them. However, such exceptions aren’t really user-friendly; they can’t even be easily translated to the user’s language. Also, because they break the application’s flow, exceptions can’t be collected and returned as a list of input errors to the user.

Always make sure that clients can’t provide data that is meaningless. What counts as meaningless can be phrased as a domain invariant too. In this case, the invariant is, “The latitude of a coordinate is a value between –90 and 90 inclusive. The longitude of a coordinate is a value between –180 and 180 inclusive.”

Usability Matters: Mobile-first UX for developers and other accidental designers

This is an excerpt from Manning's book Usability Matters: Mobile-first UX for developers and other accidental designers.

1.2.2. Input includes all ways data and information get into the app

Input encompasses all the ways of supplying data and instructions to the app. It’s the first of the components that relate to the high-level structure of the app. Figure 1.2 shows these components (in bold) and their relationships.

Figure 2.15. An example crash report showing many crashes and hangs. The value doesn’t come from capturing data, but from acting on the information revealed.

By not having data locked in a single app, you make it easier for people to do what they want and to achieve the outcome or value they’re using the app for. This might be as simple as sharing data from one app with another, or it could be the apps serve as different steps in a larger process. They could also be from a single company and use the same database. The following are different ways that your app can receive input from other apps:

  • Common local data— Data can be in a shared location on the filesystem and can be anything from a custom file format to a shared database. Avoid locking these files or changing a format to one that isn’t supported by all apps that use the data.
  • Native sharing— Every mobile OS has a built-in way of sharing common data types. Support sending and receiving data in this way if relevant to your app and the needs of the people using it.
  • 7.1.1. Dealing with the data you directly request

    Requesting data is easy. When returned successfully, the app can function as desired. It’s when the app doesn’t receive the data as expected that you need to consider because this can affect the experience a person has with your app. We’ll look at these scenarios in this section:

    Listing 8.1. Data with placeholder information to use before the image loads
    {
    "user": {
        "name": "Matt Lacey",
        "imageUrl": "http://example.com/images/3764532146873248932.jpg",
        "imageSize": "960x640",
        "imageColor": "AF927F",                                                   #1
        "imagePlaceholder":                                                       #2
         ["EAEAE3","F9F7F3","BD9586","E8E8E0","AB8255","956537","C2C4BC","F5F5F6",#2
         "8E4135","E5DAD1","AC8257","906738","B3B0A4","ABA4AA","7D4535","DDb18D", #2
         "A04D18","89633D","9D929A","B0B7C4","654033","C0977E","9D6043","583A28"  #2
         ],                                                                       #2
        ..... // other properties omitted
      }
    }