Modeling

Learn about the concepts of modeling and how models help to write properties.

What is modeling?

Modeling essentially requires us to write a simple implementation of our code, even if it is algorithmically inefficient. The model should be so simple that it is obviously correct. We can then optimize the real system as much as we want. As long as both implementations behave the same way, the complex and the obviously correct implementation should work equally as well. The complex implementation, however, probably also works faster. So, for code that does a conceptually simple thing, modeling is useful.

Example

For our example let’s look at the function that we created in the previous chapter, the biggest/1 function which returns the largest value in a list. The function looks like this:

Get hands-on with 1200+ tech skills courses.