User interface level abstraction

I have successfully worked with abstracting data layers and business layers. But recently, a colleague mentioned the ablation of a user interface layer between a user interface and a business layer. However, I can not get around it. I can not imagine how this level of user interface will differ from the level of the business level. I look at the articles well enough and don't seem to find much help. Can someone tell me a simple example?

+3
source share
5 answers

There are several options here.

  • MVC

    You need to separate the view from the model and the controller. The easiest way to imagine why you are doing this is that you had the same model and controller that you wanted to present different types: presentation of a website, view of a stand-alone application, presentation of a web service, view of a mobile phone, your unit test views, etc. Therefore, you do not need logic in your view code. I., in Java, there is no manipulation of the model inside your ActionListeners and other GUI code - instead, you move this to the controller class, and the View handler simply performs input validation, formatting the output, and negotiations with the controller class.

    Many views are written using a presentation-oriented approach. You have your own graphical interface. Something happens, and you react to it and do things, and if necessary, update the graphical interface. Therefore, it is easy to attach your business logic and model very tightly to the look.

    Basically, you create (a) the interface (s) in your business logic so that everything can trigger, so adding new views is simple. These interfaces provide all the functions required for a call. You can then make the internal business logic private.

  • Data collection web form (or series of web forms)

    It is very unlikely that you will want to collect information in the same order as your data model at your business level. In addition, you will need to be saved between pages in a multi-page form. You will quickly find that those that are not null constraints are PITA when you collect them on page 3 (because they disconnect clients on page 1). Since forms can change as they are redistributed, you will eventually separate business logic from presentation at an early stage and summarize how you fill out your model. And many other things.

  • Interface created using the model

    You have a model that can change or really describe an interface, either explicitly or implicitly. Thus, you create an interface from a model instead of using pre-designed forms and windows and so on. Thus, you should program your view code as a whole, since you will only have a model to work with. Many maps from model to user interface and vice versa. Then you add some observers, because the model values โ€‹โ€‹change elsewhere, and it's a lot of fun ... :)

  • Something else...

+1
source

I found Jeremy Miller. I created my own CAB series of articles, very informative in the past. It describes many variations of the Model-View-Controller family of models. This is a great read.

+1
source

Simply put, your user interface level only applies to the user interface and interacts with the next level down (perhaps your business level). Your business layer and data layer (and any other layers you have) should never have any user interface code, because this is the definition of user interface layers.

Think about how a web browser works, the browser is a user interface layer and relates to the rendering of your page and nothing else. When something needs to happen, it makes a request to the web server (next level) to do this, and then displays the results.

Try using Google for some well-known user interface patterns:

MVC MVP Humble Dialog Box
0
source

I read about MVC, MVP and Humble Dialog Box (I pulled my hair out). The colleague who mentioned the user interface layer was not able to give me a very good example of how it differs from the business layer. And when asked, he said that it was not MVC / MVP. So I thought I would ask about

0
source

Here is my principle: if you need to rewrite any logic (except for manipulating form controls), then you have not completely separated the user interface layer from other layers. Personally, I like to have a service level that contains my business rules, manipulating domains and datamapping objects, and only exchanging domain objects with a user interface. The user interface knows nothing about the date of the data, or about the business rules.

This does not answer about a separate โ€œuser interface layerโ€ between the user interface and my service level. Perhaps this is due to the fact that HTML and code are separate (for example, ASP.Net code can be considered a user interface layer). There is nothing worse (when changing / debugging web applications) than when changing global HTML settings, when markup is built in parts in thousands of different functions. HTML should just be in HTML files with the minimum number of scripts needed to bind them to classes.

0
source

All Articles