Results tagged “MVC”

MVC?????????????(5)

MVC??????????????????????????????MVC?????????????????????????????????????????
???????????????MVC??????????????????????

?????????????????????????????????????????????????????????????????????????????


?1. MVC?????????GUI?????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????AWT?Swing?*/Tk?GTK?VB?VC???????????????????GUI??????????MVC?????Controller??????View????????Controller?View?????????????????Controller?View??????????????C????????V???????????????????

????GoF????????MVC???original??Smalltalk??MVC??????Controller?View??????????presentation logic?domain model???????????????????????????GUI??????????????????????????M?V?????????????MVC??????????????
???MVC?GoF??????????????obsoleted???????????????????????????????23????????????????????????????

????????????????Web?????????????????????????

[3]?????????

if you need to send an onMouseOver event to a controller instead of just changing state on the button in the view, what do you gain?
...
Only things that change application states (be they persistent, session-specific, or application-wide) should be sent to a controller

?View????????MouseOver?????Controller????View???????????????????View????????????????????????????Model????????????????Controller????????????????????????View??Controller???????????????

[6]?????????

MVC, and StateMachines are orthogonal concerns (depending on the app each tier may have it's own StateMachine). The differentiation typically is in MVC the model state is persistent, and survives a many to one relationship (e.g. a bar and line graph both using the same data.) where as state machines are useful for runtime states.

MVC??????????????????????????????MVC?Model????????????????????????V-C?????????????????Model???????View?Controller??????????????????????????????
GUI??????????View????Controller???????????????????????????????????????????View?Controller???????????????????????????????View?Controller?????????????????????

???[6]?????????

Some definitions of MVC call for a single controller, supporting multiple models, each with a view. Obviously, Flash apps almost never work like that - Flash MVC is really distributed MVC, often different views have their own controllers, and views are all managed by a master state management controller.

Adobe Flash?????MVC????????M:V:C????????????????????View?????Controller?????????????Controller??????????"distributed MVC"????

???Cocoa MVC???"Responder"?Controller????????????"Responder chain"??????????????????????????????????????GUI????????MVC???????????????????????Controller?View?????????????????View????????????????????????????????View??Responder chain???????????View??Controller????????????????????????�?


?2. MVC???????????????????Web??????????
???MVC???????Model??????View??????????View?Model????????????????????????????HTTP?????PUSH?????PULL?????????????Web???????Model??????????View?????????????????Model???????View?????????????

Web?????????????J2EE?Struts?Flex?????????�Model 2�????????????????????MVC?????????????????Web?????MVC??????????????????????????????MVC??????????????????????????????
"Model 2"???????????????????????MVC???????????????????????????????GUI???MVC????????????????????MVC????????????

????????HTML????????View?????HTML??????????????????????????UI????????????View??????????????????Ajax?Flash?????????????????UI???????????????????????????????????????????????????????????????????????????????????????????????????????????????Model??????????????????????????????????

????????????MVC????????????Web?????????????MVC?????Model, Controller???????????????????????Model???Controller???????????????????????????????????????????????????????????????MVC???????????????????"Model 2"?MVC?????????????????????????????????MVC?????????????????
????????"Model 2"?MVC????MVC???????Web????????MVC???????????????????????????????

????????????????
[1] "MVC As Anti-Pattern"???

But what if you are building a web application with a rich client?
[snip]
Do you still need an MVC framework?
I think the answer is most likely no.
????????????????????????????????????????????????
Developers who use modern rich-client frameworks do not have to create controllers to manage events. What a runtime and its frameworks do internally is a different story.
??"rich-client frameworks"??View???????????Controller???????????????????GUI??????????????

[3]???

I�ve come to the conclusion that� drumroll please� MVC is probably not needed for most RIAs.
RIA?Rich Internet Applications???????????????????????????????????????????????"FrontController pattern"????????????????????????????????FrontController??????????????????

You often see architectures in which a single controller handles all of the �actions� for the entire application. I see this as a necessary evil, not a �good thing�. The world of the giant switch statement is exactly what we wanted to avoid with OO programming, right?
?????MVC?Controller????switch?????????????????????????most controversial?Skinny Controller, Fat Model??????????MVC??????????

[3]?????????

I agree, separate model and view is enough, controller sometime is abused
M-V????????????C????????????????

[6]???

Fact: No one codes Flash using pure MVC.
???????????????????????????????????????????

[3]?????????

In addition, just consider the case (in the real Business world) when you need to deploy a program (which also holds the Controlling) on the client machine
????????View???????????????????????????????????????Controller?????????????????????????????????????????????????V-C???????????????????????????????V-C????????????????????????V-C???????????????????????????????????????????????????????????????????????????????

[3]?????????

Anyone who justifies MVC as a way of making a web app �like� a desktop application�s MVC architecture is fooling themselves. The internet just doesn�t work that way. I�ve seen IT budgets balloon and schedules run late because of the blind, over-zealous switch to MVC, while chanting �industry standard� to anyone who asks �why?�


?3. MVC??????????GUI??????
MVC???????UI???????????View?????????????????????????????????Controller???????????????????????Controller?View???????????View????????????????View??????????????

?????????View?????????View??????????????????????????????????????????????????????????UI??????????????????

???View????????????Controller???????????????????????????V??1??????switch????Controller???????????????????Controller???????????????????????View????????????????View??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????View??????View?????????????????????????

?????????????????????MVC????????????????????????MVC?????????????????????????????????????????M???????????????????????????V?C?????????????????????????????????????????????????????????????????????????View????Controller?????????????????????????????????????????????????????????????????View?Controller????V-C?????????????????????????????????????????????GUI?????????Controller????View???????????????Controller?View??????????????????

????????original MVC??????????????????????"The Model-View-Controller (MVC) Its Past and Present"?P-8 "Tools for Tasks"?P-9 "Tool as a composite"?????????????V-C?Tool????????????Tool?Tool????????????????????????????????GUI????????????????????????GUI?????????????????????????????????????????????Tool????????????????MVC??????????????????GUI????????MVC????????????????????????????????????????MVC????????MVC????????????????????MVC?????????????P-8?P-9??????????????

???GUI????????GUI?????MVC???????????????????????????V-M??????MVC???????????????????????MVC????????????????????MVC??????????????????

[3]?????????

One of the reasons that people build controllers is to isolate the interaction logic from the view, with the goal of being able to swap out the view. The problem with this approach is that with the richer UI vocabulary that RIAs allow, I believe it is not possible to do this.
UI?????????UI??????View???????????????????????
????M,C??????V??????????????????????????????????????????GUI????????????????????????????????


?4. MVC?????????????????
?????????????????????????????MVC?????????????????????????????????????????
??Model??????????????????????????????????????MVC???????????????Model?????????????????Model?View???????????????????????????????Model?????????????????????????????

?????????????????????????????????????????????????????????????????????????????????????Model?????????????????Presentation?Model???????????????????????????????????????M??V??C???????????????????M?V?C???????????????

??????Controller?Model???????????????????????????????Model????????????????C-M????????Controller?????Model?????????????????????????????Controller????????????????????????????Model???????????????????????Model????????????????????????Model?????????????????????????????Controller??????????????????????

Original MVC??"THING-MODEL-VIEW-EDITOR"???????????????????????????UI?MVC???????????????????"EDITOR"?MVC????????????????????????

?????????MVC??????????????????????????????????????????????????????Model?View?????????MVC????????????HMI(Human-Machine Interface)????????????????????????????Model?????????????????????????????????????????????HMI?????????????????????????????

??????????????????MVC????????????????MVC?????????????????Model???????????????????
????????????????????????????????????????Model???????????????????????Controller??????????????1???????Model?????????????Controller?????????????????????????????????????????????????????????????????????????????????????????????????????????Controller?????????????????????Model?Controller??????????????????????????????????????????Controller??????????Model????????????????????????????????????????????
???????????UI???????????View???UI??????????View?????V-C??????????????View??????View????????????????????Model????????????????
??????????????UI??????????????????????????????Model???????????????
?????UI????????????Controller???????????Model????????????Controller???????????????????

??????????MVC???UI??????Model?????????????????????????MVC???????????????????

????????????????Model???????????????????????????????????????????????????H/W?????????????????????????????????????????????????????????????????????????????????????????????????????????????presentation logic???View????????????????????????????????????????????????????????
UI intensive?????????MVC????????????Smalltalk?MVC???????????????????????????????????????web???????????????????????Model?????????????Model????????????????

????????????????

[2]???

By letting the service layer refer to sessions, I am also creating a Model that is hard to test without having an entire application in place.

????"service layer"?Model?????Controller?View??????????I/F????????Model?????????????Model?????????????????????????

???[2]?????????

This makes me think of what Misko Hevery was saying in a previous blog post - that the more testable something is, the better it is probably architected. And, the more easily tested it is, the more it likely decoupled from other objects.

One of the huge benefits of separation of concerns is testability. If you've designed your components properly, you should be able to write test cases that can give you some peace of mind.

[4]??

If you are designing a graphics intensive program, like a game, you would probably couple the View and Model classes much more tightly than what MVC suggests. As we can see from the Basic sample application, when programming a very simple application it is common to combine the controller with the view classes.

[3]?????????

Things, of course, get tricky when user interaction comes into play. For example, if you need to pop up an alert that asks the user a question before completing the transaction.

[3]?????????

If you�re doing a word processing application, is the keypress sent to the controller, added to the document via the model, then the view is refreshed via the controller? Or is the model used to save changed files and the view handles all the live updates to the text?

[6]???

MVC says that the entire application state is supposed to reside in the model. However, many applications maintain application view state in the controller, and the data state in the model.

MVC????????????????Model??????????????Original MVC???????GUI????View?????????????????????????Controller?View??????????????????????

Controller?GUI????????????????????????????????
Original MVC?Controller?View????????????????????????????GUI???????????????????????????View???????????????????????????????Smalltalk?????????????????????????????????????????????????????????????????????GUI??????????????????????????????GUI??????Model??????????????????


?5. MVC?????????????UI?????
????View??????Model?????????????????????Controller?????View???????????????????
????MVC??????Model-Vew??Observer pattern??????????????Model?View??????????Model???????????????View?????View?Model?????????????????Model????????????????????????????????????????Controller????????????????????????????????????????????????????????????????????????

?????View????????????????????????????Model?????View????????????View???????????????????????????Model???????????????????????????????????????????????Model???????????????????????????????
????Model???????????????????????Controller?????????Model?????View?????????????Model?????View????????????????????????????????????Vew?Model?Observer?????????????

???MVC?????????????????????Model????????View??????????????????????View??Model?????????????????????????Model??????????????????????????????????????????????????????????View?Model?????????????????????Model??????????????????????????????View?????????MVC?????????????????????

????[5]???

The first problem area is to deal with setting the color of the variance. This shouldn't really fit into a domain object, as the color by which we display a value isn't part of the domain.
??????????variance??????????????????????????????????????????????????????MVC?????????????????????????????????????????????????????????????????????text field?subclass?????????????????????MVC???"Presentation Model"?View????????????????????????????????????????????????


?6. MVC?????????????
???MVC???????????????????????Web???????????????????????"Model 2"????GoF????????????????MVC?????????Smalltalk?MVC??????????Smalltalk?MVC??????????????????????????????????????????????MVC???????????????????MVC????????????????????????????MVC????????????????

Smalltalk??????????MVC??????????????????????Smalltalk?MVC????????GUI????????????????????????????MVC????????????????????
??????????????????????????MVC???????????????????????????????????MVC??????????????????????

?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????MVC?????????????????????????????????????MVC???????????????????????????MVC??????????????????????????MVC?????????????????????????????????????????????????????????MVC????????????????????????????

MVC????????????????MVC??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

[6]???

Patterns are architectural heuristics. Understanding them should widen your solution spectrum, not narrow it. They provide you with proven ways of solving a specific problem in programming. The reality is that you will rarely encounter that specific problem in the wild, but you will encounter variants of that problem

??????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

[6]?????????

I only like to talk about MVC now when there is something resembling Smalltalk MVC triads at work and controllers are required to move messages between triads. Otherwise I think the GOF book got it right to not include MVC as a pattern.

When people say they are using MVC I take that to mean they see their application as being organized somehow into three parts that can be worked on separately:

1. data and business logic,
2. presentations of that data, and
3. some sort of event management and propagation system.

I don't really think MVC means much more than that anymore. Consequently its value in discussing real-world designs has become suspect.

[3]?????????

One of my main issues with the whole framework/mvc debate is that it has been my experience that one size can not fit all.

?????????????????????????????????????????????????

[3]?????????

The most important part of an abstraction is not what patterns it strictly adheres to, but what it provides the programmer in terms of power, maintainability and ease of use.

� and back to the discussion on MVC: my �tool� abstraction encapsulates user input processing, drawing transparent scratch information (for example to display a selection rectangle) and model object manipulation. Is the tool a controller or a view? Could it even be a model (at the application level as opposed to the document level)? The answer: who cares. These labels we use are for architectural communication and education, not as rules that must be adhered to regardless of the problem domain.

A more important question than �do your developers implement design patterns?� is �do your developers *understand* design patterns and spend the time creating, analysing and discussing abstractions that may enhance the design of your application?�

?????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????


????
[1] MVC As Anti-Pattern
?MVC???????????????????Web?????????????????????????????MVC????????????????????????
[2] A Better Understanding Of MVC (Model-View-Controller) Thanks To Steven Neiland
?MVC?????????????????????????????????????????
[3] MVC considered harmful
?????????????????????????????????????????
[4] Best Practice Software Engineering - Model View Controller
????MVC?????????????????????????????????????
[5] GUI Architectures
??????????Martin Fowler?????Web?????????????????????????????????
[6] On Design Patterns and Reality
??????????????????????????????

MVC?????????????(4)

???????????????"Model 2"?MVC??????????????????????????MVC?????????????????????????????????????????????????????????????Web??????????????????????????????GoF????????MVC???????????????????"Design Patterns: Elements of Reusable Object-Oriented Software"???????????????????????????????????????????GoF??�1.2???????????????

MVC consists of three kinds of objects. The Model is the application object, the View is its screen presentation, and the Controller defines the way the user interface reacts to user input.
MVC also lets you change the way a view responds to user input without changing its visual presentation. You might want to change the way it responds to the keyboard, for example, or have it use a pop-up menu instead of command keys. MVC encapsulates the response mechanism in a Controller object.
A view uses an instance of a Controller subclass to implement a particular response strategy; to implement a different strategy, simply replace the instance with a different kind of controller. It's even possible to change a view's controller at run-time to let the view change the way it responds to user input. For example, a view can be disabled so that it doesn't accept input simply by giving it a controller that ignores input events. ???????"disabled"?????????????????????

GoF??1.2????????????????Controller????1??Model????View????????????????????????????????Controller?View??????????????????
MVC???????Presentation logic?Business logic????????????????????????????????????????Original MVC?????????????????????Controller????View?Model????????????????????????????????????MVC???????????????????

?????????????????????????????????View????????????View?Controller???????????????????????Original MVC?????????????Original MVC????????Controller??View???????????????GoF????????????
??????Original MVC?Controller??????

Conversely, a view should never know about user input, such as mouse operations and keystrokes. It should always be possible to write a method in a controller that sends messages to views which exactly reproduce any sequence of user commands.

??????????????????View??Controller????????????"views which exactly reproduce any sequence of user commands"????????????????Controller????????????????????????????????????????????????????
?????Java?Swing?Qt, GTK???????????????????????????GUI???View???????????
?????????????

Class diagram of MVC in the GoF design pattern book
?5-1: GoF??MVC????????????

Communication diagram of MVC in the GoF design pattern book
?5-2: GoF??MVC??????????????????

?????????View?????????????????????????????Original MVC??V-C????????Controller?????????????View???????????View?Controller??????????????View?????????????Controller?View???????????????????????????????Swing??GUI????????????????GUI????????????????????????????

View?Controller???????Original MVC???????????????????Controller????????????????????????????????????????

Communication diagram of MVC in the GoF book
?5-3: GoF????????MVC?????????????????


??MVC????????GoF MVC??????GoF????????????????????????????????????????????????????
?Observer
?Strategy
?Composite
?Factory Method
?Decorator

Observer pattern?????????????????Model???????observer?????????????View?????????????????????????????????
Observer pattern in GoF MVC
?5-4: GoF MVC????Observer????

Strategy pattern????????????View?????????Controller??View???????????????????????????????????GUI????????????????????????????????????????????????????Controller?View????????????????
Strategy pattern in GoF MVC
?5-5: GoF MVC????Strategy????

Composite pattern??View????????????View??????????????View?????????????View?View??????????????????????????GUI????????????????????????????????????Original MVC?"The Model-View-Controller (MVC) Its Past and Present"?P-9???"Tool as a composite"???????????????
Composite pattern in Gof MVC
?5-6: GoF MVC????Composite????

Factory Method???????View?default controller????????????????????????View????Controller???????????????????View?Controller???????????????????????create??????????GUI???????????????????????????????????main?????????????????????????????????????????????????????????Controller?Factory?????????????
Factory Method pattern in GoF MVC
?5-7: GoF MVC????Factory Method????

Decorator??????View?????????????????????????????????????????????????????????GUI????????????GoF?????????????????????????????????????????????
???????????????????????????????????????????????????Adapter?Decorator????????????????????????????????????????????????????????????????????????????????????????????
Decorator pattern in GoF MVC
?5-8: GoF MVC????Decorator????


????C?V??????V?C??????MVC??????????????GoF????????????
???MVC???????????????????????V-C?????View??Controller???????????????V-C?????Controller??View????Original MVC????GoF????????????????????????
??????????GUI?????????????MVC?????????????MVC??????????????????????????????????????????????MVC?????????MVC??????????????????????

GoF????????MVC?????????Controller??????????MVC?????????????????????????????????????????????????????????????????????????Controller???????
???GoF?????????Controller?View??????????�??????????Original MVC???View???Model??????????????????????Controller???MVC????????????????????????

Controller?View?Model?????????MVC????View?Model?????????MVC??????????????????????????????Controller????C-V??????????????????????????????MVC?????????Controller??????MVC???????????
???????????????Controller????????????????????????????????Controller??????????????????????????????Controller?View???????????????????MVC???????????????????

????GoF???????????MVC????????????????????????????????GUI?????????????Erich Gamma??Java???????????AWT????????????????????????????????????

MVC?????????????(3)

???2?????????????1-1??1-2????????MVC??????????????????????????????????????Controller???????????????????Controller?????????????Controller?????????????????Model???????????????

????Controller?View??????????????????????Model????????????????????View??????????View??????????Model?????????Controller?View????????????????????View????????????????????View?????????????

View?Controller????????????MVC??????????????????????????Model???????????????????????????????Model????????????????????????????MVC?????????
???original?MVC???????

"MODELS-VIEWS-CONTROLLERS"?Controller?????

It provides means for user output by presenting the user with menus or other means of giving commands and data. The controller receives such user output, translates it into the appropriate messages and pass these messages on to one or more of the views.
???Controller?????????????????????????????????????????????????????????Controller?????????????????????????????????????View?????

?????????????????Controller?????Controller???View????????????????????????????????????????

Class diagram of MVC with V-C connection
?2-1: Controller???????MVC????????????

Communication diagram of MVC with V-C connection
?2-2: Controller???????MVC??????????????????

?1??????????????

  • ConcreteView?Controller?????????I/F???
  • ConcreteController??ConcreteView???????
  • Controller?View???????C-V?????????

????Controller???View???????????????View?Controller????????????CUI?????????Model?View?Controller?UI?????????????????Controller???View??????????

C-V???????MVC????????????????MVC??????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

???????????View?????UI???????????????????MVC????????????????????View????????????????MVC???????GUI????????????????????????????????????????????


"MODELS-VIEWS-CONTROLLERS"?Controller?????????V-C???????????????????


Conversely, a view should never know about user input, such as mouse operations and keystrokes. It should always be possible to write a method in a controller that sends messages to views which exactly reproduce any sequence of user commands.
??????????view?????????????????????????????????????????????????view?????????method?Controller????????????????

????????"user output"??????????"user input"?"messages"?"user commands"???????????????????????????????"THING-MODEL-VIEW-EDITOR"?VIEW?EXAMPLE 1???
It understands a message asking it for an item that is positioned at a given point within its frame, and a message asking it to select a given item.
???????????frame?Controller?????????"a given point within its frame"?????????"user input"??????????????????????????????????????????
One possible sequence for selection is that the Editor reacts to redbug and asks the ListView for the item that is pointed to. The Editor then asks the ListView and any other Views to select that item.
???????????Editor???Controller?ListView???View????
??????Controller????View?????????????????????????????????????????????????????????????????????????View??????????????????View????????????????????????Controller???????????????????????????????????????View???????????????????????????????????????

??????????EXAMPLE 4????


In addition, it will need some operations on the View itself, they have to do with the positioning of the symbols in the diagram.

????Model???????????????Model?????????Model?View??????????????I/F???????Controller??View???????????????

???"MODELS-VIEWS-CONTROLLERS"?????VIEW????????????M-V????????????

A view ... gets the data necessary for the presentation from the model by asking questions. It may also update the model by sending appropriate messages. All these questions and messages ...

????View?Model???????????????????????????????????????????"THING-MODEL-VIEW-EDITOR"?VIEW??????
A View is also able to perform such operations upon the Model that is reasonabely associated with that View.

?????????EXAMPLE 6???

It is also able to pass on operations on the network and its activities that are related to this particular View. Typical operations have to do with modifying the current schedule.
?????????network?Model?activities?schedule?network????

???????Controller?????Model???????????View??????????????????????Controller??????Controller???????View???Model?????????????????????

???????MVC????????????????

Class diagram of MVC without V-C connection
?3-1: MVC????????????

Communication diagram of MVC without V-C connection
?3-2: MVC?????????????2-2????????

???????????????J2EE?ASP.NET???MVC?????????????????????????????MVC??????????"JSP Model 2 architecture"?????"Model 2"?????????????????
???Web??????MVC???????????????????????????????connectionless??stateless????View????HTTP request????response???????????????Model??????????View???????????????????M-V??Observer??????????????????

Class diagram of "Model 2"
?4-1: "Model 2"?????

Communication diagram of "Model 2"
?4-2: "Model 2"???????????

???"Model 2"??????????MVC??????????????????MVC????????????????????????????????????MVC?"Model 2"????????????MVC????????????MVC?????????
????View?Observer???MVC????????????"Model 2"?MVC????????????????????????????????????Web???????????????????????????
"Model 2"???????????????????????????"Model 2"?MVC??????????

?"Model 2"??????


MVC?????????????(2)

????????????MVC???????????????????????????????????????????1-1??1-2????V-C????????????????????????????????????????

  1. View???????View???????Model??????
  2. Model?View/Controller?????????????????????
  3. Model?View??????????Controller????????????
  4. Model?View????????????????????
  5. Model+Controller?View?????????????

(1)??????????????????????????????????(Presentation)???????????????????????????????????View???????????????Model?????????????View?????????????????????MVC???????????????????????
???Controller?View?Model????????????????????View????Controller?????????????????????????Controller??????????????????????????????Controller?View????????????View?????????????????????????????????????????

(2)??Model???????????????????????????????????????????????????????????????????????????????????View?Controller????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????Ca??????????????Ce?????Ce/(Ca+Ce)???????????????(Instability)??0?1?????????????M,V,C??????????????Model?????????????0?View?Observer I/F?????????????????????????MVC?????????????Model?View?????????????????????Controller???????????????Controller??????????????????????????????????

(3)????????????????????????????????????????????????????????????????????????UI????????????????????????????????????????????????????????????????????????????????????MVC?????UI?????????????????????????
????????Controller?Model??????UI??????????????????????Model??????????????????????GUI?????????????????CUI???????Model?????????????????????????????????????????
?????????????????????????????????????????????????????????????????????10?????????????????????xUnit????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

(4)????????????????????????????????????????????????????????MVC???????????????????????????????????????????
?????????????(business logic)????????????(presentation logic)???????????business logic????????????????????????????????????????????????business logic?presentation logic????????????????????????????

(5)????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????MVC??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Model??????????????UI?????View?????????????????????UI????????????????????????????????????View????Model?????????????????????Model?View????Model??2??Model????????????2??Model???????????Controller????????2??Model?????Magager Model??????????????????????????UI?Model????????????????????????

MVC?????????????(1)

MVC(Model-View-Controller)??????UI??????????????????????????????????????????J2EE?ASP.NET??????Web?????????????????????????????????????????
????????????????GUI????????????????????????????????????????????????

MVC????????Smalltalk-80???????????????????????MVC?????????


MVC was created as an obvious solution to the general problem of giving users control over their information as seen from multiple perspectives.
?"The original MVC reports"?????????????????????????????????????????????????????????????????????????Smalltalk???????????????????????????????????????????MVC????Smalltalk?????????????MVC??????????????????????????????????????????GUI???????????????????????????????????

??????MVC??????????????????10??????????MVC?????????????MVC???????????????????????????10??????4????????MVC????????????????????????????????????????????????????????????????????MVC?????????????????????????????????????????????????
?????????????????MVC???????????????????????????MVC????????????????????????MVC??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????MVC???????????????????????
�?????????????????????????????????????????????????????

MVC???????????MVC????????????????????????????????????????????????????????????MVC?????????????????????????????????MVC?????????????????????????????????

??????????????????????MVC????????????

  1. Model??????????View?Controller???????????????
  2. ????????????????????????????????????????
  3. ???????????M,V,C?????????????????????
  4. M,V,C????????????????????????????????????????????????????

?????????????????????

(1)??????UI???????????????????????????????V?M????C???????????C??????????????????????????????????????????????????????????C?V?????????????V?C?????????V?C????????????????V+C???????????????????????????V+C?????????????????1???V+C?????????1?????????????????????????????

(2)????????????UI????????V-C??????????????????????????M-C????????????????????
???????????????????????????????????????????????????????????????????????????????????????C??????????????????????"Skinny Controller, Fat Model"??????????????????????????Model?????????????????????????????????????M???????C??????????????????????????

(3)?????Model??????????????????Model?????I/F?View??????????????????????????????Model???????????????????I/F??????????????????????????????????????????????????????View?????????????????????????????????????????????????????
V?C????????????????????????????

(4)?????J2EE??Model???????????Java Beans(EJB)?View????????????JSP technology?Controller????????????Servlet technology?????????????????????[@IT 1] [@IT 2] ["Multitiered Applications" in Java EE tutorial])?M/V/C????????????????????????????????EJB??????????M,V,C????????????????????????Java Beans?V??C??????????????JSP?M?????C??????????????????Java Servlet???M?V?C?????M,V,C?????????????????????????????????????????????
????M/V/C??????????????????????????????????????????????????????????????????

??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

????????????MVC????????????
??MVC?????"MODELS-VIEWS-CONTROLLERS"???Model, View, Controller????????????????


Model
?????????????????????????????????????????????????????????????????"Models represent knowledge."?"knowledge"?????????????????

View
Model????????1??View?Model????????Model?????????????????????????????View???????????Model????????????Model????????????Model??????????????? ?"It may also update the model by sending appropriate messages."???????????????????????

Controller
?????????????????????????????????????????????????????????????????????????????????????????????????View?????????????
Controller?View??????View??????????????View??????????????????????????????


???MVC????????????????UML????????
Class diagram of MVC without V-C connection
?1-1: ???????MVC????????????

Communication diagram of MVC without V-C connection
?1-2: ???????MVC??????????????????

???"MODELS-VIEWS-CONTROLLERS"?????View??Model?Controller??View????????????????????????????????????????????????????MVC??????????????????????????????????

?????????????????

  • 1??Model????View??????????????
  • Model?View???????????View???????????????
  • 1??Model????Controller????????????
  • View?Controller??????????

???1??View????Model????????????Model??????????????????????????MVC???????"THING-MODEL-VIEW-EDITOR"??"each View being capable of showing one or more pictorial representations of the Model"????????????M-V, M-C????????????????????????????????Model???????????MVC????????????????View????Model?????????????MVC????????????????????????????????????????????????????????????M-V, M-C???????????????
????