Skip to main content

Separate frontend 1: Trying to separate GUI layer and data business layer.

I have seen in some projects where I have been part of. The dependency injection is done in the presentation part of the application. That can be the API front or the GUI part like in a ASP.Net web application. The way this is done is to have some interfaces to separate the business from the data layers. Often by having the interfaces for them self in a separate project. Then the presentation layer references the business layer, interfaces and data layer, and connects it all together using dependency injection. This makes it easier to test, and change storage or parts of the application. As the injector can just inject new implementations of the interfaces. 

But to me that feels like the presentation layer has two large responsibilities,  to present data and connect all the different parts together. What if you needed to change the presentation.  Then you would have to implement the injections also. You can't just switch out the presentation or add new ones. What if the old presentation had to live on.  

I wanted to build a test solution where I was able to change the presentation, without having to do anything with the injection of the different services. Just start building a new presentation layer. I started by moving the dependency injection to a separate project. Where I put all the injection part of the application. I also added a separation between the presentation layer and all the business layers and data layer. By mapping the business model to view models in the connection project. 

What I ended up with was that the presentation layer only hade one reference, and that was to the connector. Making a nice separation from the rest of the application. Every "part" of application can be accessed to using a services in the connector project. The service is responsible for making view models to the presentation layer and taking input form the presentation layer. Then using dependency injection calling the appropriate business layer interface. 

I created a simple solution where I hade two services, an article service and an example service. I only implemented the Article service. Just to try to add more presentation layers. And found that added a presentation layer was really nice and easy. I ended up with three, one ASP.Net API, a razor front end and a Blazor front end. 

I will go more into the details later in future blog posts

Comments

Popular posts from this blog

CSOM System Update that does not update minor version number

I was in a scenario where I had to do a add some data to a document list in a web job. My issue was that I could not find any system update method in the CSOM API. After searching it i found a blog post showing that one could just override the system fields, like Modified and Editor(Modified My). That seemed to work but that did not stop it form updating the version number of the document. This example will only work for minor unpublished version. I have not found a way to do this without a published version. There it will get a new minor version. The solution combines the use of adding Editor, and Modified with the use of the ValidateUpdateListItem metod. I found that one can set the item values on the item and just set one value in the form value list, then it will update all the fields. If one then set the "bNewDocumentUpdate" it will not update the version number if it is a minor version. So what i do is just get the values from the item before an update, then sets...

The future of sandbox solution

Probably old news, but I was wondering what will replace SandBox solution. Because how else would we deploy stuff to SharePoint Online without WSP's, After some searching on the net I found this blog entry on SharePoint dev blog (link below). That states that the managed code part of SandBox solution is going to be removed, not the declarative parts like content types, lists, modules, etc, This will still be supported in what they call a no-code SandBox Solution (NCSS). I must say that it is nice to know that you can still use the ok part of the SandBox solutions, https://www.blogger.com/blogger.g?blogID=921264504943302831#overview/src=dashboard