Coder Social home page Coder Social logo

rafaelqueiroz89 / design_patterns_in_csharp Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 9.0 9.32 MB

In this repository I am doing some exercises and examples about the GOF design patterns in C# 7, so it's pretty much updated.

License: GNU General Public License v3.0

C# 100.00%
csharp

design_patterns_in_csharp's Introduction

Design Patterns in C# 7.0

In this repository I am doing some exercises and examples about the GOF design patterns in C# 7, so it's pretty much updated. There is an exercise.jpg file on each project folder that is an exercise, and the solution is on the Exercise.cs file (with the Main method), there are also some other practical examples.

These examples are for Structural Patterns, Creational Patterns and Behavioral Patterns, it means that Design Patterns are standards that deal with project structures, facilitating communication between their entities. In this way they treat the way objects and classes are arranged in a project in order to form more complex structures.

There are also Architecture Patterns, that stands out for MVC (Model-View-Controller) or MVVM (Model View View-Model) that won't be covered in this repository.

This Repository was made for academic research only.

This Repository covers ALL the repositories proposed by GoF (The gang of four) and the SOLID principles:

  • SOLID Design Principles: Single Responsibility Principle, Open-Closed Principle, Liskov Substitution Principle, Interface Segregation Principle and Dependency Inversion Principle
  • Creational Design Patterns: Builder, Factories (Factory Method and Abstract Factory), Prototype and Singleton
  • Structrural Design Patterns: Adapter, Bridge, Composite, Decorator, Façade, Flyweight and Proxy
  • Behavioral Design Patterns: Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Null Object, Observer, State, Strategy, Template Method and Visitor

Note that this repository stands for KISS (keep it stupid simple) so there are no separation of class in files or helper classes, all is done in one document.

/*Some considerations: */

What are Design Patterns?

"Design Patterns are reusable solutions to common programming problems. They were popularized with the 1994 book Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, John Vlissides, Ralph Johnson and Richard Helm (who are commonly known as a Gang of Four, hence the GoF acronym).

The original book was written using C++ and Smalltalk as examples, but since then, design patterns have been adapted to every programming language imaginable: C#, Java, PHP and even programming languages that aren't strictly object-oriented, such as JavaScript.

The appeal of design patterns is immortal: we see them in libraries, some of them are intrinsic in programming languages, and you probably use them on a daily basis even if you don't realize they are there."

When to use the Builder and the Factory?

"The Builder is only needed when an object cannot be produced in one step. One great an example of this would be in the de-serialization process for a complex object. Often times the parameters for the complex object must be retrieved one by one."

What's the difference between the Composite Pattern and the Builder Pattern?

"The composite pattern is used when you have a situation when you need to construct Parent and Child, like a dynamic menubar. Or even when you might want to have a single object (like a sum of values) or many values on a row."

What's the difference between the Proxy Pattern and the Decorator?

  • Proxy provides an identical interface, the decorator provides an enhanced interface
  • The Decorator typically aggregates (or has references to) what it is decorating; proxy doesn't have to
  • Proxy might not even be working with a materialized object
  • Proxy is an implementation of lazy of the whole type for eg.

Use of dotMemory profiling in the Flyweight design pattern

In the solution of the Flyweight pattern I make use of the JetBrains (www.jetbrains.com) dotMemory profiler to make some profiling on my tests of the pattern. Documentation can be see here: https://www.jetbrains.com/help/dotmemory/Working_with_dotMemory_Command-Line_Profiler.html although it is not so well documented if you have a free version.

design_patterns_in_csharp's People

Contributors

rafaelqueiroz89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.