Ian Cooper's profileStaccato SignalsBlogLists Tools Help

Blog


    November 14

    What is the MVC noise all about, anyway? Pt 3

    Forms and Leaky Abstractions

     

    The model on Windows for rich-client programming is event-driven. Your window waits for a message, which is dispatched to a handler method it has registered with the OS (the Window Procedure). Frameworks hide this complexity here: in Windows Forms you register a delegate to listen an event and the underlying framework calls that delegate for you when it receives the event you were listening for.

     

    Web applications work by a request-response paradigm. The browser sends a message to the server, which spins up your application in response to the request. Your application processes the request and responds with a message that tells the browser what content to display now.

     

    WebForms’ server side controls brought the familiar world of event-driven programming to the web, by the trick of parsing the request to determine what action had caused the request and then raising an appropriate event on the target page.

     

    Windows applications are stateful. While we react to events, the state of the application is preserved across those events, for the lifetime of the application.

     

    By contrast web applications are stateless. The server spins up a new instance of our application to service each request.

     

    As well as giving the illusion of event-driven programming, WebForms’ also created an illusion of state-fullness. The state of our page was preserved between requests using hidden fields embedded within the HTML and restored when the request was parsed so that our page felt as though it was stateful.

     

    This illusion of event-driven, stateful behavior provided a familiar model for forms developers to use when tackling web projects and enabled programmers with little web experience to transition to web development.

     

    The question is whether this illusion hinders as much as it helps. ViewState, the mechanism used to provide the stateful illusion has resulted in heavy pages as developers fail to grasp how it works ‘under the hood’ and make mistakes in its usage; developers no longer understand what HTML elements like input controls and forms are for; mixing dynamic HTML client-side behavior i.e. Ajax with server-side WebForms controls becomes messy rapidly; the postback model for raising events results in pages that flicker and are unresponsive; the loading of control state on requests encourages developers to think they are interacting with controls, not that they are rendering HTML for display by the browser; the page lifecycle is sufficiently torturous that is has become a favorite interview question.

     

    WebForms have become a leaky abstraction, hiding too much so that the underlying protocols have been obscured and many developers cannot understand how to resolve problems when they hit them.

     

    So the divorce of frameworks like MonoRail from the server-side control model is deliberate. While WebForms developers may look on hesitantly, the truth is that a model that reflects how the web works is in many ways easier to understand.

     

    People who encounter MVC frameworks for the first time often stumble upon how useful they seem to be to RESTian services. The reality, of course, is that ,REST, Monorail et al all seem to have an affinity, because they expose how the web works, instead of obscuring it under a borrowed, and ill-fitting paradigm.

     

    Testing


    One facet of good design is software that is amenable to change. When we think about the cost of software we need to consider the total cost of ownership, not just the cost to live. Sadly that often gets forgotten, because people don’t add the two costs together when thinking about software, leading to short-term approaches in build, in an effort to reduce cost, even if the overall cost then increases.

    When we talk about cost of ownership, the big cost is how amenable is the software to change. As the business the software serves changes, so must the software. While I have been told many times, 'we do not need to worry about good design, we will never need to change the software' I have never seen that to be true. In fact, change usually happens long before the first release.

     It turns out that Test Driven Development encourages the adoption of MVC frameworks because UIs tend to require hosting in a context (browser, windows message pump, and console) that vanilla testing frameworks can't simulate. It's much easier with TDD to use a Test Double and replace the view with something that you can test.

     

    Of course you might want to replace the model too if it talks to the DB, but that's a separate story. ‘

     

    It's worth repeating an earlier blog here. There is a danger that some xUnit testing frameworks try too hard to solve the problem of hard to test code. They introduce the risk that you are no longer encouraged by those ‘hard to test’ areas to adopt best practices. Testing frameworks need to be smart enough, but no smarter.

     

    So, as other posters have mentioned the addition of an MVC framework enables people who want to work in a Test-First way. However it’s important to recognize that one facet of putting your code under test, is the emergence of good design, so designing for testability is also good design.

    Just-enough architecture?

     

    I do have some sympathy with people who resist ideas like ubiquitous language, do not want to think about entities and value types, repositories and aggregates when the project is a simple CRUD website with limited behavior. Those people often want to know what is 'just-enough' design, what is the minimum they could do to improve the maintainability of their software. I would say for those simple web sites MVC, coupled with a pattern like Active Record to shift the data around, is that: just-enough. I do not want you to discourage you from an understanding of Domain Driven Design or Responsibility-Driven Design, but if you are building a simple CRUD website with limited behaviors in the domain, then MVC-Active Record may well be the way to go. Certainly the popularity of Ruby on Rails would seem to attest that people can ‘get stuff done’ with that approach.
     

    Comments (130)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    June 26
    No namewrote:
    http://www.fudousanget.com/0saxtuporo.html
    http://www.fudousanget.com/0yokohama.html
    http://www.fudousanget.com/0tiba.html
    http://www.fudousanget.com/0kurasiki.html 
    http://www.fudousanget.com/0aomori.html
    http://www.fudousanget.com/0hokkaidou.html
    http://www.fudousanget.com/0akita.html
    http://www.fudousanget.com/0yamagata.html
    http://www.fudousanget.com/0totigi.html
    http://www.fudousanget.com/0ibaragi.html
    http://www.fudousanget.com/0niigata.html
    http://www.fudousanget.com/0minato.html 
    http://www.fudousanget.com/0sendai.html 
    http://www.fudousanget.com/0oosaka.html 
    http://www.fudousanget.com/0nagoya.html 
    http://www.fudousanget.com/0fukuoka1.html 
    http://www.fudousanget.com/0kyouto.html
    http://www.fudousanget.com/0saitama.html 
    http://www.fudousanget.com/0sizuoka.html 
    http://www.fudousanget.com/0kawasaki.html 
    http://www.fudousanget.com/0kagosima.html 
    http://www.fudousanget.com/0kumamoto.html
    http://www.fudousanget.com/0kagawa.html
    http://www.fudousanget.com/0saga.html
    http://www.fudousanget.com/0koube.html 
    http://www.fudousanget.com/0hamamatu.html 
    http://www.fudousanget.com/0sakai.html 
    http://www.fudousanget.com/0himeji.html
    http://www.fudousanget.com/corp01.html
    http://www.fudousanget.com/kaitoriget/ 
    http://www.daikenfudousan.com/sateiget/
    http://www.daikenfudousan.com/kaitorigetb/
    http://www.fudousanget.com/0nagano.html
    http://www.fudousanget.com/0ishikawa.html
    http://www.fudousanget.com/0fukui.html
    http://www.fudousanget.com/0aichi.html
    http://www.fudousanget.com/0gifu.html
    http://www.fudousanget.com/0mie.html
    http://www.fudousanget.com/0hyougo.html
    http://www.fudousanget.com/0shiga.html
    http://www.fudousanget.com/0nara.html
    http://www.fudousanget.com/0tottori.html
    http://www.fudousanget.com/0shimane.html
    http://www.fudousanget.com/0yamaguchi.html
    http://www.fudousanget.com/0tokushima.html
    http://www.fudousanget.com/0kouchi.html
    http://www.fudousanget.com/0nagasaki.html
    http://www.fudousanget.com/0ooita.html
    http://www.fudousanget.com/0okinawa.html
    http://www.fudousanget.com/kaitoriget/
    http://www.daikenfudousan.com/sateiget/ 
    http://www.fudousanget.com/0iwate.html 
    http://www.fudousanget.com/0fukushima.html
    http://www.fudousanget.com/kaitorigetb/
    http://www.fudousanget.com/0toyama.html
    http://www.fudousanget.com/0miyazaki.html
    http://www.fudousanget.com/0miyagi.html
    http://www.fudousanget.com/0yamanashi.html 
    http://www.fudousanget.com/0wakayama.html
    http://www.fudousanget.com/0sagamihara.html
    http://www.fudousanget.com/0akasi.html 
    http://www.fudousanget.com/0kitakyusyu.html
    http://www.fudousanget.com/0ehime.html
    http://www.fudousanget.com/kaitorigetb/
    http://www.houjy.co.jp/
    June 18
    June 18
    June 18
    May 27
    May 18
    No namewrote:
    http://www.00113.net/
    http://www.akonan.com/
    http://www.alcyemen.com/
    http://www.angel-santos.com/
    http://www.anuranan.com/
    http://www.campuslackers.com/
    http://www.cebunatcon2007.com/
    http://www.christmasbookshop.com/
    http://www.cjtz.net/
    http://www.dawnherman.com/
    http://www.djscott.biz/
    http://www.dostunubul.com/
    http://www.enkamobilya.com/
    http://www.equentitysucks.com/
    http://www.etalonweb.com/
    http://www.frontallobefilms.com/
    http://www.gaiaecology.net/
    http://www.gorkemturizm.com/
    http://www.gradina-petrol.com/
    http://www.heavyweightchampionsound.com/
    http://www.hfdpdesign.com/
    http://www.hosting4fun.com/
    http://www.hotel-le-flepen.com/
    http://www.inseadme.com/
    http://www.jingdapower.com/
    http://www.jumilero.net/
    http://www.kirkwoodscrystalsandcrafts.com/
    http://www.mcrguate.com/
    http://www.modelscans.net/
    http://www.mokafolio.com/
    http://www.morningdr.com/
    http://www.msc4.com/
    http://www.oshoinformationcenter.com/
    http://www.palmdat.com/
    http://www.proyeccionpatagonica.com/
    http://www.puntodequiebra.com/
    http://www.rbcf.biz/
    http://www.republikadzieci.com/
    http://www.senmons.com/
    http://www.senmons.net/
    http://www.standplaats.net/
    http://www.stshort.com/
    http://www.swj8.com/
    http://www.thunthanalak.com/
    http://www.tiptopmoda.com/
    http://www.traktite.com/
    http://www.virtualmonkeys.net/
    http://www.crosscountrycreations.com/
    http://www.braingymasia.com/
    http://www.appro-diffusion.com/
    http://www.bulgariandiary.com/
    http://www.micro-webserver.com/
    http://www.crimepundit.com/
    http://www.dfpk.net/
    http://www.genealogical-exchange.com/
    http://www.hd17.net/
    http://www.hn99.net/
    http://www.icimco.com/
    http://www.lamatlock.com/
    http://www.zghl.net/
    http://www.b0002.com/
    http://www.aurevoirspasalon.com/
    http://www.kalomusic.com/
    http://www.pxarts.com/
    http://www.b0005.com/
    http://www.b0008.com/
    May 18
    May 18
    May 18
    May 18
    No namewrote:
    <a href="http://www.masswowgold.com/Hakkar-Alliance.html">Hakkar-Alliance wow gold </a>
    <a href="http://www.masswowgold.com/Hakkar-Horde.html">Hakkar-Horde wow gold </a>
    <a href="http://www.masswowgold.com/Haomarush-Alliance.html">Haomarush-Alliance wow gold </a>
    <a href="http://www.masswowgold.com/Haomarush-Horde.html">Haomarush-Horde wow gold </a>
    <a href="http://www.masswowgold.com/Hellscream-Alliance.html">Hellscream-Alliance wow gold </a>
    <a href="http://www.masswowgold.com/Hellscream-Horde.html">Hellscream-Horde wow gold </a>
    <a href="http://www.masswowgold.com/Hydraxis-Alliance.html">Hydraxis-Alliance wow gold </a>
    <a href="http://www.masswowgold.com/Hydraxis-Horde.html">Hydraxis-Horde wow gold </a>
    <a href="http://www.masswowgold.com/Hyjal-Alliance.html">Hyjal-Alliance wow gold </a>
    <a href="http://www.masswowgold.com/Hyjal-Horde.html">Hyjal-Horde wow gold </a>
    <a href="http://www.masswowgold.com/Icecrown-Alliance.html">Icecrown-Alliance wow gold </a>
    <a href="http://www.masswowgold.com/Icecrown-Horde.html">Icecrown-Horde wow gold </a>
    May 18
    May 7
    May 7
    No namewrote:
    WoW shares many <a href="http://www.game4power.com/">wow gold</a> of its features with previously launched games. Essentially, you battle with <a href="http://www.game4power.com/buy-gold/"> wow gold cheap </a> monsters and traverse the countryside, by yourself or as a<a href="http://www.bestwarhammer.com/">buy warhammer gold</a>team, find challenging tasks, and go on to higher <a href="http://www.aocsale.com/">aoc gold</a> levels as you gain skill and experience. In the course of your journey, you will be gaining new powers that are increased as your skill rating goes up. All the same, in terms of its features and quality, that is a ture stroy for this.WoW is far ahead of all other games of the genre the <A href="http://www.game4power.com/buy-gold/">cheapest wow gold</A> game undoubtedly is in a league of its own and <a href="http://www.game4power.com/buy-gold/">buy cheap wow gold</a> playing it is another experience altogether.

    Even though WoW is a <a href="http://www.wowgoldone.com/"> Cheap Wow Gold </a> rather complicated game, the controls and interface are done in <a href="http://www.vipwarhammergold.com/">warhammer gold</a> such a way that you don't feel the complexity. A good feature of the game is that it <A href="http://www.itemchannel.com/?op=powerleveling">wow power leveling</A> does not put off people with lengthy manuals. The instructions <a href="http://www.game4power.com/">game4power.com</a> cannot be simpler and the pop up tips can help you start playing the game immediately. If on the other hand, you need a detailed manual, the instructions are there for you to <a href="http://www.itemchannel.com/">World Of Warcraft Gold </a> access. Buy wow gold in this site,good for you.

    <a href="http://www.game4power.com/"><>buy wow gold<></a>
    <a href="http://www.game4power.com/">buy gold wow</a>
    <a href="http://www.wowgoldone.com/">cheapest wow gold </a>.
    Apr. 15
    Apr. 1
    Apr. 1
    Apr. 1
    Apr. 1
    Mar. 26
    No namewrote:
    It was not long <a href="http://www.gold4power.com/">cheap wow gold</a>before some one knocked at<a href="http://www.gold4power.com/">wow gold cheap </a> <a href="http://www.gold4power.com/">wow gold for sale</a>the house-door and called, open the door, dear children, your mother is here, and has brought something back with her for each of you. But the little <a href="http://www.wowpoweron.net">wowpoweron</a>kids knew that it was the wolf, by the rough voice. We will <a href="http://www.gold4power.org/">gold4power</a> not open the door, cried they, you are not our mother. She has a soft, pleasant voice, but your voice is rough, you are the wolf.

    Then the wolf went <a href="http://www.itemchannel.com">World Of Warcraft Gold</a>away to a shopkeeper and bought himself a great <a href="http://www.gold4power.com/">cheapest wow gold</a>lump of chalk, ate this and made <a href="http://www.mmogap.org.">mmogap</a> his voice soft with it. The he came back, knocked at the door of the house, and <a href="http://www.igsky.net">igsky </a>called, open the door, dear children, your mother is here and <a href="http://www.gold4power.com">Cheapest Wow Gold</a>has brought something back with her for each of you.

    Mar. 24

    Trackbacks

    The trackback URL for this entry is:
    http://iancooper.spaces.live.com/blog/cns!844BD2811F9ABE9C!533.trak
    Weblogs that reference this entry
    • None