OS X == Serious MVC

by Jon Davis 28. August 2008 22:39

Another quickie post, as I spend more time on my Mac Mini and tinker with Xcode, it's really starting to sink in that all this talk lately over the last few years about MVC (Model-View-Controller) is really heavily themed in the entire workflow and almost mandatory software architecture patterns in the OS X environment.

You've got Objective-C forcing you to declare your controllers and objects in a very loose fashion, managing everything with delegates and interfaces.

You have Interface Builder forcing you to build out your views with zero application logic but with hooks everywhere. (This unlike the code-behind model in Visual Studio for all views.)

Then on the data side you have Core Data, http://developer.apple.com/macosx/coredata.html, which really goes a long way to facilitating MVC relationships with the views in Interface Builder and with the general flow of the application.

In some ways, I'm reminded of the amount of effort Microsoft has gone through in Visual Studio to support data binding, except there's an incredibly beautiful simplicity yet sophistication about Apple's approach, where you don't just data bind to inject data into a view, as in dumping data, rather you provide the data models and the controllers to handle the delegates and the actions of the view. The implications of these differences can be staggering. And I know that Visual Studio/.NET facilitate delegation for these things (raising events), but the approach is just not as MVC-oriented. Visual Studio doesn't enforce MVC, Xcode/IB does. Visual Studio allows for MVC, that is, but Xcode/IB imposes it--or at least makes it really obvious that it's the best way to work in Xcode.

Which one is better? Neither; Visual Studio offers versatility whereas Xcode/IB offers elegance and predictability. I love them both.

MVC, TDD, ORM, WCF, OMG LOL

by Jon Davis 23. April 2008 22:05

Rob Conery, creator of the SubSonic ORM and scaffolding framework for ASP.NET, has been transparently publishing, in video format, what he understands TDD (Test Driven Development or Test Driven Design) in his presentations on the the reworking of the ASP.NET Storefront Starter Kit based on the ASP.NET MVC toolkit.

Surprisingly, the series has little to nothing to do with the storefront project. It's more of .. what I just said, Rob's transparent discovery process of TDD and keeping his process in check. That said, I thought it was a rarity among webcasts, something very much worth watching. Rob, who was recently brought into the Microsoft fold, has a way of making Microsoft look and feel human like the rest of us, using common sense and even humbly making adjustments of mindset and worldview according to the wise words of industry professionals as they give feedback. (This is something Microsoft has been getting good at lately, stepping out from their big Redmond city sized box and learning from a bit the rest of the planet, which is why I still root for them despite my relentless criticisms.)

Rob's discovery process is actually a very, very good opportunity for the rest of us to learn from. Rob came in prepared, he presented well, and the content and message are very good. While it was mostly review for me, TDD brings about such a different mindset to software that I feel like I need as many such "reviews" as I can find so that I can get it ingrained and rooted in my mental patterns.

That said, I am still greener than I want to be at ASP.NET MVC. This is just an issue of experiece; we're using it at work but I haven't been given the opportunity to implement, the other fellows have. Same with SubSonic.

I'm a big fan of SubSonic. I like its approach to ORM and its scaffolding.

Lately, though, I've been touching a bit with one of the software industry's best kept secrets among rediculously handy ORM solutions, and that is EntitySpaces. Mike Griffin's work with ORM tools has been around longer than Rob Conery's, and I've admired his work with both MyGeneration (a free, open source, and in many ways much better alternative to CodeSmith) and EntitySpaces for a couple years now. EntitySpaces is still pioneering in the ORM space, they've had a super-sweet ORM query object model that has been around and in production for much longer than SubSonic's recent "super-query" tweaks, which are still in beta. Makes us all wonder ...


Rob Conery

Mike Griffin
ROFLMAO.

Aside from the additional fact that ES works cleanly and happily on the Mac and on Linux with Mono, and aside from the additional fact that SubSonic is less about ORM and more about "building web sites that build themselves" (not everyone is building ASP.NET web sites, some people are writing software and just need a focused ORM solution), one thing I'm noticing recently about ES that makes it stand out from a lot of the other solutions out there is that an investment in ES on the server side is a really smooth and effortless transition to the client when you throw WCF in the mix, if all the client needs is the data models. The WCF proxy support in MyGen+ES makes client/server integration over WCF a snap. Part of this magic is also in Visual Studio, when you right-click References and add a Service Reference, the proxy objects are brought over from WSDL or a WSDL equivalent proxy definition, and you can begin coding on a seemingly rich object model on the client right away.

For me when I was tinkering with ES over WCF, being still green to ES, this brought TDD (actually integration testing) back into the picture. I found myself taking what I learned from Rob Conery on TDD and designing my services by executing tests--specifically, integration tests, which isn't pure TDD but I trusted WCF. I kind of had to; I needed to invoke the interfaces so that I could step through the debugger and introspect the objects and see what was going on under the covers as I was invoking code over the wire. This isn't pure TDD by principle but it is "test driven design" in the sense that I was finding myself writing tests that simulate real-world behavior in order to design how I want the code to function.

TDD, meanwhile, has made me think a lot about what I wrote half a year or so ago about Design Top-Down, Implement Bottom-Up. I didn't get much feedback on that post, but I, too, was being transparent with what I thought was a good idea. My word choice in that pattern seems foreign at first to TDD principles, if not contradictory, but the more I think about it the more I think it is actually very much complimentary.

  • In TDD, the tests simulate, by way of invocation, the top-down design and verify the bottom-up implementations, and
  • The implementations are kept in check by these simulations of top-down usage.

So I think TDD is really the glue, or a type of glue, that makes Top-Down-Bottom-Up work. I think the only big differences in perspective here are physical; TDD's perspective is a "I poke at you first, before you yelp", or forwards, perpective, Top-Down-Bottom-Up assumes that encapsulation is a layer, and the priority in the design process, over the implementation. (Or something.) It's all pretty much the same thing. And actually, while TDD validates the Top-Down-Bottom-Up process, TDBU validates TDD, too, because done right it uses TDD to prove out the stability and rock-solid implementation of an end product.

I'm feeling now like haacking (pun intended, for those who know) together a SuperText blog engine using a mish-mash of funzy geek stuff I want to keep pushing myself with including ES, ASP.NET MVC, TDD, REST, WCF, VistaDB, Silverlight, Javascript/AJAX, and Internet Explorer. Just kidding, I won't use IE ...

... not that I haven't built a complete blogging solution before.

MVC On The Client In Javascript

by Jon Davis 1. April 2008 04:30

I stumbled across this over the weekend.

http://javascriptmvc.com/

I was actually very surprised by how closely it resembles what we've been working on at the office. Ours uses a controller to manage and control events and event propogation, track "view objects" (we call 'em "client controls" for drag-and-drop support in Visual Web Developer) and manage AJAX calls. And we've spec'd out to use RESTful URIs to manage data model retrieval and callbacks, and these are cacheable using Google Gears, Flash storage, or *shrug* cookies.

Theirs has a few additional features, though, some of which I think we can glean from, like:

  • script librarian ("Include"), which we don't need but I think we could accomplish using something like JSLoader
  • a complete ActiveRecord-like modeling pattern
  • a complete ASP-like templating system that executes on the client
  • "everything is a plug-in" philosophy

I like what I see, although our own framework goes further as it is built with ASP.NET, ASP.NET MVC, Visual Studio, and Expression Web all in mind. With ours, we enable our web designer, who is not an engineer, to create a complete, non-Flash RIA web pages without coding. Using Expression Web or Visual Web Developer, he can click on one of our controls in the Toolbox, drag it out to the page, absolutely position it, stylize it, give it a data source URI, and have it subscribe to other controls' events (think Flash video player, responding to the events of media playback controls). The entire multi-page web site will support executing in the rich execution environment of a single-page RIA application with a seamless user experience. And since the framework is not done in Flash (although Flash "client controls" are supported), it will support continuous extensions using the wonderfully universal languages of HTML and Javascript, both at design-time (creating new controls, customizing existing controls) and at runtime (RESTful fetches of web content, dynamic execution of JSON models, etc).

In some ways, ours is looking like http://www.wavemaker.com/, except that WaveMaker is based on Java and dojo, and the designer experience is in-page (which is way too much support overhead--why reinvent the designer when Visual Studio / Expression Web can do the job on its own?).

But I'd certainly recommend Javascript MVC (JavascriptMVC.com) as a skeleton foundation framework for someone to roll their own framework. We were thinking about open-sourcing our client bits once we are done with our prototype, but I think Javascript MVC comes close enough that it would do just as well to recommend that one instead. Mind you, I have never used it, I'm only suggesting it based on what I'm seeing at their web site.

kick it on DotNetKicks.com

JSON and XML View Engines in ASP.NET MVC

by Jon Davis 28. March 2008 18:28

I posted earlier that we're working on a client-side MVC framwork that compliments the ASP.NET MVC framework. It's actually not formally MVC on the client, but it comes close. The view side is entirely controller-driven, even the event model. The "model" side of it is the ASP.NET server itself. So the server spits out both templated markup for the client-side controls, as well as the AJAX'd data models. These data models are models to the client but they are views to the server, or at least that's the way we're designing it.

So my co-worker posted his solution to XML and JSON callbacks, since ASMX is not MVC-friendly. It's a JSON view engine for MVC.

"I recently saw Scott Guthrie at a local .NET User Group event, and he mentioned that the ASP.NET MVC Framework was completely "pluggable", and you could easily replace the built-in View Engine.  So, I immediately searched for examples, found one ... tossed it out and whipped together a really quick and simple 'JsonViewEngine' class. Here's the code ..."

http://www.fragmentedcode.com/2008/03/27/jsonviewengine-for-aspnet-mvc-framework/

kick it on DotNetKicks.com

Currently rated 1.5 by 21 people

  • Currently 1.47619/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

Software Development | Web Development

MVC Now A Microsoft Thing

by Jon Davis 7. October 2007 14:55

A week or so ago (??) I learned at Haacked.com, with Phil Haack's news that he was joining Microsoft, that Microsoft has been paying attention to the recent successes people have been reporting with MVC/MVP with ASP.NET. I'm still scratching my head wondering what how on earth you can string these two models together, but I'm glad to learn that Microsoft has been paying attention to what has been going on at the Castle Project with MonoRail, et al, among other things.

What had me most concerned about MVC/MVP was that, on the web, everything starts with that @#$% URL which infers a reference to some applicaton state in some point in time, or else a specific pointer to some data, and with ASP.NET a URL generally maps to a Web Form, with some predetermined template with some tricks up its sleeve to allow for things to show and hide and move around based on postbacks and/or AJAX calls. In other words, classically, on the web, the view is predetermined, and it already controls everything, rendering MVC/MVP a concept limited to the lifetime of the rendering of specific controls that happen to be on a template (an ASPX page).

It looks, though, like HTTP handlers are being put into place so that URLs don't map to a Web Form but rather an action to perform so that the MVC controller controls the output rather than some file-mapped template.

While I haven't peeked enough into MonoRail to know whether it does something similar, I must say that I now officially don't know what I'm talking about when I pooh pooh MVC for the web. I'm really looking very much forward to seeing what Microsoft ends up with. Jeffrey Palermo's blog indicates that this new initiative has these goals: 

  • Natively support TDD model for controllers.
  • Provide ASPX (without viewstate or postbacks) as a view engine
  • Provide a hook for other view engines from MonoRail, etc.
  • Support IoC containers for controller creation and DI on the controllers
  • Provide complete control over URLs and navigation
  • Be pluggable throughout
  • Separation of concerns
  • Integrate nicely within ASP.NET
  • Support static as well as dynamic languages

I'm impressed. So much of this is so .. non-Microsoft-like .., it's like they were working in a box for so long. I had grown so accustomed to Web Forms with all its constraints, now I have to re-learn everything all over again. I hope there will be a special certification track for this ...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Web Development

Paying Attention to MVP, Presenter First, Castle, MonoRail, Igloo, et al

by Jon Davis 23. July 2007 00:34

In order to be an excellent software developer, one must be able to communicate and interoperate with others' software excellently. Lately, deafening chatter has been overwhelming the software communities about MVC, MVP, Presenter First, Castle, Spring, MonoRail, and so on. To my shame, I was so focused for so long on embracing OOP and the C# language and the .NET Framework and general Microsoft APIs and technologies that I overlooked these essential patterns, practices, and tools used by software professionals the world over. If I had only swallowed MVC and XP years ago, I would not be struggling so badly to play catch-up.

So far I haven't actually written a single line of code yet based on these patterns. I have looked over the shoulder of our team architect who was trying to get into it, and in so doing got a snapshot of what MVP code "looks like" (lots of interfaces and event handlers). After listening to Atomic Object's ArcCast podcast interviews, I've read Atomic Object's PDF presentation on Presenter First. I've realized the value of mock objects, and I've heard about Rhino Mocks. I've learned about Inversion of Control and dependency injection, and implementation tools for these in Spring.Net and in the Castle Project. I've been looking around for how MVP is supposed to work correctly in a web-based environment, where view state is already URI-controlled (unlike a GUI app, where the controller / presenter can push a view change more immediately). I've come across MonoRail and Igloo, but except for coding shortcuts I still don't see a solution to this problem.

But I haven't actually started using any of them.

I still haven't figured out whether these processes, patterns, and tools are directly related to those of Agile and XP. I do know that all of these are directly tied to unit testing and testable software--a critical process of software development I have tended to abhor, to my awful, disgusting shame.

I have an "Agile Princples, Patterns, and Practices in C#" book sitting on my lap, and I'm trying to figure out whether I should delve into this book, or if I should start tinkering with Castle to lead to MonoRails, or tinker with NUnit, or with NMock, or Rhino Mocks, or what. Maybe it doesn't matter, as long as I delve into one of these and progress myself.

I am certain, however, that by the end of this year, I had better know and be practicing all of the essentials of the above, or I will not feel confident in calling myself "excellent".

Update: After reading the forewords and the prefaces of Agile Principles, Patterns, and Practices in C#, I am pursuaded, this is the path I should take right now. This should be a book I should try to read end-to-end. While the subject is not related to MVC/MVP/PF, etc., I'm pursuaded that XP / Agile programming is a skill that is mandatory to understand as a software professional. It is about working with people, test-driven development, changeable software, and core values. MVP is just one technique for process and pattern, but it does not fit all. XP/Agile knowledge, however, might actually be one-size-fits-all. We'll see.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , , , , , , ,

Software Development


 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
 
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of jondavis.net have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 


Tag cloud

Calendar

<<  November 2018  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

View posts in large calendar