Showing posts with label LightSwitch. Show all posts
Showing posts with label LightSwitch. Show all posts

Tuesday, 2 November 2010

Turn off that LightSwitch, and Let's Get Naked!

So, no sooner had I blogged about VS Lightswitch (I mean literally the next morning) I discover that there is a whole architectural pattern out there that tackles the problem that I have been considering developing a framework for  - Naked Objects. The shame of my arrogance (mixed with some naivety I concede) to think that I may be the first out there to strive for, well not so much a Silver Bullet, but well, just something better for such architectural commonality.

Richard Pawson coined the term Naked Objects when he had the vision of exposing domain objects to the UI (OOUI).  Naked Objects was the result of his Ph.D. thesis, written a few years ago when I was still trying to get to grips with proper OOAD/P and .NET 1.1.

The same curiousity that got me intrigued by VS LightSwitch had me interested in Naked Objects, that is a sound belief in DDD; the presentation, data (service and whatever other) layers are simply scaffolding for the domain. Get the domain correct, your app from a business representation perspective will be correct. As a software engineer that is the most difficult thing to get correct, and is the thing that is most likely to make or break the success of your project/app.
 
UI Designers of course argue different, arguing that a good UI is critical and fundamental to a successful application (it is this stick that Larry Constantine beat the Naked Objects concept with some time back.
I am not entirely unsympathetic to their stance and I certainly think a good UI helps, but without a sound domain model a fancy UI is worthless.  The same cannot be argued for the reverse (I know since I've developed a few such apps, a good few of which were deemed a success and are still in operation today).

Interestingly, Pawson has recounted how Trygve Reenskaug himself had stated that the Naked Objects pattern was the ultimate end game to his Model-View-Controller pattern.  This certainly gives weight and validity to Naked Objects as an architectural pattern (in the West of Scotland we call this "hawners").

Of course Pawson has went on to develop his own framework for his Naked Objects pattern, namely Naked Objects and more specifically Naked Objects MVC for .NET, utilising the ASP.NET MVC 2.0 technology.  The Naked Objects MVC framework is interesting from a number of points of view:
  • The Naked Objects framework is solely centered on domain objects as indeed Pawson claims. In other words, there is no code needed from you the developer, for the presentation layer or the data layer, leaving you to concentrate on getting your domain model correct.  If Naked Objects and VS LightSwitch were ever in direct competition, in my opinion, Naked Objects would win for this reason alone. Even although the Entity Framework (EF) Code-First CTP was released before VS LightSwitch beta, VS LightSwitch is still driven from the data model, suggesting that the intended user demographic of VS LightSwitch is pre-dominently people with no proper OO experience.  Naked Objects on the other hand is clearly a product for OO developers.
  • The domain objects are also true POCOs, meaning that you can port your domain model to another framework or to your own custom framework/application at a later date if you decide the output of Naked Objects is not to your liking without any rework to your domain.
  • The Data Layer of Naked Objects is build on the Code-First component of EF, which doesn't require any data modelling or data access code, you hook up your domain model and away you go.
  • The Presentation Layer uses reflection to obtain not just the state, but also the behaviour of your domain objects in order to display the functionality on offer in your UI.  This means that there is only actually a few generic views and controllers needed in the framework in order to render this behaviour and state at run time.
  • The Naked Objects MVC product also allows you to customise your views, meaning the end result doesn't have to be a set of similar looking views obviously generated from boiler plates. Indeed, you can add on your own views to extend and customise your UI further if necessary.  (My guess is that this is Pawson's reply to Constantine's criticism's of generated, standard, no-design UIs.)
However, there are a couple of concerns I have about Naked Objects MVC at first glance:
  • The UI uses terminology such as "Create Instance", which is great for technical people, but it means business users need to learn a new set of terminology to use your application.  To me, this seems to contradict the Ubiquitous Language so keenly advocated by DDD.
  • The use of reflection for all domain objects in order to build dynamic pages at runtime does concern me a little with regard to performance. Depending on the complexity of your objects and/or intended UI page there is a possibility that you may end up with a performance problem in your web application. (I am willing to be set on this one if I have it wrong.)
  • The data layer is built on a CTP of EF.  Admittedly, CTP4 does seem to have made major advances for the reputation of the EF as an ORM, but I know my boss isn't interested in running production applications against CTPs any time soon.
  • Pawson also claims that you have flexibility in your application by allowing you to customise your Views not just by stylesheets, but by use of a raft of very helpful HTML helper classes as part of the Naked Objects framework.  He also makes a case for ultimate flexibility as the framework allows you to use your own custom Views and with every likelihood your own Controllers also.  Personally, I'm not convinced by this as a selling point of Naked Objects MVC because if you take away the Views and Controllers you have cranked yourself, for all intents and purposes you are left with the domain model you also created and the EF CTP.
As a final observation Pawson claims that Naked Objects works well for sovereign applications but it does not lend itself very well to transient applications.  Personally, I don't think that application posture is as applicable today as it once was; today's end users don't just use software as a job tool, but as a medium that is part of their day-to-day social interaction. As a result, their expectations are higher and sub-consciously or otherwise, the expectation (no matter if they use it 7 hours per day or just in passing) is not just on how it looks, or what functionality it offers but how it actually behaves (usability).  If the UI generated by the framework is rigid in structure and not intuitive to users, this could limit the adoption of Naked Objects frameworks such as Naked Objects MVC.

My previous observation of having a sound domain model and not necessarily having a good UI should be qualified by the times in which this software was written.Going back to touch on Constantine's point about the UI being vital; end users these days are not expecting a good UI as apposed to a good functionally sound domain implementation, or even vice versa - they want both.

Saturday, 30 October 2010

Enlighted? Certainly Not At The Flick Of A Switch.

Recently I watched the VSLive presentation on Microsoft's new development technology - Visual Studio LightSwitch - and I was more than a little intrigued (and admittedly a little nervous) at what I was in store for.

Before getting down to technical detail I wanted to mention Microsoft sessions in general.  As I expected from Microsoft, the presentation and the demoes were slick and polished, but I continually can't help but feel I'm being presented to by a couple of marketing guys who have been schooled by techies. I far more enjoy being presented to by an academic than being sold to by a salesman.  Maybe its just me?


OK, so on to LightSwitch.  The main questions I had was: What is it?  and What problem is it trying to solve?

As I say I was intrigued by LightSwitch as I had read some material explaining that LightSwitch was the solution for straightforward CRUD applications (or the CRUD elements of applications at least), that LightSwitch would auto-generate CRUD code.  I have to admit this initially had me excited .
You see, most of the bespoke applications I'm involved in tend to consist of 2 functional aspects:
  1.  the implementation of the specific business domain (i.e. the part of the application specific to support the business process) 
  2. and the maintenance of the supporting data for that business process - the CRUD element.  
Designing and implementing the business domain is the interesting (and dare I say it, creative) part of development process.  The CRUD element tends to be the necessary evil for many applications as it tends to be unimaginative, unchallenging and repetitive. As a developer, anything repetitive I try to automate or design my way round (I usually end up trying to let inheritance and the O-R Mapper take the strain).

Now here was Microsoft apparently releasing a tool to automate this for me.  Sounds good.  However, I still had reservations, namely
  1. Is it easy to integrate the specific, interesting (and sometimes complex) business domain code of your application with the CRUD code auto-generated by LightSwitch?
  2. Integrating and re-using objects is one thing, but is it possible that you can scale such drag & drop solutions?  And what type of architecture am I going to end up with?
Taking these one at a time, Microsoft claim that you can indeed integrate your custom, complex business code easily by generating your  CRUD code, and then simply digging into the C# or VB code generated by it.  Again, sounds good doesn't it? Well, on reflection I'm not so sure as it means you face the same problems that many other code generators create (perhaps T4 templates aside, but thats another blogpost already in the pipeline) in that you have no control over what that code looks like, meaning that your objects may end up in a shape that you don't want, and don't allow you to easily extend.  Then there's the issue of continual refactoring of code.  What happens with LightSwitch when you generate you CRUD code complete with your nice new screens, extend the code by adding some custom business logic, and then discover that you need to regenerate your whole CRUD code again via LightSwitch?  What happens to that expertly written custom business logic that you are so proud of?  Do you have to re-insert it?  Will it still fit?

Moving on to the non-functional questions over flexibility and scalability, again Microsoft claim that LightSwitch allows you to deploy your end solution as a Silverlight app, which definitley gives it reasonable flexibility over the target platform.  The demo also covers how to scale this from being a simple single user executable during development to being a multi-user deployed web app.  Again, the demo makes it look so simple, but I think that is mostly down to the simple demo. In reality, most applications tend to be more complex than that.

All of this aside, the one question that remains unanswered is: who exactly is this product aimed at? Who is going to use it?

The LightSwitch demo host presented a strong case for allowing business users to build their own apps organically, and only when the app graduates from being a single user or department wide app to an enterprise app should us developers get involved.  Traditionally, this has been done using Microsoft Access in its various incarnations, and I've experienced such situations, and I can understand the argument that says the best applications "grow" from this type of root.
So, is this an Access replacement?  Well no, because its a Visual Studio component and business users don't usually have Visual Studio on their standard desktop, but they do have Office, which is why Access had/has such a high adoption rate.
So, then its a developer tool. And here is where that nervous feeling comes from....are Microsoft suggesting .NET developers hand over control of the design and architecture of their enterprise scale software to a code generator?  (Not only that, a code generator that seems to focus on state and not necessarily behaviour at that?!)  Just when we are finally making some headway with .NET being taken as a serious development platform, some innovation, some serious thoughtleaders using the .NET platform and out there being heard, and Microsoft comes back advertising a new way of pointing and clicking your way through your professional career.  I wonder if its too late for me to start learning something like Ruby On Rails?

(thanks to restoreus .org for use of the image)