All Projects → OmarElGabry → Designpatterns

OmarElGabry / Designpatterns

Licence: mit
Examples of Design Patterns in Java

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Designpatterns

Dntframeworkcore
Lightweight and Extensible Infrastructure for Building Web Applications - Web Application Framework
Stars: ✭ 208 (-16.8%)
Mutual labels:  design-patterns
Javascript Design Patterns For Humans
An ultra-simplified explanation of design patterns implemented in javascript
Stars: ✭ 2,818 (+1027.2%)
Mutual labels:  design-patterns
Designpatterns
Simple repository containing one simple example for all existing patterns in C#
Stars: ✭ 231 (-7.6%)
Mutual labels:  design-patterns
Javascript Interview Questions
500+ JavaScript Interview Questions
Stars: ✭ 208 (-16.8%)
Mutual labels:  design-patterns
Awesome Design Systems
A curated list of bookmarks, resources and articles about design systems focused on developers.
Stars: ✭ 222 (-11.2%)
Mutual labels:  design-patterns
Run Aspnetcore
A starter kit for your next ASP.NET Core web application. Boilerplate for ASP.NET Core reference application, demonstrating a layered application architecture with applying Clean Architecture and DDD best practices. Download 100+ page eBook PDF from here ->
Stars: ✭ 227 (-9.2%)
Mutual labels:  design-patterns
Reactpatterns
React patterns & techniques to use in development for React Developer ⚛ .
Stars: ✭ 201 (-19.6%)
Mutual labels:  design-patterns
Node.js Design Patterns Third Edition
Node.js Design Patterns Third Edition, published by Packt
Stars: ✭ 239 (-4.4%)
Mutual labels:  design-patterns
Design Patterns Typescript
Design Pattern Examples in TypeScript
Stars: ✭ 221 (-11.6%)
Mutual labels:  design-patterns
Getx pattern
Design pattern designed to standardize your projects with GetX on Flutter.
Stars: ✭ 225 (-10%)
Mutual labels:  design-patterns
Designpattern.samples.csharp
23种面向对象设计模式示例代码(C#实现)
Stars: ✭ 215 (-14%)
Mutual labels:  design-patterns
Material Backdrop
A simple solution for implementing Backdrop pattern for Android
Stars: ✭ 221 (-11.6%)
Mutual labels:  design-patterns
Dotnet New Caju
Learn Clean Architecture with .NET Core 3.0 🔥
Stars: ✭ 228 (-8.8%)
Mutual labels:  design-patterns
Design Patterns Csharp
Design Pattern Examples in C#
Stars: ✭ 213 (-14.8%)
Mutual labels:  design-patterns
Clean Architecture Manga
🌀 Clean Architecture with .NET6, C#10 and React+Redux. Use cases as central organizing structure, completely testable, decoupled from frameworks
Stars: ✭ 3,104 (+1141.6%)
Mutual labels:  design-patterns
Learning Oop In Php
A collection of resources to learn object-oriented programming and related concepts for PHP developers.
Stars: ✭ 2,359 (+843.6%)
Mutual labels:  design-patterns
Urf.core
Unit of Work & Repositories Framework - .NET Core, NET Standard, Entity Framework Core. 100% extensible & lightweight. Live demo: https://goo.gl/QpJVgd
Stars: ✭ 226 (-9.6%)
Mutual labels:  design-patterns
Design Patterns Python
💻 Padrões de Projeto em Python
Stars: ✭ 246 (-1.6%)
Mutual labels:  design-patterns
Design Patterns
💼 Design patterns written in different programming languages 📐
Stars: ✭ 244 (-2.4%)
Mutual labels:  design-patterns
Program Blog
Practice, thinking and reading
Stars: ✭ 228 (-8.8%)
Mutual labels:  design-patterns

Screenshot

Design Patterns

Design Patterns are solutions to common software design problems that occur over and over in software development.

Index

Structural

Adapter

An adapter helps to join two incompatible interfaces to work together. So, if you have an interface with implementing classes. If you were asked later to add additional sub class(es), but they have incompatible Interface, then, adapter pattern could be useful. There are two structures:

Object

The Adapter has a reference to the incompatible object.

Class Diagram

Interface

The Adapter has a reference to the incompatible interface.

Class Diagram

Decorator

The decorator pattern extends the functionality of an object dynamically.

Class Diagram

Bridge

Decouples an abstraction from its implementation so that the two can vary independently. As an example, If you have a class called Rectangle. This class could have two different implementations, Red Rectangle and Blue one. Instead of Inheriting from Rectangle class, one for blue rectangle and another for red, We could instead pull out these implementations and use Composition over Inheritance.

Class Diagram

Composite

It's used to create a tree structure of group of objects. So, an Object can be collection of other objects, where objects share a common interface that defines the common operations.

An object can have a collection of objects called Composite Or Node, while objects that can't have other objects(at the lowest level) called Leaf. Composite object can have leafs or other composites.

Class Diagram

Behavioral

Strategy

Strategy is used when you want to extend the behavior of an Object, where this behavior could vary during the run time. If multiple objects need to use the same behavior(algorithm), we get the benefit of code reuse too.

Class Diagram

Dependency injection

Dependency is used when you want to separate the dependencies of an Object, and pass them to dependent object during run time. The dependent object does not need to know how to construct the dependencies nor which actual dependencies it is using.

Class Diagram

Iterator

This pattern is used to get a way to access the elements of a collection object in sequential manner without exposing its underlying representation. In this snippet, I am using Java's built-in Iterable & Iterator classes.

Separate Class

Class Diagram

Single Class

Class Diagram

Observer

Observer pattern is used such that if an object is changed, its dependents objects get notified of that change, Thus, there is 1:M Relationship. As an example, having a Publisher that publish news to the Subscribers, Whenever any new updates or data added, the Subscribers get notified. In this snippet, I am using Java's Observer and Observable classes.

Class Diagram

State

A class behavior may change based on set of states either made by user, or internally by the system. In this pattern, We encapsulate each state. The user doesn't need to know about each state, the user only performs some actions which in turn may change the state of the object.

Class Diagram

Creational

Factory

This pattern defines a way for creating object(s) during run time.

Factory Method

Factory Method is a method used to create object(s) of a certain type(interface) during run time.

Class Diagram

Abstract Factory

Factory Method is an object used to create a set of related objects during run time.

Class Diagram

Singleton

The Singleton Pattern is a pattern that ensures that there is only ever one single instance of a class, And it provides a global way to get to that instance.

Classic

This is the basic implementation

Class Diagram

Eager Instantiation

If you are concerned about synchronization, eager intantiation could be useful as long as you know you'll always need to instantiate the object, and the object doesn't take a lot of time to load.

Class Diagram

Synchronized

Another solution for synchronization using synchronized method. But, you will pay for it's pitfall; Synchronized code takes a lot longer to run.

Class Diagram

Prototype

The Portotype Pattern used when you want to hide the complexity of creating new instance same as in Factory Pattern, and Creating an object is an expensive operation. Thus, copy an existing object is much efficient. It uses Java's Cloneable Interface for cloning objects.

Abstract Class

Using abstract class

Class Diagram

Interface

Using Interface

Class Diagram

Support

I've written these snippets in my free time during my studies. If you find it useful, please support the project by spreading the word.

Contribute

Contribute by creating new issues, sending pull requests on Github or you can send an email at: [email protected]

License

Built under MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].