How to design patterns from scratch using C# asp.net MVC

coder rock 436 Reputation points
2024-04-19T14:27:10.4633333+00:00

I am new to building design pattern using factory design pattern, its C# asp.net mvc application which i am going developing my new web application,

please can you help me how to start from scratch.

I have worked one design pattern application which is designed by my seniors developed using factory design pattern they have developed using component class.

I have 8 years of experience never design, any design pattern from scratch just used develop by others.

Developer technologies .NET Other
Developer technologies ASP.NET Other
Developer technologies C#
{count} votes

Accepted answer
  1. mickeymartin 80 Reputation points
    2024-05-22T11:31:37.3566667+00:00

    Learn the pattern (books/websites).

    Pick the right one (Repository, Factory, etc.).

    Code it (interfaces, classes, leverage MVC).

    Use Dependency Injection (optional).

    1 person found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2024-04-19T16:19:47.74+00:00

    You should study design patterns. There are books and online courses.

    The factory pattern is one of the simplest. instead of creating class instances with the new operator, you call a "factory" method to create the instance. typically an interface is returned rather than a class type. It is not uncommon to use a factory for the factory, especially if plugins are used.

    a common use besides configuration is unit test mocking.

    simple online example:

    https://www.dofactory.com/net/factory-method-design-pattern

    1 person found this answer helpful.
    0 comments No comments

  2. Lan Huang-MSFT 30,186 Reputation points Microsoft External Staff
    2024-04-22T03:12:16.71+00:00

    Hi @coder rock,

    MVC is a Model-View-Controller - high-level architectural pattern which intend is separating UI from from model. Factory is a low-level pattern which intend is a creation of objects.

    You can check out the following links:

    ASP.NET MVC Pattern

    Getting started with ASP.NET MVC 5

    https://github.com/nemanjarogic/DesignPatternsLibrary
    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  3. Stencilloart 0 Reputation points
    2024-06-21T16:38:01.18+00:00

    Learn the pattern (books/websites).

    Pick the right one (Repository, Factory, etc.). At Stencillo, we blend the beauty of nature with the precision of artistry. https://stencillo.com/

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.