Skip to main content

Design Patterns for better code - Mediator Design Pattern

Comments

Popular posts from this blog

Design Patterns for better code - Null Object Design Pattern

Null being a part of programming languages is a billion dollar mistake. -Tony Hoare Writing everyday code irrespective of Language used (either be C# or Java or Python) we write null checks. Well we write null checks so often that a study estimates on an average one developer gives 5% of his entire development time to null checks only. So we can think of the importance of null checks. It's also the main problem of production issues specially for Junior developers.  Well writing null checks is not a problem until 100 lines of code contains 20 lines of null check code 😀 To reduce the number of lines for null checks, so that developer only focus on business logic instead of null check, Null Object design pattern was invented. Let's look at how we can use Null Object Design Pattern for our Invoice Application. Here we have different types of Invoice logic written in Separate Invoice classes (EmailInvoice, PDFInvoice, SMSInvoice). The User will choose the Invoice Type at runti...