Monday, May 10, 2010

ICEfaces 1.8 - Next Generation Enterprise Web Development

Hi,

because of the integration of ICEfaces and Grails I started looking at books describing ICEfaces as a framework. Unfortunately I found only one, the "ICEfaces 1.8 - Next Generation Enterprise Web Development".

I was pretty excited at first when I saw the integration itself. Many things are done by convention (so more/less the Grails way), views use Facelts for templating... And in many places ICEfaces is mentioned as the best JSF-based framework out there.

So back to me reading the book...

Well,... hm,... what can I say...

60 pages of blah blah blah about how difficult it was to create web applications in the past with pure servlets and JSP, then the magical discovery that was made that web apps could actually mimic the experience of desktop apps... All nice and dandy but... BOOOORING!!!

I finally came to the page where code started to shine through the misery we've been at for the past decade or so. The thing that killed me at first was the statement that layouts should be done using tables!

I mean come on, guys! Where's the distinction between content and presentation? Where's the semantic web stuff??? Should we abandon CSS completely because IE is so damn cruel in this regard?

They even say that they took this road because of "pragmatism":

You may wonder why we use a <table> for the layout, and even the align attribute, when there is a <div> tag and CSS. The answer is pragmatism.

Whatta heck is that?

Honestly, around page 64 I have decided to stop reading the 290+ pages miserable poem and figure out the way to deal with ICEfaces myself using examples from their website.

The conclusion is that some books could just be better. Nonetheless it's fascinating how things get boring when you step back into the "official enterprise" sort of things having your brain already set on the nature of the web (the request/response kind of thing) by all those MVC-based frameworks like Grails, RoR and ASP.NET MVC...

Have fun!

C# with dynamic: Xml processing

Hi there!

I've been watching Anders Hejlsberg and his presentation about dynamic features introduced in C# 4.0. It got me into thinking that the CTPs and RCs of the language must have been long enough out there for people to do some crazy stuff with it.

I was sooo not mistaken!

Take a look at those couple of things here:
  1. DynamicXmlParser
  2. XmlBuilder

Those are like straight out of Groovy just named a bit differently (the dynamic xml parser is called XmlSlurper) but do mostly the same thing!

C# is getting more and more appealing to my liking of programming languages :)

Have fun!

Thursday, May 6, 2010

Delphi 2010

Hi there!

I'm currently looking at the newest version of old Borland tools namely the "Delphi 2010" environment. I thought that I'll share my thoughts with the rest of you...

There are a few things I'd like to make one thing completely clear: I'm a seasoned Delphi programmer with more that 10 years of experience of using Borland's and then Inprise'es and after that CodeGear's tools to do the job. That being said it is my honor to write a brief review of the latest and the greatest that came out of Embarcadero...

So.. Leaving the "nice words" behind let's see what's in the package!

Let's start with Ruby.
The so called "3rd rail" is not much of a helper since all they have added is the project support, debugging and some code-insight (that's Borland's name for the code hints). After 15 minutes I've reverted back to the only free IDE supporting RoR and I was happy to stop dragging the 3rd leg behind me...

(I just needed to spit it out - sorry :D)

Delphi... Completely different story!
I was using Delphi from version 2.0 when it came out in 1996 I was still using Turbo Pascal and I believed that to be the ultimate choice for a developer. Delphi teached me that doing GUI manually might not be the best idea and also showed me that stuff like code insight are actually working.
Years after that (4 to be exact) I started working for a company in Poland that used Delphi 5 to do some CAE-like application. It was really amazing what one might have accomplished with this tool at hand!
Later we've switched to Delphi 7 which I believe to be the absolutely, completely, unquestionably best IDE in the world EVER! The personal edition had everything a proficient Pascal developer would ever need and was so damn fast that today's Express editions of Visual Studio can only dream about being in such a great shape.

Then came along Delphi 8... For Microsoft .NET 1.0 (as far as I can remember)... It came and went...

I really hoped Delphi 8 was a misunderstanding and that later version of my beloved IDE will follow the usual path. You can imagine how crushed I was when the next version came out and it was based on the same completely lame engine as 8!!! That was the day I thought to myself "OK buddy, it's time to learn something else". With that in mind I was still looking at the evolution of my old IDE just to make sure I made the right choice :)

Today it's the year 2010, Borland is pretty much dead, Inprise is a name no one has ever heard of, CodeGear has a nice ring to it but the phrase "whatta heck is it" surfaces every time I ask someone about it... And today's name for the company is..... Embarcadero!

They still follow that same devil's route Inprise embarked on in 2003 which is a long-starting, incredibly embedded, ugly looking and slow performing IDE.
Sure they have added some cool features to the language. No questions about it... But was that enough to justify a programming language evolution to bring the old, lovely platform down???

Today I'd never ever choose Delphi for my development - at least nothing above version 7 which is in my opinion the best IDE for Pascal-like languages ever created (and I admit I'm a bit tainted but hey.. who's not!).

I'd like to know why Borland and then Inprise, CodeGear and finally Embarcadero didn't see the beauty of the IDE, the language and the huge user base they have had back in the days and shifted to this ugly-looking thing they are feeding us today?


Rust in Peace Delphi! You'll always have a special place in my heart!

Sunday, May 2, 2010

ASP.NET 4 WinForms inside an MVC project

Hi,

I was stunned today watching a presentation by Scott Hanselmann about the new features of .NET 4 especially the fact that you can actually compose in a WebForms page into an MVC application using routing and it all just works!

Imagine you have like a regular MVC 2.0 app and for this one thing that you need to implement having a form instead of a controller and view would be soooo much easier. Now with this simple line of code
routes.MapPageRoute("Form", "Example", "~/Forms/Example.aspx");

you can actually do just that!

In this example I've created a folder called Forms inside of my MVC project and inside that project I've created a WebForms page named Example.aspx. To be able to access that page all I needed to do was to tell the routing thingy that I want the Example.aspx page to be available under /Example and that was it!

Now the question if we should go with WebForms or MVC is gone! You just use whatever suits your needs in the particular case you have to solve and you're done.


Have fun!

Saturday, May 1, 2010

The Great Trio

Hi there,

I wanted to do a comparison of different MVC-based frameworks/application stacks flying around. I was looking lately at Ruby on Rails, Grails and ASP.NET MVC so this comparison is going to tackle those 3 guys.

I've deliberately left out pure Spring MVC, Monorail, all the statefull frameworks and other guys because I personally think they are so much not how like I'd like a framework to look like.

Let's start with Ruby on Rails.

1. Extremely nice, terse and concise language (+)
2. Very large user's group (+)
3. Easy to write CRUD-based applications (+)
4. Very testable (+)
5. Depends on the existence of a database (-, but it can be changed)
6. Tooling support OK (+)
7. Free IDE support is not so great (-)
8. Platform agnostic (when you take into account that you can deploy it virtually everywhere, for example on .NET, Java and pure Ruby interpreter it's mind bothering how far you can go with this guy) (+)

Let's quickly follow up with Grails.

1. The language is for sure better than Java but it still has this Java-feel I personally despise.
2. User's group not so large as in the case of RoR but still large enough (+)
3. Easier than with RoR when it comes to writing CRUD-based applications due to the dynamic scaffolding mechanism (++)
4. Very testable (+)
5. Does not depend on the existence of a database to execute but can use one if you'd like it to (+)
6. Tooling support OK (+)
7. Free IDE support is not so great (-)
8. Easy to deploy on any Java EE container so it runs everywhere (+)

And last but not least - ASP.NET MVC.

1. I love the language (+, yes, it's my personal preference). With the latest addition of "dynamic" keyword (and therefore ease of integration with dynamic languages) it's the most powerful language I've come across so far.
2. User's group is very limited by comparison to the other two. (-)
3. CRUD-based applications are definitely the strongest point of this framework but it's mainly due to the fact that it pushes you in no direction when it comes to database layer. You can choose whatever you want (for me it's a +)
4. Very testable (+)
5. Free IDE support (with tooling) is fantastic! (++)
6. Learning materials are through the roof! (+)
7. Deployable on .NET and Mono but not as broad as with the other two guys (-)

I guess when it comes to my personal preference I'd choose ASP.NET MVC before any of the other tools. However the plugin support in Grails and RoR is really amazing and one can accomplish a lot without writing even one single line of code which is an extreme productivity boost.

Have fun cuz that's all that matters!

ASP.NET MVC and different output formats

Hi there,

I wanted to mimic the nice behavior of Ruby on Rails that allows you to render different content based on the extension passed on in the URL. Here are a couple of examples:

http://localhost/people/list.json <- list of people in JSON
http://localhost/people/show/1.json <- person with id=1 in JSON
http://localhost/people/list.xml <- list of people in XML
http://localhost/people/show/1.xml <- person with id=1 in XML

The part I was not able to figure out right away was the routing configuration. Here's how I finally did it:
routes.MapRoute(
"ActionWithFormat",
"{controller}/{action}.{format}"
);

routes.MapRoute(
"ActionWithFormatAndId",
"{controller}/{action}/{id}.{format}"
);

routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new {
controller = "Home",
action = "Index",
id = UrlParameter.Optional,
format = "html"
}
);

As you can see here I've added 2 additional routes (ActionWithFormat and ActionWithFormatAndId) that contain the additional parameter distinguished by "." (dot) instead of "/" (forward slash). I've also took the liberty to modify the Default route so that when no format is passed the default "html" format is what you'd get passed to the action.

Now suppose you'd like to make use of it in the PersonController's Show action:
public ActionResult Show(String id, String format)
{
var person = new { FirstName = "John", LastName = "Doe" };
switch (format)
{
case "json":
return Json(person, JsonRequestBehavior.AllowGet);
default:
return View(person);
}
}

Sure that the RoR's version is shorted, nicer, purer and all that but this little fellow here does the trick as good as the RoR's :)

The key here is that the format is just a string so if you'd like to come up with (let's say) a PdfActionResult then using it in an action is just dead simple!

I hope you'll find it useful!