Briefly about Types
Learn how types can make our code better and more understandable.
We'll cover the following
Overview
Throughout the preceding lessons, we’ve seen that types play an important role in making our code safer by preventing certain types of bugs at compile time. Similarly, they can expedite development with faster feedback. Instead of waiting for unit or integration tests, our IDE will immediately tell us that what we’re doing is wrong. As a bonus, statically typed languages can offer better performance, especially for long-running applications.
Let’s examine how types help make our code more understandable. We’ve already seen how defining input and return types more explicitly makes code easier to reason. Rather than employing guesswork, we know what kind of behavior to expect. Furthermore, in functional programming or functionally oriented code, types help users understand and change the code, even if they don’t have the luxury of writing the code. Let’s consider an example.
Get hands-on with 1400+ tech skills courses.