Chapter 1. Begin Thinking Functionally
A man with a chainsaw enters a hardware shop and says to the assistant: "Two weeks ago, you told me this thing would allow me to chop down 30 trees in an hour. But I can only manage one tree. I want to return this for a refund". The assistant says "let me see" and starts the chainsaw. The visitor jumps back screaming "What's that noise?!"-An old joke
The joke opening my narrative is very relevant to the subject of this chapter: in order to achieve the benefits expected from the use of any tool, you should know how to use that tool the right way. Moreover, an advanced tool used in a wrong manner may be even less productive than the corresponding simple one used the right way. A hammer outperforms a microscope when it comes to nailing wooden boards together.
Chapter 1, Begin Thinking Functionally, should help you develop a manner of solving day-to-day software engineering problems that are usually associated with the functional paradigm. This means presenting the solution by verbs rather than nouns, avoiding the use of mutable entities to carry states, avoiding relying upon side-effects, and minimizing the amount of moving parts in the code.
In this chapter, we will cover the following topics:
- The multi-paradigm nature of F#
- A comparison of F# paradigms by solving the sample problem applying:
- An imperative monolithic solution
- An object-oriented solution
- A functional solution
- Properties of the functional paradigm
I will wrap up this chapter with a list of key concepts to retain and recognize, as well as skills to reuse in your functional solutions.