A Beginners Guide to Design Pattern in Java

What is Design Pattern?

In term of Software Development, a Design pattern is a well-organized explanation for solve software problems. During Software development, developers have faced some difficulties, so solving these issue developers use Design Pattern. It is not a complete solution for problems; it is just a template for how to solve a problem.

It is a reusable solution. By using this Pattern, your code will be more flexible, reusable and manageable because internally java follows Design Pattern.

 

f:id:javatpoint:20181209152149p:plain

design pattern in java

Types of Design Pattern in Java:

In Design Pattern in Java are mainly categorized into 3 Category and their subcategories. These are:

  1. Creational Design Patterns – This Design Pattern is all about Object Instantiation. This design pattern offers a technique to create objects. There are 5 Sub Patterns in this design:

www.javatpoint.com

  • Singleton Pattern– Singleton Pattern is a concept of “define a class with only one instance and offerglobal access.”

 

  • Factory Pattern–In this pattern, subclasses are responsible for making the instance of the class. This pattern is also recognized as a Virtual Constructor.

 

  • Abstract Factory Pattern - This plant is additionally referred to as factory of factories. This type of design pattern comes beneath creational pattern as this pattern provides one amongst the most effective ways to make an object.

 

  • Builder Pattern: As the name implies, it supports the concept of that from simple object constructs a complex object by using the step-by-step technique.

 

  • Prototype Pattern–It simply means that copy of an existing object instead of making a new one and can also be modified as per our requirement.

 

  1. Structural design Patterns–Structural Patterns offer a different way to make class structural.

www.javatpoint.com

  • Adapter Pattern–Between two interfaces, Adapter pattern does the role as a bridge. This type of design pattern comes beneath structural pattern as this pattern combines the skill of two independent interfaces.

 

  • Composite Pattern–To treat a group of objects as a single object, we use Composite Pattern.

 

  • Proxy Pattern–In this Pattern, Class characterizesthe functionality of another class. It offers control for accessing the unique object.

 

  • Flyweight Pattern–This Pattern is used to share the same objects. Every object consumes memory area which is harmful to low memory devices, such as mobiles, embedded systems. So, to reduce the load on memory, we use the Flyweight Pattern.

 

  • Bridge Pattern–It is used to separates an object’s interface from its operation.

 

  • Decorator Pattern–This type of Pattern is allowed a user to update the functionalityto an existing object without changing its Structure.

 

  1. Behavioural Design Patterns–These Design patterns is about communication between objects.And introduce that how to offer loose coupling and flexibility to spreadeffortlessly.

www.javatpoint.com

  • Template Method Pattern–Concept of this Pattern is“just describe the frame of a function in aprocess, accepting some steps to its subclasses.”

 

  • Mediator Pattern - Mediator design pattern is used to offer a Mediator class which is handle communication between different objects or class in a system.

 

  • Chain of Responsibility Pattern–This pattern is a way to passing a client request to a chain of the object for the process.

 

  • Observer Pattern–It works on a one-to-many relationship concept, when one object changes their states, all dependent is automatically updated.

 

  • Strategy Pattern–When we have a specific task and for that task we have multiple algorithm, so in that condition client decides the implementations to be used at runtime. For this Strategy, we use the Strategy Pattern.

 

  • Command Pattern–This Pattern provides a concept of encapsulation on the object. It refers that encapsulate all the request in one object and then passes it to other objects.

 

  • State Pattern–This Pattern is coming under in Behavioural Pattern so, as its name implies this pattern works between state and behavior. A class behavioris changed, based on its state.

 

  • Visitor Pattern–This Pattern provides a facility to move the operational logic from one object to other.it works on a group of similar type of objects.

 

  • Interpreter Pattern–This Pattern represents a grammatical structure. To deal with the grammar, this pattern provides an Interpreter.

 

  • Iterator Pattern–This Pattern is Provide a way to traverse, by a group of objects. This pattern is to hide the specificoperation of traversal. It is widely used in Java Collection.

 

  • Memento Pattern–We use this pattern to save the state of the object for future use, that we can restore later. This Pattern protects the certainty of saved state data.

 

Usage of Design Patterns:

Design patterns have 2 major uses.

1. They supply you with how to resolve problems related to software package development using a verified solution. They isolate the variability that will exist within the system needs, creating the general system easier to grasp and maintain.

2. Design patterns create communication between designers extra efficient. Software developers will now image the high-level design in their heads after they refer the name of the pattern used to solve a specific issue once discussing system design.

Introduction to C programming language

What is C Language?

C language is a programming language. It supports structured programming. It is a high-level language. It is also considered as the mother of all computer programming language as it consists of basics to all languages.

www.javatpoint.com

It was developed by Dennis Ritchie. C has been standardized by the American National Standards Institute. It was designed to be compiled using relatively straight-forward compiler, to provide low-level access to memory, to require minimal run-time support. Therefore, C-language was useful for many applications that are coded in assembly language such as in system programming.

It has some fixed keywords such as for, if/else, while and do/while.  There are large numbers of arithmetical and logical operators such as +, +=, ++, &, etc.

Advantages of C-language:

  1. C-language is a building block for many other languages.
  2. C is highly portable language.
  3. C has an ability to extend itself.
  4. It is a structured programming language.