From 0 to 1: Design Patterns - 24 That Matter - In Java

An intensely practical, deeply thoughtful and quirky look at 24 Design Patterns. Instructors are ex-Google, Stanford.
4.2 (95 ratings) Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
1,512 students enrolled
$19
$50
62% off
Take This Course
  • Lectures 63
  • Length 11.5 hours
  • Skill Level All Levels
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 10/2015 English

Course Description

  • Prerequisites: Basic understanding of Java
  • Taught by a Stanford-educated, ex-Googler, husband-wife team
  • More than 50 real-world examples

This is an intensely practical, deeply thoughtful, and quirky take on 24 Design Patterns that matter.

Let’s parse that.

  • The course is intensely practical, bursting with examples - the more important patterns have 3-6 examples each. More than 50 real-world Java examples in total.
  • The course is deeply thoughtful, and it will coax and cajole you into thinking about the irreducible core of an idea - in the context of other patterns, overall programming idioms and evolution in usage.
  • The course is also quirky. The examples are irreverent. Lots of little touches: repetition, zooming out so we remember the big picture, active learning with plenty of quizzes. There’s also a peppy soundtrack, and art - all shown by studies to improve cognition and recall.
  • Lastly, the patterns matter because each of these 24 is a canonical solution to recurring problems.


What's Covered:

  • Decorator, Factory, Abstract Factory, Strategy, Singleton, Adapter, Facade, Template, Iterator, MVC, Observer, Command, Composite, Builder, Chain of Responsibility, Memento, Visitor, State, Flyweight, Bridge, Mediator, Prototype, Proxy, Double-Checked Locking and Dependency Injection.
  • The only GoF pattern not covered is the Interpreter pattern, which we felt was too specialized and too far from today’s programming idiom; instead we include an increasingly important non-GoF pattern, Dependency Injection.
  • Examples: Java Filestreams, Reflection, XML specification of UIs, Database handlers, Comparators, Document Auto-summarization, Python Iterator classes, Tables and Charts, Threading, Media players, Lambda functions, Menus, Undo/Redo functionality, Animations, SQL Query Builders, Exception handling, Activity Logging, Immutability of Strings, Remote Method Invocation, Serializable and Cloneable, networking.
  • Dependency Inversion, Demeter’s Law, the Open-Closed Principle, loose and tight coupling, the differences between frameworks, libraries and design patterns.

Talk to us!

  • Mail us about anything - anything! - and we will always reply :-)

What are the requirements?

  • There are no pre-requisites other than curiosity - about Design, about Patterns, about Life :-)

What am I going to get from this course?

  • Identify situations that call for the use of a Design Pattern
  • Understand each of 24 Design Patterns - when, how, why and why not to use them
  • Distill the principles that lie behind the Design Patterns, and apply these in coding and in life, whether or not a Design Pattern is needed
  • Spot programming idioms that are actually built on Design Patterns, but that are now hiding in plain sight

What is the target audience?

  • Yep! Engineers - from street-smart coders to wise architects - ought to take this course. After this class, you'll look at software design with a new pair of eyes.
  • Yep! Product Managers ought to take this course - you will learn to understand the 'how' of Software Design without being constrained by it.
  • Yep! Technology executives and investors who don't write code ought to take this course - after this you will always have an intelligent point-of-view on software, and won't find your eyes glazing over when its time to talk nitty-gritty
  • Computer Science majors (undergrad or grad) - if you are among the folks that make 'real world example Observer Pattern' such a common search phrase on Google, this is precisely the place for you.
  • Yep! Journalists, Wall Street types or IP lawyers seeking to understand recurring patterns of problems and solutions in technology.
  • Yep! If you are prepping hard for software engineering interviews :-)
  • Nope! This course is not right for you if you are looking for a Programming 101 course. That's not because there are pre-requisites, but simply because a Programming 101 course focuses on syntax, and on doing, while this course focuses on design, and on thinking.

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: What are Design Patterns?
06:40

We - the course instructors - start with introductions. We are a husband-wife team, studied at Stanford, and spent several years working in top tech companies, including Google, Flipkart and Microsoft.

Next, we talk about the target audience for this course: Engineers and Product Managers, certainly, but also Tech Executives and Investors, or anyone who has some curiosity about technology.

By the end of this class, students will be able to: spot situations where design patterns lead to better designs, and deploy those patterns effectively. Product managers and executives will learn enough of the 'how' to be able intelligently converse with their engineering counterparts, without being constrained by it.

That's it for preliminaries - with this we plunge right in!

  • "Design Patterns are canonical solutions to recurring problems". We start by understanding what Design Patterns are, and why these patterns are still so popular decades after they were first put together.
  • Design Patterns, Libraries and Frameworks: A martial arts analogy illustrates the difference
  • Broad Categories of Patterns: We also take a quick swing through the major categories of Design Patterns - creational, structural and behavioral.
07:03
Design patterns are often divided into three categories - creational, behavioural and structural. Let's understand what these categories represent.
04:14

'Program to interfaces, not implementations' said Eric Gamma. Of course he was right.

05:31

Code should be open for extension but closed for modification. How can this be achieved? Well, there are 3 possible ways: inheritance, delegation, and composition.

04:39

Like children, code should only talk to friends, never to strangers!

05:46

Always rely only on abstractions, never on details. Oh - and don't call us, we'll call you. That's how Hollywood works, and that's how the Hollywood Principle reads.

1 question



12:17

We will cover a fair bit of ground in this class. Here's a quick look at what's coming your way.

Section 2: The Strategy Pattern
14:25
The Strategy Design Pattern helps modify the behavior of classes at run-time - and does so using composition (member variables) rather than inheritance (parent classes). We examine how the Collections.sort method embodies the Strategy Pattern.
10:23

Dependency Injection is a widely-used design technique that is closely related to the Strategy Design Pattern. This lecture details how dependency injection is used to specify complex user interfaces in Java FX using an XML representation called FXML. This is a common technique used in modern UI frameworks in Java.

10:44

Dependency Injection is a widely-used design technique that is closely related to the Strategy Design Pattern. This lecture continues detailing the use of dependency injection to specify complex user interfaces in Java FX, and then ties back to the Strategy Design Pattern

Quiz : Strategy Pattern
1 question
Quiz : Strategy Pattern
1 question
Quiz : Strategy Pattern
1 question
Section 3: The Decorator Pattern
08:43
The Decorator Design Pattern comes in handy when a class hierarchy needs to take into account multiple independent implementation details. One decorator class for each independent variable, each of which can be created from another. All decorator objects implement the same interface of course.
13:26
The Java File APIs are a classic use-case of the Decorator Pattern - it would be difficult to imagine an efficient way to implement these APIs without using the Decorator.
Quiz : Decorator Pattern
1 question
Quiz : Decorator Pattern
1 question
Section 4: The Factory Pattern
14:57

Let's say your organization is moving from one database (say MS SQL-Server) to another (say Oracle). How would you use the Factory Pattern to minimize the effort needed for this enormous move?

05:43
We continue with our planning for the move to Oracle from MS-SQL Server - we see how the Decorator Pattern, combined with the use of reflection and config files, can save us many late nights and bug bashes
16:03
The Abstract Factory Pattern is closely related to the Factory Design Pattern, but is a better fit when entire different hierarchies of related objects need to be created. We also examine the Open-Closed Principle, which specifies that classes should open for extension but closed for modification.
08:48

Let's see an example of how we can use the Abstract Factory pattern to create families of classes. We'll work with the same example of moving from Microsoft to Oracle as our database provider.

15:47
These days, the Factory Design Pattern is increasingly implemented via Reflection, so it makes sense for us to understand the pros, cons, and complexities of Reflection
10:33
As previously discussed, these days, the Factory Design Pattern is increasingly implemented via Reflection. In this video, we describe a specific use-case when Reflection is exactly the right tool for what we are seeking to accomplish.
Quiz : Factory Pattern
1 question
Quiz : Factory Pattern
1 question
Quiz : Factory Pattern
1 question
Quiz : Factory Pattern
1 question
Section 5: The Singleton Pattern
09:05

The Singleton Pattern is beautiful - a unique object, usually implemented via a private constructor and a static getter method.

13:14

The Singleton Pattern is very elegant in its construction, but there are important nuances that we should be aware of, specifically related to multi-threading and to class loaders in Java. In this lecture, we explore how a concurrency-related Design Pattern called Double-Checked Locking can come in handy while implementing the Singleton in a multi-threaded environment.

12:17
The Singleton Pattern in a multi-threaded environment is surprisingly hard to get exactly right - we dig deeper into the subtleties - this requires us to understand the exact semantics of the Synchronized keyword.
13:51

We tie together the different threads (bad pun!) we had going on multi-threading, and present a final thread-safe implementation.

Quiz : Singleton Pattern
1 question
Quiz : Singleton Pattern
1 question
Quiz : Singleton Pattern
1 question
Quiz : Singleton Pattern
1 question
Section 6: The Adapter Pattern
05:18

The Adapter Pattern is often used in converting data from one representation to another: we understand how an adapter can help with loose coupling of classes. Also, classes need not be rewritten to support additional interfaces, a new adapter is all that is needed.

07:07
We continue with the benefits of adapters, and see a simple example of adapters - wrapping arrays so that all of the powerful functionality available for working with Collections can be easily applied to arrays too.
12:59

The Adapter Pattern is simple: an adapter takes in an object (usually singular) of one interface, and gives back another object (also singular) of another interface.

Quiz : Adapter Pattern
1 question
Section 7: The Facade Pattern
15:53

The Facade Design Pattern hides in plain sight: complicated operations (such as networking and url handling) used to be incredibly onerous in C, and are incredibly simple in Java. We have the Facade Pattern to thank for this.

Quiz : Facade Pattern
1 question
Quiz : Facade Pattern
1 question
Section 8: The Template Pattern
16:10
The Template Design Pattern is perfect when we need to specify a complex algorithm, and leave room for a client to plug in a specific implementation for a specific step. We examine this via an example from Natural Language Processing: automatically summarizing a document. We see how classic NLP algorithms can be plugged into the more general summarization algorithm via the Template Pattern.
15:19
The Template Pattern was the precursor to Frameworks - both embody the Dependency Inversion Principle, where high-level objects say to low-level objects "don't call us - we'll call you".
05:58
The Template Pattern was the precursor to Frameworks - both embody the Dependency Inversion Principle, where high-level objects say to low-level objects "don't call us - we'll call you". We consider Java FX, a framework where the client plugs in code into a specific method, the framework does the rest (which is a lot!)
Quiz : Template Pattern
1 question
Section 9: The Iterator Pattern
12:25
The Iterator Design Pattern has become part of the daily idiom of programming; iterators offer a standard way to access elements in a collection, independent of the implementation of the collection.
12:02
We look at how generics help enforce type-safety in collections - and how iterators are correspondingly also generic.
07:58

We explore in further detail the differences between Internal and External Iterators, and also how the for-each operator has become a standard part of language support for iterators in Java, Python and other major languages

15:48
We continue look at how Python and Java have explicitly added language support for iterators, and also examine how iterators in Python are inextricably linked to the language (far more than in Java)
Quiz : Iterator Pattern
1 question
Section 10: The MVC Paradigm
13:59
The Model-View-Controller (MVC) paradigm is ubiquitous in UI programming; along with the Observer and Command patterns, MVC has practically defined modern User-Interface programming.
08:11

Models contain data, views define the UI, and controllers respond to user input and update the model and the view. We see how this plays out in a Media Player application.

08:42

Models contain data, views define the UI, and controllers respond to user input and update the model and the view. We see how this plays out in a Charting application.

Quiz : MVC
1 question
Quiz : MVC
1 question
Quiz : MVC
1 question
Section 11: The Observer Pattern
09:34

The Observer Pattern, along with the MVC and Command Patterns, has practically defined modern UI programming. Publishers publish updates when their state changes, and Subscribers can listen in on these updates. An event is fired when the state changes, and the listener responds via a Command object called the event listener code.

07:06

After the relatively new-age Properties and Bindings, we turn to classic use-cases of the Observer Pattern, in User Interface elements such as mouse click handlers and tree views. The Observer Pattern is used in clever ways in Swing and other UI frameworks, allowing the user great flexibility in responding to a variety of different user actions.

10:34

We dig deep into the interplay between the Model-View-Controller and the Observer Pattern, tied together via the Command Pattern. These three patterns have, together, defined modern User-Interface programming

15:17

Models contain data, views define the UI, and controllers respond to user input and update the model and the view. We see how the Observer Pattern plays a crucial role in seting up this MVC example for success - for instance, a slider that wires up the volume of the media is just about 1 line to set up correctly.

Quiz : Observer Pattern
1 question
Quiz : Observer Pattern
1 question
Quiz : Observer Pattern
1 question
Quiz : Observer Pattern
1 question
Quiz : Observer Pattern
1 question
Quiz : Observer Pattern
1 question
Quiz : Observer Pattern
5 questions
Section 12: The Command Pattern
11:50

The Command Design Pattern is used to separate an action from its execution. A seemingly abstract idea, and an incredibly powerful one. The Command Pattern, along with the Observer and MVC Patterns, has practically defined modern User Interface Programming.

09:51

The idea of encapsulating an action in an object can be used to retro-fit functional programming support into an object-oriented language like Java. Lambda functions, in particular, are a functional programming concept that has become a cross-over hit in the object-oriented world of Java.

10:04
We continue with functional-programming support in Java. In addition to lambda functions, there are also powerful aggregate operators - map, foreach and filter - that we can use to chain lambda functions together
14:29
The Command Design Pattern is used to separate an action from its execution. We see how this idea is used as the starting point of most modern Threading libraries. Java has old-school and new ways of getting Multi-threading done, and both of these start with the Command Pattern.
14:39
The Command Design Pattern is used to separate an action from its execution. This idea serves as the basis of two really neat applications: implementing Undo, and logging activity. Let's see how.
Quiz : Command Pattern
1 question
Quiz : Command Pattern
1 question
Quiz : Command Pattern
1 question
Quiz : Command Pattern
1 question
Quiz : Command Pattern
1 question
Section 13: The Composite Pattern
09:02
The Composite Pattern works best when a tree-shaped class hierarchy needs to be set up; This is understood best via the Decorator Pattern, which in turn works best when an onion-like class hierarchy (similar objects wrapped inside each other) works best. So we start with a segue into the Decorator Pattern, specifically with the objective of making the Composite clear via juxtaposition.
17:39

We finally get to the Composite Class Hierachy, and study the tree-shaped class structure it usually results in.

15:19

Two canonical examples of the Composite Pattern: Swing UI containers, and Transitions in Java FX. Swing containers (JPanels) contain other containers, leading to a tree-like object structure. Likewise, in Java FX, two special types of transitions - parallel and sequential transitions - contain other transitions, leading to a nested object hierarchy.

Quiz : Composite Pattern
1 question
Section 14: The Builder Pattern
15:48
The Builder Pattern works best when a complicated object needs to be set up, with inputs in its construction flowing in over time (because this information is not all available when the object is constructed, the Builder pattern usually is marked by constructors that do little, if anything). We start with a simple example, of an HTML Builder.
09:42
A more substantial example of the Builder Pattern, this time put to use to build SQL queries. This is a classic and canonical example of the Builder Pattern.
13:05

We continue with our use of the Builder Pattern to build SQL queries. This is a classic and canonical example of the Builder Pattern. In this lecture, we show the Builder Pattern would work in this case, and how it would solve the issues we encountered with our previous approaches.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Loony Corn, A 4-person team;ex-Google; Stanford, IIM Ahmedabad, IIT

Loonycorn is us, Janani Ravi, Vitthal Srinivasan, Swetha Kolalapudi and Navdeep Singh. Between the four of us, we have studied at Stanford, IIM Ahmedabad, the IITs and have spent years (decades, actually) working in tech, in the Bay Area, New York, Singapore and Bangalore.

Janani: 7 years at Google (New York, Singapore); Studied at Stanford; also worked at Flipkart and Microsoft

Vitthal: Also Google (Singapore) and studied at Stanford; Flipkart, Credit Suisse and INSEAD too

Swetha: Early Flipkart employee, IIM Ahmedabad and IIT Madras alum

Navdeep: longtime Flipkart employee too, and IIT Guwahati alum

We think we might have hit upon a neat way of teaching complicated tech courses in a funny, practical, engaging way, which is why we are so excited to be here on Udemy!

We hope you will try our offerings, and think you'll like them :-)

Ready to start learning?
Take This Course