C# on the IPhone

28 June, 2009 (06:06) | .NET Tools | By: twagner

This morning I stumbled across some discussion of using C# to build IPhone apps. You may know already that ordinarily IPhone apps are built using Apple’s Objective-C , which is pretty ancient and lacks some useful features like automatic memory management for example. Objective C came out as part of NextStep which was a company that Steve Jobs had for a little while during the years when John Scully was at the helm of Apple. This was back in the late 80’s early 90’s I think.  So basically the code used to write IPhone apps is about 15 -20 years old and at this point its only a version 2 product. Seems odd. From what I have read, dealing with Objective-C is no picnic. Imagine my surprise when I saw this note on the Mono site.I followed the links and found Unity - what looks to be a very capable game design IDE that uses C# and compiles to Apple Objective-C. Thats pretty neat. I suspect it probably has some early version hiccups but in time with proper care and  feeding I wonder if this IDE wouldnt grow into something usable for general IPhone dev.

ASP.NET MVC Impressions after 1 week

5 June, 2009 (08:45) | Uncategorized | By: twagner

  • I like it, but boy it requires a shift in thinking and has a learning curve since you need to practically relearn how to do everything on the web page. No more controls.
  • It suffers a little bit from RoR envy.
  • It will probably take some time before the best ways to do certain things in this framework will be discovered. Looks like everybody is trying new and different things.
  • Because it does everything different than webforms it takes me longer to create something – that will change over time
  • It drives home the point just how different web forms are from “normal” html based development because it lets you do things with CSS that you dont see in reg ASP.NET sites, because regular .net controls are not too open standards compliant.
  • The separation of concerns into model / view and controller code is refreshing
  • There will be a lot of open source feedback which will influence the next versions of MS MVC as well as offer substitute ways of doing things. Just like the RoR community, a MVC developer will be faced with a plethora of choices. I dont know how  I feel about that because it can lead to religious arguments — my Spark View Engine is better than you built in View Engine….use FubuMVC as opposed to MS MVC etc etc etc. Unless there is a clear frontrunner for a given aspect I am worried that there will be a lot of confusion.

Overall I still wonder how much need there will be for MVC in the long run as opposed to Silverlight or even something like Adobe Flex. In other words will the web move more toward Rich Apps or will it move more toward jazzed up HTML apps. Fact is there are things you can do in MVC that are not possible to build quite as nicely and easily in regular ASP.NET. For example there is a plethora of CSS tools out there and freely available plugins and whatnot for jQuery that may work easier in MVC pages.

No RenderPartial from a different folder

3 June, 2009 (10:17) | ASP.NET MVC | By: twagner

Maybe this is not supposed to work out of the box in the manner I thought…..

In order to render something similar to a user control in ASP.NET MVC one creates a partial view – which ends up with the extension of ascx.  This partial view can be embedded into and rendered through other pages (views) . That’s normally done via the RenderPartial method. It all works very well until you need to render a partial view that sits in another folder.Then for whatever reason the system starts to complain bitterly. Yes I know … your supposed to put it into the Shared folder. But somehow that doesnt sit well with my sense of organization. Why have one folder that has a bunch of partials from all over the place.  ( I have not tried adding sub folders to /Shared. Maybe thats an idea as well)

Seems to me that I should be able to create a partial view that has a table of data and then embed this partial view in a variety of other views- wherever I might need this list. And the places where I might need this list could be scattered all over the Views structure.

I am not the only one who ran into issues like this.  Here is a post by a fellow who had similar issues with entire pages.

An internet search turned up the following idea which may possibly do the job:

protected void Application_Start()
{
	var engine = (WebFormViewEngine) ViewEngines.Engines[0];
	engine.MasterLocationFormats = new string[] { "~/Views/{1}/{0}.master", "~/Views/Shared/{0}.master" };
	engine.ViewLocationFormats = new string[] { "~/Views/{1}/{0}.aspx", "~/Views/{1}/{0}.ascx", "~/Views/Shared/{0}.aspx", "~/Views/Shared/{0}.ascx" };
	engine.PartialViewLocationFormats = new string[] { "~/Views/{1}/Partial/{0}.aspx", "~/Views/{1}/Partial/{0}.ascx", "~/Views/Shared/Partial/{0}.aspx", "~/Views/Shared/Partial/{0}.ascx" };
}

The problem with the ASP.NET MVC Revolution

2 June, 2009 (13:58) | ASP.NET MVC | By: twagner

blog-revolutionMany years ago I lived in a Communist country. I grew up there.  All children growing up in this Communist country had to learn about various Revolutions in history. Most dominantly the October Revolution in Russia that overthrew the Czar and established a Communist government. So it can be said that I have some idea of what it takes to make a Revolution.

Having spent some time with ASP.NET MVC – the revolutionary ” new ” direction of ASP.NET software development I have a few observations:

ASP.NET MVC is more than just the code necessary to make MVC compliant apps in C#. Seriously. It is a lot more. Just as the .NET System.Web namespace put a wrapper around HTML so does ASP.NET MVC.  Its not as deeply permeated as the regular Webform system but there is still an awful lot more to this implementation than simply the code needed to run an MVC app.

Here is the deal – in order to have a plain and simple MVC you don’t need all the stuff provided by ASP.NET MVC.  Basically you need a bit of dependency injection (just a few lines), an Action Framework and Routing Structure. That’s it.

Of course ASP.NET MVC has all that – and I must say the Action Framework is done very nicely – but at the same time it also contains a fullfledged attempt to substitute an entirely new paradigm for the existing webform system. Consequently you have all sorts of wacky stuff going on like Views that look a look like tag soup , partial views that are similar to user controls, a magical way of passing data back and forth among the models, views and controllers and number of other features that are intended to make the system more testable.

I have spent several days so far building an internal test app on the ASP.NET MVC framework and I am here to tell you this is no walk in the park. Considering this is a released product, it strikes me as ironic that there are only a handful sample apps out there which contain any sort of complexity.  There are a handful open source apps out there which range from absolutely pedestrian to entirely new generations of MVC that dont much resemble the MS release version (on the surface anyways)

In addition there seems to be a lot of flux in what is accepted as a good design and architecture. Several of the more prominent samples (Kobe, Oxite, MVC Commerce) are being rewritten based on extensive criticism by the OSS community. This begs the question who is the OSS community and how is it these folks have so much criticism of these products. I really hope its more than the handful of “usual suspects” in the .NET community. You know… the guys that like to congregate around the Alt.Net water cooler.

Here is my issue. When I am learning a new tool Ilook for definitive examples of good design and usage of that tool. And I just don’t see enough of those examples. Having 6 month old sample apps criticized as being incorrect architecture and in need of updates only adds to the frustration levels.

Consider how many millions of ASP.NET programmers there are in the world – heck the Indian sub continent alone can probably account for a few mill – the dearth of good ASP.NET MVC reference material is alarming. One would think that there would be more excitement around this stuff.  Of course I don’t have the same visibility into acceptance rates as some of the MS Regional directors. Its quite a dilemma I think. For almost 10 years MS web technology has gone one way ( web forms) and now here comes this entirely different way of doing it.  Like I said before, I am still waiting to see how ASP.NET 4.0 deals with routing (it still uses web forms). In the meantime I will keep plugging away at MVC.

One thing is for sure, in order for this Revolution to take hold there will need to be a much greater acceptance by the .NET community and that in turn requires more than a handful of books  and a dozen sample apps. In the end I am not even sure that the greater developer community at large will switch to MVC as opposed to Silverlight. Yes MVC will always have its audience , but I am thinking along the lines of the thousands of corporate developers. These guys would have a hard time with yet another paradigm shift and the reward seems to be so much greater in the area of Silverlight apps for these fellows.

I sure hope that in time my posts about this framework will become more positive.  I suppose that once I get past the frustrations there is a lot to like there.

Vendor Client Relations

1 June, 2009 (17:15) | Software Quality, Uncategorized | By: twagner

This is so correct and true to life it is scary.

More ASP.NET MVC Puzzlement

30 May, 2009 (19:50) | .NET, .NET Code Related, ASP.NET MVC, Software Architecture | By: twagner

puzzledI have been slogging my way through the MS MVC architecture. There are some good parts and some really hard to get used to parts. Some stuff just has me completely puzzled. For example when your used to setting an autopostback property on a drop down control, the need to have to hand code some js to do the same every time I want an autopostback gets old pretty quick.

I love the way MVC separates out the code that used to get thrown into the same code behind in web forms. It really shines in that regard. Who knows maybe it will have a positive influence on webforms apps in that regard.

For the moment my bottom line is that it takes a lot longer to write the same functionality in MVC than webforms. That’s partly due to the learning curve and partly due to the fact that there is more code to write. The fact that there is more code will be interesting to watch. Maybe in time people will find some efficient practices that will help to bring down the overall effort required. If thats not the case I wonder how someone would justify the cost of building a system one way versus another. And dont tell me to build it in MVC because webforms are evil. Thats nonesense. We have almost ten years of webform driven sites out there.

Lastly, for all those folks who are jumping on the “Viewstate is evil” bandwagon – which seems to be the same lemmings who jumped on Datasets as a DAO in 2002 – have a look at the following performance test. 6-8 requests per second for an MVC app is laughable. I sure hope that’s not the case presently. Its worth some internal testing to see. By the way, just on a purely subjective note, for the past year I have frequently spent time on MarketWatch. Since they switched to MVC I have noticed a small performance penalty. Purely subjective. Heck maybe its even a matter of browsers.

Decisions Decisions…..

25 May, 2009 (12:39) | .NET Tools, RoR, Software Architecture, Software Quality, Uncategorized | By: twagner

decisions11 As a programmer / consultant I always work on improving my skills. Except for the past year or so. I coasted a little bit. Consequently I am faced with two technologies that I need to study up. MS MVC and Silverlight. My personal feeling is that Silverlight will grow into the larger market over time. But at the moment its still lacking a lot of tools that a normal developer (not a bleeding edge addict) would come to expect in a platform. On the other hand MVC is slated to take off like a rocket. There is sooooo much pent up RoR envy in the .NET developer community its ridiculous.

My main issues with MS MVC is the fact that it tries to be something very similar to RoR. I feel this way because Model View Controller can be done without MS MVC. As a matter of fact as I have mentioned ad-nauseaum Dan and I have built and MVC driven framework a while back. So if I am interested in just the simplest most straightforward way to plug MVC into ASP.NET – thats the way to go – just build a small and simple action framework / router. No tag-soup either. I suppose I have to revisit this after ASP.NET 4.0 is out because it will incorporate routing.

Having said all that as a preamble, I would be silly not to study up on MS MVC. There are some aspects I really do like about it. The great enforcement of separation of concerns for starters.

As I looked over the web to find some decent examples of people who have blazed trails in this area I came across Karl Seguin’s Canvas MVC sample app. It was written with one specific purpose in mind: as a simple learning application that illustrates a good way to build an MVC app. In my opinion this app is a resounding success. It has enough code to illustrate the majority of work that one has to deal with (i.e. data entry, paged lists etc). And it doesn’t try to throw every possible scenario in the mix. The result is a well structured easy to follow sample. Believe me I have looked at numerous different ones out there and this is by far one of the better designed samples. Love it !

CodeGen on Steroids

21 May, 2009 (13:39) | .NET Code Related, Software Architecture, Uncategorized | By: twagner

steroids1Wow, I really have been leading a pretty sheltered life as a consultant. There is a toolset I have used for a number of years that has predictably delivered results. When it comes to projects where you deliver or you dont eat its pretty important that your tools work. Along the way I was fortunate enough – with the help of one important friend ( Dan ) – to produce some pretty good tools. We had a version of MVC in 2006 – 3 years before MS had theirs.

Fast forward to 2009. ASP.NET MVC hits the market. Only its not just routing and actions its a whole big kit and kaboodle. Reminds me a little of RoR. Along the way all of a sudden a lot of folks are complaining that Viewstate is the big evil and if only they could code without it. Meh. Sounds a little like people flocking to the latest shiniest thing. And there is nothing wrong with that. Its just ironic that many of the personality types that flock to this technology are the same type of folks who argued that datasets would save the world. Geez.

MVC is good stuff and my buddy Phil has poured his heart into this project. So I certainly hope it will thrive and progress. What has me confused at the moment are a plethora of adjacent projects that are growing up around it. I have a hard time discerning which to take serious. What do I make of an open source “architecture” that spits out a bunch of scaffolding pages and uses itself two other OSS projects. By the way, am I the only one who sees a trend of OSS projects where someone produces an entire new something that is 50% built on top of someone elses new something. Hope that makes sense. Did the RoR community go through a similar evolution?

As a consultant I need rock solid tools that are not necessarily going to be impacted by a deprecation of some obscure aspect because the manufacturer used some OSS project that is no longer popular. I really should research how the RoR community deals with this.

And while I am on the subject of “architectures”…. seems that there are some ASP.NET MVC “architectures” floating around that are primarily fantastic code generators. I would actually call them Form Wizards on Steroids. Hence the pic.

In 1992 I worked on a pretty large MS Access app. Yes we did those and they were good. Dont laugh. MS Access was the MVC of its day. Anyways, the IDE had a Form Wizard. Point it at a query or table and it would generate all the code you need. I learned an important lesson back then about code gen. Especially UI code gen. Dont use it. Wizard generated code is great … al the way until you need to change it. And Wizard generated apps tend to contain a lot of unnecessary stuff that you wouldn’t produce by hand.

Now mind you I am not talking about the utilization of some other view engine. Spark for example looks pretty cool. I am talking about the notion that a utility spitting out a bunch of views and controllers and tests is a measure of productivity. It is not.

Speaking of productivity. Rob Connery had a very cool demo of MSpec on his site. Finally a spec / test system that makes sense. (Besides Fitnesse that is).

Project Estimates = PM Voodoo ?

18 May, 2009 (10:38) | Software Quality | By: twagner

screenshot131In my experience project estimates are all over the place and often do not have any relationship to reality. Depending on any number of subjective factors the same amount of work gets turned into very untenable estimates.

Recently I watched a team of developers produce estimates that were fairly reasonable only to be asked to build the project for less money … in other words in the interest of budget constraints the devs were asked to submit an estimate consisting of less hours.

The unsuspecting developers did exactly that. In the interest of customer relationships they lowered the estimated hours of the project, thinking this would work out because the customer would be happy.

Some weeks passed. Nobody remembered why the total hours for the project were set at a specific level…as time passed all anyone cared about was the deadline. Can the team meet the deadline ???? When are they going to be done ??? We have commitments we need to meet. You know the drill.

Finally a point in time came when the team was behind schedule and the customer became very upset. Turns out that the customers project management people had made commitments on the basis of the discounted estimate.

The error here is that everyone worked in terms of hours = $$ . Instead of hours = work effort. The amount of work needing to be done did not change at all. Its not as though the deliverables had been reduced. And just because the dev team gave a discount expressed in hours on an estimate, that did not change the overall effort needed to produce the work.

The big learning lesson for me is to carefully look at the way in which estimates are expressed. A better solution is quoting the total price based on a normal effort and then apply a discount percentage to the bottom line. That approach could have saved these fellow programmers a lot of heartache.

Of course there was also the matter of having dependencies on legacy code that was not documented and nobody understood but that’s a different post for another day.

A question about social safety

29 March, 2009 (12:04) | Uncategorized | By: twagner

The NY Times has a nice article describing how German companies deal with the economic downturn (check the comments as well !) .

It touches on some of the aspects I previously brought up. The notion that in Europe, especially in Germany, you find a greater sense of social collectivism. Bad choice of words maybe. But read the article and ask yourself the following: “ In the long run, what is a better approach for a country and its citizens. A shared social responsibility or the individualistic approach advertised by the US.?”.   Keeping in mind that you can’t point to the economic might of the US as proof that this is the right way. Why? Because Germany is so much smaller yet so much more efficient with its resources. Imagine if Germany was given the resources of the US. So the self-fulfilling argument of “I am rich therefore I am right” is off the table.

Perhaps you will be in the same situation as I have been. Depending on my age and experience I would answer the question about pros and cons of each system very differently. In my younger years I found the less paperwork approach of the US very appealing. I could start a company on a dime and would not worry about employee welfare.  If the economy warrants it I would hire more people and as the business dictated I would lay them off.

Having been on both the giving and receiving end of this cycle I can tell you that the upshot of it entails more negative impact on the business than positive. My business depends on the intelligence and loyalty of its employees. My people are my greatest asset. By breaking the implied social contract that existed for so long between companies and its employees, I turn my workforce into a group of mercenaries. This is not some theoretical pontification – this is real and actual life. I recently saw a customer have a project severely impacted because he works on a “staff per project” basis with consultants and freelancers.

I know you can probably make arguments for the existence of our current system in the US that are just as eloquent as the ones being made in Germany. However, put yourself in the shoes of the workers described in Times article and then picture a typical US worker being laid off.  A shared social responsibility makes life better for everyone. Not just the fortunate few at the top. I would love to learn more about the way this concept is applied in countries that are even less individualistic than Europe. For example in Asia.