Skip to content

ronelpanag/DesignPatterns.Examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Notes that I took from this learning path

This repo plans to serve as a cheatsheet or a notebook with practical examples that explain the use of design patterns in software development. Some of those examples are created by myself, others by Dmitri Nesteruk in his [Design Patterns in C# and .NET course](Design Patterns in C# and .NET )

I'm using C# console applications with .NET 8.0

What's a Design pattern

In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. It represents best practices evolved over time by experienced software developers. Design patterns can speed up the development process by providing tested, proven development paradigms. Reusing design patterns helps to prevent subtle issues that can cause major problems and improves code readability for developers who are familiar with the patterns.

Design patterns can be categorized into three main types:

  1. Creational Patterns: These patterns deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. Examples include the Singleton, Factory Method, and Abstract Factory patterns.

  2. Structural Patterns: These patterns focus on the composition of classes or objects to form larger structures. Examples include the Adapter, Composite, and Decorator patterns.

  3. Behavioral Patterns: These patterns are concerned with the interaction and responsibility of objects. They define patterns of communication between classes and objects. Examples include the Observer, Strategy, and Command patterns.

Creational Patterns

Builder pattern

There is an example in the Creational project

Some objects are simple and can be created in a single constructor call. This pattern makes easy and productive the construction of any object, specially when you need a lot of arguments to create that object.

There are several ways to implement this pattern. You can use:

  • Basic builder implementation
  • Fluent builder. e. g.: when you create a request using Flurl var request = _baseUrl.AppendPathSegment("/example).WithHeader("x-api-version", "1.0").GetStringAsync();. You can see an example with recursive generics at Creational/FluentBuilderWithGenerics.cs
  • Stepwise builder
  • Functional builder
  • Faceted Builder

About

Design Patterns notebook with examples using .NET 8 C# Console Apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages