Skip to content

Separation of Concerns

All good software engineering starts with good separation of concerns. This means knowing what the responsibilities are within the feature and dividing them accordingly between the various actors. In our case, the actors include:

  1. The Unsplash Store: it makes the API calls to the Unsplash client and fetches the details.
  2. The API client: responsible for making the server calls, which is done through the pub pub package.
  3. The Widgets: rendering surface for the information that is fetched from the API calls and serviced through the store.
Information Flow

Store

The Unsplash Store internally uses the Unsplash Client to make calls to the server and fetch all the photos. For this it needs the API key to access Unsplash, which is set up in the init() method of the FeatureDescriptor. You might have seen this in the article on the FeatureDescriptor.

Widgets

The widget layer always talks to the store and never has direct access to the API client. This is very intentional and also abstracts the details of making server calls from the widgets. Ultimately, what the widgets care about is simply having the information that is to be shown on the screen.

In this feature, we have widgets like the PhotoCard, PhotoDetail and CollectionGridView which act as a simple Design System layer for the screens.