Design Patterns are a priceless tool for professional developers. In this course, you'll learn the fastest way to understand four of the most advanced patterns: Adapter, Decorator, Proxy, and Composite.
Design Patterns are a must-have in any developer's bag of tricks. The most useful patterns, however, are also the hardest to understand. Structural patterns, in particular, are both extremely useful and somewhat difficult to master. In this course, Design Patterns Playbook: Structural Patterns, you'll discover the ins and outs of four of the most advanced structural patterns to utilize in practice. First, you'll learn the structural patterns that tell apart the master programmer from the beginner. Next, you'll delve into understanding patterns through practical examples that use pictures and code together. Finally, you'll explore a brief overview of what Design Patterns are and why they are so useful. By the end of this course, you'll know how to wield Adapter, Decorator, Proxy, and Composite to make your code easier to understand and maintain.
Course Overview Hello from Paolo Perrotta. Welcome to the Design Patterns Playbook. This is a patterns training with a difference. It focuses on just a few patterns that are quite advanced, so many developers tend to ignore them. And that's a pity because they are really useful. These are the so-called structural patterns, the ones that help you decide how your classes and objects are related to each other. You should definitely know about that. So here is my bet. I will teach you the most important structural patterns in just about 1 hour. We can make it with the help of a lot of pictures. With the right diagram, even these intricate patterns suddenly look easy. And once you wrap your head around them once, they will stay in your programming quiver forever. So in just 1 short hour, you will get to know some of the most important, most advanced patterns, adapter, decorator, proxy, and composite. You will understand when and how to use them with concrete examples. You will learn visually. You will see code, and at the same time you will see the structure of the patterns. And we'll even find a few minutes to talk about design patterns in general and why they are so useful. I used both Java and C# in this training. They're similar languages, so if you know either language, then you're all set. You will be able to follow all the examples. So if you want to learn about structural patterns, and still be done in time for lunch, you've come to the right training. Let's dive in.
Why Design Patterns? The original idea of design patterns came from, guess what, architecture. I mean civil architecture, not software architecture. In the 70s, this Austrian architect, called Christopher Alexander, noticed that there are things in our way of building that stayed the same pretty much everywhere and throughout history. For example, take the idea of the promenade, the walking street. Ancient Roman cities had this large street where people could take a walk and mingle with other people, and so do most modern cities today, all over the world. Sure, no two of these promenades look exactly the same, but the basic idea stays the same. Technology changed an awful lot, culture, even the concept of a city changed, but the promenade seems to be a constant. So Alexander said this is a common, reusable solution to a common problem. Let's call it a pattern. And he could see many such patterns all the way from city planning down to individual rooms. For example, he said rooms that feel cozy and comfortable tend to have windows on two sides. This is a common pattern. Let's give it a name and study how it works. So he gathered a few collaborators together, and they wrote a book that collected hundreds of such patterns. So that's what a pattern is. It's a solution to a design problem that works well in general, so you see it applied over and over again with variations. It's not something you invent from scratch, more like something you discover while looking at existing solutions, and then you can give it name and discuss when it works, when it doesn't, concrete examples, and so on. This was a brilliant idea, but for some reason it never really spread much amongst architects. And then after a few years something unexpected happened.