Chapter 14. Models: working with data

 

This chapter covers

  • Building models from data
  • Using the same data in multiple projects
  • Switching between data files
  • Specifying map data in The Crypt

In chapter 13, you saw how you can use modules to break a program into separate files. You can then work on the modules independently, easily switch between modules, and reuse them across multiple projects. You can even publish your modules and import published modules written by others.

This chapter maintains that spirit of modularization and reuse. You look at moving data out of constructors and functions. You represent the data simply so that multiple apps can use the data, even if the apps are written in different programming languages. You then consider how to feed that data into constructors and functions to build models that add extra functionality. Finally, you define map data for The Crypt, adding challenges to make the game more engaging.

14.1. Building a fitness app—data and models

Your development work has really gotten you noticed (The Fruitinator! was a global smash), and you’re now part of a team developing a fitness application. Health-conscious users track their exercise, logging the date and duration of each session.

Mahesha
120 minutes on February 5th, 2017
35 minutes on February 6th, 2017

2 hours 35 minutes so far.
Great work!

14.2. The Crypt—separating map data from the game

14.3. Summary