
This video provides an overview of the entire course.
This video will talk about the definition of the design pattern and a brief idea about the course’s content.
• Discuss about the application we will build throughout the course
• Define Design Patterns and give a high-level overview of the course contents
The student needs to understand what their job is as a problem solver and that software is their tool. They also need to understand how a developer progresses in their career.
• Talk about the progression from basic OOP concepts to more advanced topics
• Discuss how a developer goes from a junior to a senior developer
• Discuss the important of application architecture design
The student needs to understand where design patterns started from and why they even exist. This video will traverse through the development of design patterns.
• Discuss the origin of solving problems in software development
• Understand the need for standard solutions for recurring problems
• Look at the procurement and standardization of design patterns
We will review, at a high level, the three categories of design patterns and the six design patterns that we will discuss in this course.
• Give a list of the categories and specific design patterns we will discuss
• Define and discuss the three categories of design patterns
• Define and discuss the six specific design patterns
Discuss the problem with having constructors that have a lot of parameters and how it can be difficult to work with them.
• Know the common need for classes that have many member variables
• Discuss the first choice of having a constructor with lots of parameters
• Discuss the second choice of having an empty constructor but lots of setters
Discuss the Builder Pattern in detail so the student understands the theory behind it and how it can be implemented in any language.
• Know the anatomy of a Builder class
• Talk how to set values to the builder
• Discuss how to program the Build method
Discuss how the Builder Pattern can be implemented in the Kotlin programming language.
• Demonstrate how the Builder class can be set up in our app
• Discuss how to set values and build with the builder class
• Understand how the Builder class can now be used to build objects (Outfit)
Discuss the problem of needing to have only one possible instance of a class and how we can implement that.
• Learn the properties of a single instance object
• Go through the situations where we would need a single instance object
• Give some practical example where a single instance object is appropriate
Discuss what a Singleton class looks like and some issues that can arise.
• Look at the anatomy of a Singleton class
• Understand how easy it can be to create more than 1 instance
• See the potential for memory leaks
Discuss when it is appropriate to use the singleton pattern and add a ShoppingCart class to our app Kotlin Clothes.
• Discuss situations where singleton is appropriate to use
• Build a ShoppingCart class in our app KotlinClothes
• Show how we can use the ShoppingCart class anywhere in the app
Discuss how simple it is to implement the Singleton pattern in Kotlin as opposed to other languages.
• Review the old implementation of Singleton
• Talk about the new implementation with Kotlin
• Discuss how usage of the new implementation is identical to the old one
Discuss the issues of having a class that is sub-classed many times.
• Discuss the problems with many subclasses including forgetting which is the one we need
• Look at the Factory pattern as a way to make finding the right subclass easy
• Look at the practical use cases for the factory pattern
Discuss how to create a factory method and discuss the advantages of using the factory pattern.
• See the anatomy of the factory pattern
• Skim through the advantages of using a factory to create objects
• Discuss transferring responsibility to the Factory
Discuss how to implement the factory pattern in Kotlin and create a Factory class (OutfitFactory) for our app.
• Demonstrate how to implement the factory pattern in Kotlin
• Add a factory class to our app (OutfitFactory)
• Demonstrate how to use the OutfitFactory class to create Outfit objects
Discuss what inheritance is and why it’s important to OOP. Also show scenarios where we can’t extend a function.
• Learn about the inheritance and why it’s important
• Explore the reasons to inheritance from a class
• Look at the scenarios when we can’t extend a class to add functionality
Discuss a few problems that exist with sub-classing or extending a class.
• Explore the limitation of being able to only extend 1 class
• Discuss adding functionality without enforcing the is-a rule
• Look at the limitation of changing functionality once a class is sub-classed
Discuss how the decorator patterns works, as well as advantages of using the decorator pattern.
• See the anatomy of the designer pattern
• Look at the advantages of using the decorator pattern
• Look at the ways we can now add functionality to multiple classes at once
Discuss how to implement the decorator pattern in Kotlin, as well as adding a Decorator class to our app (OutfitWithPromotion).
• Demonstrate how to implement the Decorator pattern in Kotlin
• Add a class to our app called OutfitWithPromotion
• Show how we can use the OutfitWithPromotion class in UI without affecting the integrity of the Outfit class
Begin by discussing the various logic building blocks (if-else, for, while, when) and then mention the difficulty of dealing with multi-level nested statements.
• Discuss the various logic building blocks
• Demonstrate a multi-level nested if-else block
• Explore simple ways to simplify this scenario
Since this is a complicated design pattern, we will go over a use case for chain of responsibility to help explain it. We also need to go over the anatomy of the chain of responsibility.
• Discuss a use case for the design pattern to help explain it
• See the anatomy of the chain of responsibility pattern
• Explore some implementation challenges of the pattern
We need to show how to implement the chain of responsibility design pattern in Kotlin.
• Demonstrate how to implement the pattern in our project Kotlin Clothes
• Create a class based on Chain of Responsibility (CurrentSeason)
• Demonstrate how to use the CurrentSeason class to get an Outfit object
To help explain this design pattern, we will go over some examples of the Observer Pattern in the Android OS.
• Discuss the common need to have classes be notified of changes in other classes
• Mention an approach that is common but very bad
• Look at few examples of Observer in the Android OS (OnClickListener)
Details are important in this design patterns so we will go over some common issues to help the student avoid them in their development.
• Understand the ease of falling into issues with memory leaks
• Talk about the problem of switching between threads for fast processing
• Mention reactive programming (RxJava) as an ideal solution to these problems
We need to go over the anatomy of the Observer Pattern from a theoretical standpoint as well as mention some of the advantages of using the pattern.
• See the anatomy of the Observer Pattern
• Go into more detail about the Observer, Observable and their roles
• Look at some advantages of using the Observer Pattern
We need to show how the user can implement the Observer Pattern in Kotlin in a simple way. We also need to add an Observable to our app, so we will convert the ShoppingCart to one.
• Demonstrate how to implement the Observer Pattern in Kotlin
• Make the ShoppingCart class an Observale
• Show how any class can now observe the ShoppingCart very easily
As the concluding section in the course, we will go over how to bring it all together and use design patterns in your own code.
• See how simple it is to use design patterns in your code
• Discuss how design patterns can be added to any project no matter how old
• Know how many design patterns can be used within the same project with no issues
To keep the student engaged and up to date with more design patterns, we should go over further readings, so the student has more options to learn from.
• Skim through the classic design pattern book (GoF)
• Mention other avenues the student can learn from
For the final video, we should give a recap of the entire course contents as well as some final advices to the user when it comes to design patterns.
• See a recap of the entire course contents
• Summarize the 6 design patterns we learned
• Look at some final advices to wrap the course up
Over the years, programmers have run into pretty much the same problems time and time again; not every problem is entirely unique. Therefore, over time programmers applied varying solutions to these problems, and this is how design patterns were born.
This course will walk you through some centrally significant design patterns so that you can easily resolve programming issues encountered in your day-to-day tasks. You'll learn these patterns in one of the most modern languages: Kotlin! We cover the three major areas in design patterns: creational patterns, structural patterns, and behavioral patterns. We also implement one structural pattern—Decorators—that plays an important role in adding functionalities to your programs. We take a look at different kinds of problem and implement the required patterns while avoiding common pitfalls. We also supply useful tips and tricks to use design patterns more effectively.
By the end of the course, you will be confident about using varying types of design patterns to solve common design problems.
Please note that a basic familiarity with Kotlin is desirable to get the most out of this course, along with some experience working with Android Studio.
About the Author
Yusuf Saber is a seasoned Android developer with over 8 years' professional experience in Android development. Yusuf has been in love with Kotlin since its first stable release in 2016. Since then, he has been using Kotlin to develop Android applications. Yusuf earned his Master's degree in Computer Engineering from Ryerson University in 2011 and started his career as a .NET developer before turning to Android. He has worked on a large range of Android apps, from social to multimedia to B2B and more!