Design Pattern Application example of single piece pattern application, and simple injection realization form

Source: Internet
Author: User

The last time I wrote a system architecture based on MVC pattern and command mode, I also made a simple example.

After writing what I want to write, I want to use a specific project to concatenate most of the design pattern ideas.

What I want to say today is the single piece mode.

First of all, a simple description of what is a single piece mode, also known as Singleton mode, to achieve a single instance of the function, not specifically said, do not understand the other introduction of conceptual articles.

Usually, in the project I have done, the most application singleton is to do the adapter, below I will explain how to do the adapter.

First, we introduce the application process of implementing a single instance of the adapter through a single piece mode.

Before I introduce the single piece mode, I want to introduce the concept of service-oriented programming first. In my current design thinking process, I think that any one of the business logic is based on service.

Services are coupled through interfaces and implementations. The following is an example of a system that I developed earlier to describe how to do an adapter by abstracting the core idea.

First, make a solution.

Do a user class service interface

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Model;

namespace IService
{
    public interface IUserService
    {
        Users Load();

        void Insert(User user);

        void Update(User user);

        void Delete(User user);
    }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.