Advanced Defensive Programming Techniques
This course will lead you step by step through the process of developing defensive design practices, which can substitute common defensive coding, for the better of software design and implementation.
What you'll learn
How often do you have to defend from nulls, zeros, surprising cases hitting switch instruction, impossible else branches, and so on? Is your life a struggle with issues caused by unexpected data or invalid system state? In this course, Advanced Defensive Programming Techniques, you'll learn how to defend by means of design, so that almost all explicit defensive code can be happily removed. First, you'll discover how to build validation. Next, you'll explore how exactly to design a public interface. Finally, you'll cover how to unify error flows, so nothing unpredictable can take you by surprise. By the end of this course, you'll have the necessary knowledge to efficiently develop your own defensive design practice.
Table of contents
- Reaping the Benefits of Constructor Validation 4m
- Defending in Property Setters 5m
- Understanding Distinct Kinds of Properties 3m
- Defending in Complex Mutations 4m
- Function Domains Revisited 4m
- When Constructor Depends on Multiple Objects 4m
- Creating Objects in Small Steps 7m
- Persistence and Parameterized Constructors 6m
- Summary 3m
- The Reasons to Avoid Enumerations 6m
- Alternatives to Enumerations 4m
- Converting Enumeration to a Class 5m
- The Reasons to Never Stringify Data 6m
- Reaping the Benefits of String Encapsulation 3m
- Avoiding Primitive Types Altogether 3m
- Example: Modeling Money 4m
- Persistence: Small-scale CQRS and DDD 5m
- Demonstrating Persistence 7m
- Summary 3m
- Encapsulating State 7m
- Keeping Related Data Together 6m
- Turning Chained Ifs into the Chain of Rules 5m
- Making Friends with Regular Expressions 3m
- Replacing Branching with Regular Expressions 6m
- Moving Expressions out to Configuration 4m
- Persistence: Creating and Updating Domain Objects 8m
- Summary 3m
- Understanding the Role of Null 4m
- Why Compilers Still Rely on Null? 4m
- Do Not Return Null from a Method 7m
- Using Callback on Optional Content 4m
- Overloading Existing APIs to Never Return Null 5m
- Returning an Optional Object 5m
- Implementing Custom Option Type 5m
- Consuming the Option 6m
- Persistence: Creating Complex Domain Objects 4m
- Summary 2m
- What’s Wrong with Status Codes? 5m
- Understanding Effects of Throwing Exceptions 4m
- What Exceptions Are Not Meant to Do 7m
- Leave Nothing Exceptional in Exceptions 7m
- Returning a Polymorphic Type Instead of an Exception 5m
- Separating Positive and Negative Return Values 5m
- Inventing the Either Type 6m
- Consuming the Either Type 3m
- Summary 4m