C# Design Patterns

C# Design Patterns

When we do development on software or application projects, we should know the design pattern we are working on because it is a must to know. Generally, a developer encounters a problem that is always the same constantly, when doing activities writing code lines or coding. For this reason, we need a solution, for this problem, where the solution has been found by inventors in the past through years of research, the solution is called Design Pattern.

Understanding the design pattern

Design Pattern is a design pattern (best practice) for solutions to solving problems in general in software or application development, which almost certainly every developer encounters. Design patterns, like a concept or template, which we can apply and use in a programming language. The use of design patterns is also situational, so it depends on the problems we encounter when we do development. As for the implementation phase, design patterns are only effective if the developer has encountered previous problems, through trial and error, when developing software or applications.

Benefits of Design Pattern:

  • Lines of code are more neatly structured and easy to read and understand, so we can use them at any time.
  • We can submit our projects to other developers to continue, which is certain that the developer must know about design patterns.
  • We can solve the problem of developing software or applications in general.
  • Improve the efficiency of time in developing software or applications, because errors that have been repeatedly repeated are resolved.

Pattern in C#

Pattern Singleton Design

If you see the picture of singleton design, there are 3 connections to the database, and each connection consumes 5 KB of memory. and that happens because printing objects from more than one connection, it requires limitations to streamline the database connection, meaning that it is enough with only one connection to connect to the database if described like this

Pattern Factory Method Design

The factory method is a method that has a special function to construct a class into an object and return the object’s reference. This method must be static and be embedded in the class. And to guarantee that we will not be able to do direct construction, explicitly the constructor method must be changed given private access.

Pattern Bridge Design

linguistically the meaning of this bridge is the bridge/bridge. its function is to separate between abstraction and its implementation

Leave a Reply

Your email address will not be published. Required fields are marked *