1. Home
  2. Training Library
  3. Programming
  4. Programming Courses
  5. Using Design Patterns in Java Projects

Facade

Contents

keyboard_tab
Design Patterns
1
Design Patterns
PREVIEW2m 26s
2
Singleton Pattern
PREVIEW3m 13s
9
Decorator
7m 48s
10
Flyweight
9m 20s
11
Proxy
7m 36s
12
Facade
6m 5s
14
Command
11m 44s
15
Iterator
8m 24s
16
Visitor
9m 4s
17
Mediator
11m 38s
18
Memento
9m 48s
19
Observer
10m 40s
20
Strategy
8m 27s
21
State
10m 27s
22
Template
7m 56s
23
MVC
10m 27s
26
DAO
10m 27s
27

The course is part of this learning path

Start course
Overview
Difficulty
Intermediate
Duration
4h 56m
Students
22
Ratings
5/5
starstarstarstarstar
Description

This course takes an in-depth look at how to use design patterns in your Java projects. We will then run through some example questions of what you could expect from the Oracle Certified Java EE exam.

Learning Objectives

  • Understand what design patterns are
  • Learn about the myriad of design patterns that you can use in your projects

Intended Audience

This course is intended for anyone who already has basic knowledge of Java and now wants to learn about Java EE 6.

Prerequisites

Basic knowledge of Java programming.

 

Transcript

Hello, dear friends. In this video, we will examine our last structural pattern known as facade. Let's begin. Facade is a part of Gang of Four design pattern and it is categorized under structural design patterns. Facade means the face of a building. While passing across a street, all we look at is the face of a building. The face abstracts all the complex implementation details of a building. Similarly, a facade design pattern aims to provide a unified interface to a set of interfaces in the subsystem. This unified interface hides the subsystem complexity from the client. It falls under the category of structural patterns. The java.util.connection in Java is a facade as it allows us to create DB connections and hides the implementation details. Similarly, java.net.urlclass is another facade that exposes the open stream method hiding all involved details. The facade pattern is usually a refactoring pattern.

For a large complex subsystem, it's a fairly good idea to use a facade pattern and provide the clients with a friendly interface to interact with. The facade pattern is appropriate when we have a complex system that we want to expose to clients in a simplified way. Its purpose is to hide internal complexity behind a single interface that appears simple from the outside. Facade also decouples the code that uses the system from the details of the subsystems, making it easier to modify the system later. Basically, facade allows us to use the open-closed principle in SOLID. The facade pattern describes a higher level interface that makes the subsystems easier to use. Practically every abstract factory is a type of facade. Let's create a project and apply the face pattern. Create a new project and name it Facade. I'd like to create a game selection project for football, basketball, or handball.

First, we need an interface. Let's name it Sport. Now we need a method. Let's name it setGame() ;. Let's define our sport types. Class Football implements Sport{. Override method. Football has been chosen. Let's go on with basketball. Override method with basketball. Last one is handball. Done. Now we need a tournament class to use these sports. First, let's define our properties as sport types from Sport interface. Now, we need constructor. In constructor, we will set sports to interfaces. Let's add methods. SetFootball( ). Basketball( ). Handball( ). Done. Now we can use this structure in Client page. First, we need a tournament instance. Let's call set methods one-by-one. Done. When we run project, as you see, the result is football, basketball, and handball. Now, with the facade pattern, we have finished looking at the structural patterns. In the next video, we will start to examine behavioral patterns, starting with the chain of responsibility pattern. See you in the next video.

 

About the Author
Students
433
Courses
47
Learning Paths
2

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.

Covered Topics