c# - More layers and performance issue -


Depending on the presentation (for more details) it seems that unnecessary performance problems due to layers and assembly can be problematic. Take a look at this scenario, it's about sending a message on the "contact us" section of an application:

  [http post] Create public actioners (contactwmmedmail contact viewmodel) {var Request = new CreateContactRequest (ContactViewModel); _contactService.CreateContact (requested); See Return (); }  

This request is just an MVC controller action to make contact through feedback patterns, now about the service layer, in the service layer I have this piece of code:

  Public CreateContactResponse CreateContact (CreateContactRequest Request) {var response = New CreateContactResponse (); Var contact = request.ContactViewModel.ConvertToContactModel (); {_contactRepository.Add (contact); _unitOfWork.Commit (); reaction. Success = true; reaction. Type message = message type Success; reaction. Message = service message. On the general service service success message; _logger.Log (response.Message); } Hold (exception exception) {response.Success = false; Response.MessageType = Message type. UnSuccess; reaction. Message = service message. Common service messages; _logger.Error (exception.Message); } Return response; }  

By converting the service methods into a model by model, and calling it the method below the nHibernate to be in the data base in the repository layer:

  Add Public Zero (T unit) {SessionFactory.GetCurrentSession (). Save (unit); }  

And finally after the unitofform pattern, it remains in the database. I have actually reduced the amount of code and all the process of making this simple contact in the database. This code implementation has been done in the domain driven design and this pattern is clearly more readable and can be enhanced for maintenance and every change, but I can also write something like this to make a contact:

< Pre> [HTTP post] Create public proceedings (contact contact) {SessionFactory.GetCurrentSession () .save (contact); See Return (); }

In this kind of implementation, there is no need to throw any contact, yes to throw five layers! I know about making a contact and this kind of simple business is second best, but it is impossible for complex businesses to take care of everything, definitely A by calling B and B. And ... there is a kind of display problem.

Now I want to know what are the methods of optimizing the performance of layered architecture?

I have blogged a post about it, though it is optimized for n-layered architecture Not easy, I talked about some tips:


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -