Categories: Design Pattern

Behavioral Patterns – Interpreter

Step 3 Suppose the data has been assessed before the executing interpreter operation in the interpreter service class. The Interpreter services class can edit when the interpreter classes under the IAbstractExpression interface class have edited the complete end. It adds the DataAccess function and the default layout data format function here.

Fig 4 InterpreterServices class source code

Add a few private functions in the interpreter services class, such as AddExpression and LayoutExpression. Developers need to tell the program which one expression must add this operation and then output the response object description.

Fig 5 AddExpression fun source code
Fig 6 LayoutExpression fun source code

The interpreter services class can find out the interface has two same seem like function name, such as Expression, Expression2 which because these are on behalf of two different operation methods to explain the executing interpreter pattern concept operation. The first method is to fasten the response class file with the List object in the function block. The second method is that the response class uses the generic skill to explain the response class file with the ICollection object.

Fig 7 Expression and Expression 2 fun different parts.

Step 4 Add the interpreter pattern-related files in the web project, such as view flies, controller files. Register the interpreter pattern files in the web project’s start.cs file.

// Interpreter
services.AddScoped(typeof(IInterpreter<,>), typeof(InterpreterServices<,>));
Fig 8 Interpreter pattern result

Reference

Page: 1 2

davidsky69

View Comments

Recent Posts

SOLID Principles – Single-responsibility principle

The single-responsibility principle (SRP) is a computer-programming principle that states that every module, class or…

4 years ago

Microservices – Command and Query Responsibility Segregation(CQRS)

Command query responsibility segregation (CQRS) generalizes CQS to message-driven and event-driven architectures: it applies the CQS…

4 years ago

Microservices – Domain-driven design(DDD)

Domain-driven design (DDD) is a software design approach focusing on modelling software to match a…

4 years ago

Microservices – Onion architecture

A microservice architecture – a variant of the service-oriented architecture (SOA) structural style – arranges…

4 years ago

Unit Of Work pattern concepts in .NET

The Repository pattern and Unit of Work pattern are used together in most time. Unit…

5 years ago

Behavioral Patterns – Visitor

Visitor – It allows the program changes the algorithm and the operations that base on the visitor…

5 years ago