加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 在哪里可以找到一个简单的简单解释MVC?

发布时间:2020-12-16 00:40:44 所属栏目:asp.Net 来源:网络整理
导读:在我的公司,我们即将使用ASP.NET MVC构建一个新网站。我的老板(营销人员)想了解一些关于技术的内容,所以我试图找到一个非常好,简单和教学性的MVC概念,没有任何运气。他们大多数在编程中需要相当多的基础知识。 任何关于好视频,幻灯片或其他的建议? 解
在我的公司,我们即将使用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 you
is as clear as day,but saying to the business ‘Model,View,
Contoller’ could give them the impression that you are suffering from
some form tourette syndrome. MVC won’t mean much to the business even
after you define them in relation to the code. To get the business to
understand why this is the answer and least of all what it is,can be
more of a task than expected in my experience. Even some fellow
developers have difficulty understanding this on occasion.

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

To give an example of how you could describe this I have very briefly
explained how separation works in property. Keep in mind this is
focused on using the system not developing which could be a completely
different angle of explanation.

View

The view in MVC is the presentation layer. This is what the end user
of a product will see and interact with. A system can have multiple
views of all different types ranging from command line output to
rendered HTML. The view doesn’t consist of business logic in most
clear designs. The interface is fit for purpose and is the area of
interaction. Therefore you could simply output HTML for consumers to
interact with or output SOAP/XML for businesses to interact with. Both
use the same business logic behind the system otherwise known as the
models and controllers.

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

Controllers

The controller is where the magic happens and defines the business
application logic.
This could be where the user has sent a response
from the view,then this response is used to process the internal
workings 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 and
item choice. These elements are then processed through the business
logic to complete a purchase. The data is passed through the system
into the model layer and eventually after the entire request satisfies
the business definitions,the order is constructed and the user
receives their item.

If we compare this to a property,we could compare the ordering of a
book online to turning on a light switch. A tenant will flick the
switch to on just like ordering a book. The switch itself is an
element in the view layer which sends the request to the controller
just like clicking a checkout button on a web site. The business logic
in this case is what the electrician installed and are embedded within
the property designs. The switch is flicked,which completes the
circuit. Electricity runs through all the wires including the fuse box
straight through to the light bulb. Just like the user receiving a
book,in this case the tenant receives light. The whole process behind
the scenes involving the electricity cabling is not visible to the the
tenant. They simply interact with the switch within the space and from
there the controller handles the request.

Models

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

Sticking with out example of turning on a light switch,this level in
our structure could be the electricity supply. When the tenant flicks
the switch,the internal circuit must request electricity to power the
request which is similar when the user requested data from the
database,as in data is needed to process a request. If the dwelling
isn’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 then
have to see what benefits can be obtained from it. I’m not going to go
into a huge amount of detail here are I’m sure you can apply benefits
more accurately which are directly related to you actual situation. To
list just some of the common benefits of an MVC based system here are
a few examples:

  • Different skill levels can work on different system levels. For example designers can work on the interface (View) with very little
    development knowledge and developers can work on the business logic
    (Controller) with very little concern for the design level. Then they
    simply 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 the
    developer and vice versa. This development process can be parallel as
    opposed 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 as
    you clearly know the permitted route from the data to the user and can
    have 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 maintained
    and managed much easier and quicker than a tightly couple system where
    you 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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读