gpt4 book ai didi

asp.net-mvc - 在哪里可以找到关于MVC的简单解释?

转载 作者:行者123 更新时间:2023-12-03 12:35:40 24 4
gpt4 key购买 nike

在我公司,我们将使用ASP.NET MVC建立一个新站点。我的老板(市场营销人员)想了解有关该技术的更多信息,所以我试图找到一个真正好的,简单且具有教育意义的MVC概念介绍,但没有任何运气。他们中的大多数都需要大量的编程基础知识。

对于优质视频,幻灯片或其他任何建议?

最佳答案

克雷格·斯特朗(Craig Strong)撰写了一篇不错的文章,介绍了有关MVC的总体知识以及如何解释其对业务的好处。在此处检查:Updated link

Define MVC in layman’s terms

Remember you’re technically minded and close to the code. MVC to youis as clear as day, but saying to the business ‘Model, View,Contoller’ could give them the impression that you are suffering fromsome form tourette syndrome. MVC won’t mean much to the business evenafter you define them in relation to the code. To get the business tounderstand why this is the answer and least of all what it is, can bemore of a task than expected in my experience. Even some fellowdevelopers have difficulty understanding this on occasion.

To get the listener to understand what MVC is and why it works what Ihave tried in the pass is to apply MVC to a different industries wherethe listeners have had more involvement. An example that has workedfor me in the past in a comparison to the property or even thevehicles. Most people have had dealing’s with builders, carpenters,plumbers, electricians or have watched the flood of property shows onthe TV. This experience is a good platform to use and to explain whyseparation such as MVC works. I know you’re probably thinking thatwon’t work as it’s not the same as in software, but remember you’renot trying to train the business to become developers or have an indepth understanding of MVC, simply explaining to them that separationin production is required and that’s what an MVC structure offers.

To give an example of how you could describe this I have very brieflyexplained how separation works in property. Keep in mind this isfocused on using the system not developing which could be a completelydifferent angle of explanation.

View

The view in MVC is the presentation layer. This is what the end userof a product will see and interact with. A system can have multipleviews of all different types ranging from command line output torendered HTML. The view doesn’t consist of business logic in mostclear designs. The interface is fit for purpose and is the area ofinteraction. Therefore you could simply output HTML for consumers tointeract with or output SOAP/XML for businesses to interact with. Bothuse the same business logic behind the system otherwise known as themodels and controllers.

In the world of property you could think of the view as the interiorof a property or the outer layer of a property that the inhabitantsinteract with. The interior can be customised for purpose and the sameproperty can have many different types of tenants. For example aproperty of a particular design could contain residential dwellings.The same internal space could easily be used as office space, wherealthough in the same property has a different purpose. However theproperty structure is the same. Therefore the environment in which theusers interact does not interfere with the structure of the building.

Controllers

The controller is where the magic happens and defines the businessapplication logic. This could be where the user has sent a responsefrom the view, then this response is used to process the internalworkings of the request and processes the response back to the user.Taking a typical response where a user has requested to buy a book.The controller has the user id, payment details, shipping address anditem choice. These elements are then processed through the businesslogic to complete a purchase. The data is passed through the systeminto the model layer and eventually after the entire request satisfiesthe business definitions, the order is constructed and the userreceives their item.

If we compare this to a property, we could compare the ordering of abook online to turning on a light switch. A tenant will flick theswitch to on just like ordering a book. The switch itself is anelement in the view layer which sends the request to the controllerjust like clicking a checkout button on a web site. The business logicin this case is what the electrician installed and are embedded withinthe property designs. The switch is flicked, which completes thecircuit. Electricity runs through all the wires including the fuse boxstraight through to the light bulb. Just like the user receiving abook, in this case the tenant receives light. The whole process behindthe scenes involving the electricity cabling is not visible to the thetenant. They simply interact with the switch within the space and fromthere the controller handles the request.

Models

The models in MVC are the bottom most layer and handle the core logicof the system. In most cases this could be seen as the layer thatinteracts with the data source. In systems using MVC, the controllerwill pass information to the model in order to store and retrievedata. Following on from the example above controller definition, thisis where the order details are stored. Additional data such as stocklevels, physical location of product of the book amongst many thingsare all stored here. If that was the last book in stock ordered, thenext request for this item may check if it’s available and disallowthe order as the item is no longer available.

Sticking with our example of turning on a light switch, this level inour structure could be the electricity supply. When the tenant flicksthe switch, the internal circuit must request electricity to power therequest which is similar when the user requested data from thedatabase, as in data is needed to process a request. If the dwellingisn’t connected to an electric supply, it cannot complete the process.Business benefits from using MVC

After you get the message across explaining what MVC is, you will thenhave to see what benefits can be obtained from it. I’m not going to gointo a huge amount of detail here are I’m sure you can apply benefitsmore accurately which are directly related to you actual situation. Tolist just some of the common benefits of an MVC based system here area few examples:

  • Different skill levels can work on different system levels. For example designers can work on the interface (View) with very littledevelopment knowledge and developers can work on the business logic(Controller) with very little concern for the design level. Then theysimply integrate together on completion.
  • As a result of the above separation projects can be managed easier and quicker. The designer can start the interfaces before thedeveloper and vice versa. This development process can be parallel asopposed to being sequential therefore reducing development time.
  • Easy to have multiple view types using the same business logic.
  • Clear route through the system. You clearly know where there different levels of the system are. With a clear route of the system,logic can be shared and improved. This has added security benefits asyou clearly know the permitted route from the data to the user and canhave clear security checks along the route.
  • Each layer is responsible for itself. (Relates to point 1) This means that you can have clean file structure which can be maintainedand managed much easier and quicker than a tightly couple system whereyou may have lots of duplicate logic.
  • Having a clear structure means development will be more transparent which should result in reduced development time,maintenance problems and release cycles if applied properly.

关于asp.net-mvc - 在哪里可以找到关于MVC的简单解释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/883004/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com