Template method pattern is one of the behavioral design patterns. I think that you all must have already used this pattern many times.
In this pattern, Abstract class holds the primitive operations which needs to be executed and all those methods might be abstract if they are customizable and it also holds one method which executes all the other methods in pattern which you have defined. This method is also called template method. This abstract class must be overridden by sub classes to write custom primitive operations according to your requirements.
We can understand this pattern by following code.
Command pattern is a behavioral design pattern in which the object is encapsulate all the information to be executed at later time.
To understand this pattern let’s take an example of signing up for an account.
So let’s assume that registration is three step procedure. First step is to fill basic details, second step to fill business details and then final step to fill payment details. Initially object of Command is created and will be used to collect all information. …
Let’s understand behavioral design pattern before we start on observer pattern.
This type of design patterns will help you to solve problems related to behavior of your program. This patterns are concerned about interactivity between objects and the responsibility of objects and yet they must be loosely coupled to each other.
Observer pattern is one of this type of design pattern which we will understand in this story.
In this design pattern, The object maintains the list of observers which are dependent on it. So whenever something gets changed in that object, it will notify to all observers in the…
In most cases, We use Django Rest Framework filtering module to filter data but if you have large dataset then in those cases we must need indexing engine to index data and then do filtering on them. There are many search indexing engines out there. In this article we will use one of them and will understand how that can be used in Django project along with Django Rest Framework.
All index engines are differently implemented and to use them in python they are providing interfaces. …
In this tutorial, you will learn about deployment on Ubuntu desktop or Ubuntu server using following technologies
To start new project, create virtual environment using following commands. You can create virtual environment wherever you want but I would suggest to create parallel to you project folder. (For existing project)
sudo apt install python-virtualenv
Virtualenv -p python3 venv
Install django to start new project in Django
pip install django==2.1
Start new project with name “demo”
django-admin startproject demo
Change directory to your project folder and install all the python dependencies (For existing project)
pip install -r requirements.txt
Django 2.0+ is the big change against 1.x versions of Django. In new version, Few functionalities are changed. For changes look at the official release note. It supports Python 3.4+. Django 1.11 was the last version to support Python 2.7.
Before creating new project we must create one python virtual environment to make separate development environment for the project.
Create Python virtual environment with name
venv. To do that follow this tutorial - setup-python-virtual-environment.
Activate Python virtual environment
Now as this Python virtual environment is separate to work on the project so we can install the python…
This SingleTon pattern is very useful pattern when we need global instance of any service or class. This pattern is used to implement a class which returns only one instance every time when we try to create new instance.
Pattern Type — Creational Design Pattern
Now to implement this pattern to achieve SingleTon instance, we have 4 solutions and all of them are explained below one by one so, you can use any of them according to your…
Proxy design patterns fall under structural design patterns category. It basically provides interface to real object which can be of different types such as networking, large in memory, file etc. Proxy class acts as intermediate to requester and provider. In serving web requests, proxy server is the best example for this pattern. When any new request comes to proxy server, it will evaluate the request and then will forward request to appropriate server and get response to give back to requester. This proxy server also provides additional security and other functionalities.
Facade pattern allows to hide complexity of system and provide simple interface to client of the service.
Before going through programming example, let’s understand a real life example, Shopkeeper. In shopkeeper, Many items are available but custom doesn’t know the exact location of the item in the store so we ask shopkeeper with list of items and shopkeeper provides all the items which customer wants to buy as shopkeeper know where items are located. Shopkeeper is facade of the shop.
Another easy example is facebook-sdk library to user facebook APIs. It provides very easy and simple methods to access all…
Factory is a creational design pattern which helps hiding object creation process.
Pattern Type — Creational