Instruction

Learning About Classes

In the rest of this module, you’ll imagine that you’re creating a MetMuseum app to search for and display art objects by working with data from The Metropolitan Museum of Art Collection API. Each art object has a huge number of properties, but your app will only need to use a few of these.

Every art object has a unique objectID. When you search for art objects that match a user query, you’ll first fetch an array of objectID, then loop over this array to fetch each object’s data. You won’t be doing searches in the app. Instead, you’ll be passing the data of a single art object to the custom type you’ll create.

Your app will display the art object’s title. As a courtesy to the museum, you should also display the object’s creditLine — a description of how the museum acquired the object.

You’ll definitely want to show an image of the art object. The primaryImageSmall property is the URL of the object’s image. For example, this is what you get when you load https://images.metmuseum.org/CRDImages/ep/web-large/DT1567.jpg in a browser:

Image: Wheat Field with Cypresses, Purchase, The Annenberg Foundation Gift, 1993
Image: Wheat Field with Cypresses, Purchase, The Annenberg Foundation Gift, 1993

However, not all art objects have image URLs. Some art objects are not in the public domain, and their primaryImageSmall value is an empty string. Your app must load the art object’s objectURL to view its page at metmuseum.org. For example, https://www.metmuseum.org/art/collection/search/13061:

Cypress and Poppies web page
Cypress and Poppies web page

Your app will model this data by defining a MuseumObject type with these properties, and use the isPublicDomain property to implement a showImage method.

It’s time for you to define the art object in the demo.

See forum comments
Download course materials from Github
Previous: Introduction Next: Demo