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!

Friday, April 30, 2010

Reloading lib/ classes in development

Hi,

I've finally found a solution for reloading classes found in rails' lib folder.


In Environment.rb: Add the path for the lib subdirectory where my module was stored, e.g.

config.load_paths += %W( #{RAILS_ROOT}/lib/item_setup )

In Development.rb: Add the name of my Module to the explicitly_unloadable_constants list, e.g.,

ActiveSupport::Dependencies.explicitly_unloadable_constants = 'NameOfMyModule'

If you have other modules you want to automatically reload, use the << explicitly_unloadable_constants array, e.g.,


ActiveSupport::Dependencies.explicitly_unloadable_constants << 'NameOfAnotherModule'

That's more less it.

Monday, April 19, 2010

JavaScript editor in VWD 2010 rocks!!!

Hi there,

I've always been a huge fan on VisualStudio. That fact alone means that my opinion might be biased. However what the VS team made this time with the capabilities of JavaScript editor is simply magic!

Here's what I started with: I've created an ASP.NET MVC project using default settings. That has produced the basic skeleton with Scripts folder in it. Then I've created a new WebSite, copied the jQuery stuff over from that MVC project, created a new JScript file, included jQuery in it and bang! IntelliSense worked just like that!

And it's not only because the $ object is defined! Far from it! Take a look at the following screenshot:


As you can see the IntelliSense worked not only with the stuff that comes directly from $ object but also worked just fine with my plugin as well!

Here's another example that I've tested - ExtJS:


As you can see the editor was capable of parsing all the sources from ExtJS and provide me with the proper IntelliSense for a an object instantiated from Ext.Window prototype!

To add to all that the editor works like a speeding car - fast like I've never seen it before anywhere else!

I'm sure other IDEs (especially those from Java world) provide good developer experience but VWD 2010 is simply the best!

Thanks Microsoft for making this tool available to everyone!


Have fun!

Thursday, April 15, 2010

4Developers conference in Poznan


Hi all,

last month I've visited one of the biggest conferences for developers in Poland. 4 tracks, a lot of very passioned people, lots of great material, good beverages and great service - all in one place.

To the right there's Jarek Palka with me just moments before his presentation on JavaScript on the server side :) Very interesting stuff indeed!

If you'd like to check out the agenda and presenters look at http://2010.4developers.org.pl/

One thing that I must say was a big disappointment was the presentation given by Jacek Laskowski. I was really expecting more from a person like him. Instead we were given a lot of CV stuff and unprofessional jokes.

A very interesting thing I saw there was a presentation by Maarten Balliauw showing not only that programming against the cloud is possible but also that using Microsoft's IDE and tools it's extremly easy! Good job Maarten!

See you again in a year!