Programming Concept - ntierontime/Log4Net GitHub Wiki

Architecture Design Patterns

There are tons of articles talking about Architecture Design Patterns, the following Architecture Design Patterns are used and generated.

  • Service-oriented architecture(SOA)
  • Separate Of Concern/Inversion of control(IoC)
  • Model–View–Presenter(MVP)
  • Model–View–Controller(MVC)
  • Model View ViewModel(MVVM)

Service-oriented architecture(SOA)

Wcf Web Application project and Wcf Client projects for different platforms are generated. WebApi is also generated for Asp.Net Mvc in Controller project, and consumed in Asp.Net Mvc project.

Separate Of Concern/Inversion of control(IoC)

IoC is used when:

  • Common Business Layer calling Data Access Layer
  • UI Process Layer calling Common Business Layer

Generated MVP, MVC and MVVM

MVP, MVC and MVVM are used in generated solutions. Please see following chart for major differences.

Model–View–Presenter(MVP)

MVP is used in WebForm Application.

Model–View–Controller(MVC)

MVC is used in Asp.Net Mvc Project.

MVC will be used in future:

  • Asp.Net MVC with AngularJS, AngularJS UI and Bootstrap.
  • Html 5/Css 3 web application with AngularJS, AngularJS UI and Bootstrap.

Model View ViewModel(MVVM)

MVVM is used in several platform: WPF desktop application, Windows App Store, Windows Phone App, and Silverlight.

MVVM will be used in future:

  • Xamarin IOS Mobile Applications.
  • Xamarin Android Mobile Applications.

Single Responsibility Principle

“In object-oriented programming, the single responsibility principle states that every class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned with that responsibility.”(From Wikipedia)

Single Responsibility Principle is extended in nTierOnTime generated code by using partial class.

Partial Class

Partial classes are primarily for code-generator usage, such as designers.

Extra generated classes or methods are needed for based on .dbml and .edmx, and we don’t want to put the code into generated files. A separate class file should be/ is generated/added to contain extra generated code.

Developers may want to add new logics in same classes based on generated code. Developers can add a new file with is same partial class of generated class.

All generated classes are partial classes.

Partial method

You need to know the rules of partial class to work with partial methods, also the knowledge of partial structure and partial interface can be helpful. A number of articles are present on the internet about them, so I am not going to go in details about partial classes. There are several rules to follow with partial class and there are several rules to follow with partial method as defined by Microsoft. Those rules are listed below:

  • Partial methods are indicated by the partial modifier.
  • Partial methods must be private.
  • Partial methods must return void.
  • Partial methods must only be declared within partial classes.
  • Partial methods do not always have an implementation.
  • Partial methods can be static and generic.
  • Partial methods can have arguments including ref but not out.
  • You cannot make a delegate to a partial method.

Partial method is not used in nTierOnTime generated code because of upper features/limitations.

Extension method

Extension method is another good practice when developers want add new methods without change existing code.

  • Extension methods that relate to specific business needs of a project (whether they are connected to basic data types or custom objects) should not be included in a library that would be distributed across multiple projects.
  • Extension methods that relate to basic data types (int, string, etc) or generics that have a wider application could be packaged and distributed across projects.
  • You need a method on a type and you don't own the source.
  • You need a method on a type, you do own the source, and the type is an interface.
  • You need a method on a type, you do own the source, but adding the method creates undesired coupling.

Extension method is not used in nTierOnTime generated code. You may want to compile generated code without any change, and use the .dlls as reference in other project. You can declare extension methods in referencing projects.