Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30424
| Date | 2014-11-26 20:40 +0000 |
|---|---|
| From | lipska the kat <lipskathekat@example.com> |
| Organization | A Gang of Wailing Harpies |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: MVC Partner |
| References | <986bdeb7-709c-4e79-91e6-1b31771f7d06@googlegroups.com> |
| Message-ID | <EM6dnQUsINsnp-vJnZ2dnUVZ8j-dnZ2d@bt.com> (permalink) |
On 26/11/14 19:16, Leonan Luppi wrote: > Hello Guys, > > I have some doubt about MVC. Someone could solve please? > > So for my "M" it's need to be my mirror of DB (Entity mapped my JPA for example)? > > For my "V" it's need to be interfaces which only show and send to my controller? > > For my "C" it's need to be all business rules, calling my DAO to result from DB ? > > Someone can give an example please? > I really think that there is an awful lot of mis-information out there about MVC. For example the wikipedia article mentioned by another responder talks about MVC being a 'design pattern' when effect it is a combination of several design patterns. I think 'paradigm' might be a better word. The *original* idea behind MVC was that you had a Model, this could be any persistent store, often but not exclusively a database. The Controller was responsible for updating the Model in response to interactions with the View. There could be many Views on the Model each of which registered themselves with the Controller and each of which were updated in response to an interaction with any one of them. so for example you could have 3 Views, possibly on 3 different devices and if any View was modified by a 'user' the state of the Model was first updated by the Controller which then updated *all* the views that were registered with it at the time. The finer details escape me, it was some years ago when I studied this. With the advent of Java, Sun came up with something called Model2 IIRC. In this case you still had your persistent store but the Controller was a Servlet (or rather the interface to the Controller was a Servlet) and the view was (classically) implemented as a JSP. The fundamental difference is that because http is a request/response protocol and there is no way to 'push' changes initiated by one view to other views. Things may be slightly different now with the advent of asynchronous technologies such as Web Sockets. So, in the classic 3 tier Model 2 web application you have an SQL database which would be your Model, a Servlet engine such as Tomcat which would host your Servlets (your Controllers) and a (arbitrary) client, let's say in this case a web browser, to which you would deliver your View implemented as a JSP Your business logic is typically accessed through a facade accessed by a Servlet, your business logic would communicate with a facade onto your database, this would initially be an Interface. The single most important thing to remember is that your business logic should be completely decoupled from the View *and* from the Model. In this way you can deliver your content to any interface, not just a web interface and persist you data to any type of persistence mechanism. -- lipska the kat - treacherous feline. Proudly nominated for IPOTY 2014 - LIGAF ================================================== Any GNU/Linux distribution that does not come with the set of tools required to build its open source kernel is incomplete. This is an opinion. ================================================== GNU/Linux user #560883 - linuxcounter.net
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
MVC Partner Leonan Luppi <leonan.luppi@gmail.com> - 2014-11-26 11:16 -0800
Re: MVC Partner Arne Vajhøj <arne@vajhoej.dk> - 2014-11-26 14:56 -0500
Re: MVC Partner Leonan Luppi <leonan.luppi@gmail.com> - 2014-11-26 14:54 -0800
Re: MVC Partner Arne Vajhøj <arne@vajhoej.dk> - 2014-11-26 18:07 -0500
Re: MVC Partner Martin Gregorie <martin@address-in-sig.invalid> - 2014-11-26 23:22 +0000
Re: MVC Partner lipska the kat <lipskathekat@example.com> - 2014-11-26 20:40 +0000
Re: MVC Partner Leonan Luppi <leonan.luppi@gmail.com> - 2014-11-26 15:01 -0800
Re: MVC Partner lipska the kat <lipskathekat@example.com> - 2014-11-27 08:56 +0000
csiph-web