Yes it is true – I am not going to lie about it – I hate ASP.NET… But still it has its charms – the ability to just work on every client is actually worth something. But ASP.NET solutions are really just a million pieces of crap flying in close formation so that it resembles an application…
So me being this strongly-typed person that I am, how can I still deliver ASP.NET stuff without puking all over myself from disgust?
Well I guess it is not possible to completely NOT use the ASP.NET framework – but at least I want to use it as little as possible and certainly not for very straightforward stuff like showing up business objects in a standard UI with comboboxes, edit and grids.
If I can catch what I want in a model in like 5 minutes I do not want to spend more than 5 minutes to get it up and running. If I am satisfied I can spend more time on tuning it to “perfection” (hey its ASP.NET we talk about) but the basic stuff of fetching and editing and applying and persisting – 5 minutes tops. If I can get these things going in 5 minutes – fine – otherwise I want to ship it away to someone else for production. That someone else probably hate ASP.NET as well – but they will do it for the money.
Ok – Maybe MVC is the solution – NOT! MVC breaks my fingers from typing and I am still left with the disgusting html wiring of the UI – the very thing that makes me puke and it simply takes for ever.
So what am I saying here? What is my recommendation?
Go declarative – do things only once – use a framework from the future
Using Enterprise Core Objects – the model driven framework that actually works – a.k.a ECO I create this model:
Notice the “/” on Order.TotalCost and on OrderItem.CostForRow – these are derived attributes. Defined in Object constraint language (OCL – a rather boring but cool OMG standard) as such:
Ok that took me like 5 minutes – better hurry up. I create a viewmodel:
Sure looks like a lot of typing but since the editor is Model driven I can more or less just pick and choose:
Ok… Maybe I have spent another 5 minutes on this…
That means I would have 10 minutes to get it up and running in ASP.NET.
Drag on a ViewModelASPNET control on a WebForm and set its viewModelName to the name of the viewmodel from above:
Add some styling and background images and hit F5:
Ah, it still looks like shit but it is working – I can now spend days on getting it to look the way I want with css. The thing is that:
The ComboBoxes shows up the correct rows
Changing a ComboBox updates the single links in the correct object
The Totalcost is updated and displayed correctly
The buttons execute the domain logic as defined.
I can select, delete or edit Grid rows.
Data is persisted on the server.
The ViewModel has ReadOnly and VisibleExpressions that controls all the webcontrols
Declarative is nice! I still hate ASP.NET though…