Chapter 4. Writing a real application
This chapter covers
- Putting primitives together to write real code
- A typical development process
- Modularity
- Testability
We’ve introduced FRP with some contrived examples and shown you some more realistic GUI code. Now we want to show you how to write a real-world FRP application, this time in the industrial space. In this chapter, you’ll develop a petrol pump.
It can be difficult to find the right example for FRP. FRP’s pretensions to stardom conglomerate around the notion that it deals with complexity, but this doesn’t manifest in a small example. If the example is too simple, you’ll say, “That was a weird way of doing things for no apparent benefit.” If the example is too big, it can be a lot of work for you. We chose the petrol pump idea to strike a balance: the size is about right, it should be easy to follow because it’s a familiar real-world application, and the level of complexity is enough for our purpose.
Note
This example uses industry-standard development methodology: you’ll add features one by one without much deliberate design. We’ve left out refactoring; refactoring is simple in FRP, and we’ll cover this subject in chapter 13.