Thursday 29 November 2012

Worlds apart but not that different

One the face of things: a philosophical monologue.

I have been brushing up on my ASP.Net skills prior to the start of a rather large Sharepoint based project and during the last week have been comparing the JEE6 (Java Enterprise 6) stack to the ASP.Net stack.

Luckily I don't have to wallow in the mud with VB, the language of choice here is C# so the jump between the 2 languages, Java and C#, is not so great. Mind you the syntax of a programming language, especially when they have such close roots, should never be anything other than a trivial exercise for you.

Not a clash of ideologies here

There have been so many flame wars, rants and idealists fighting about .Net vs Java that I am not attempting to fan the flames again.
If you consider the 2 platforms, as you should be doing, then .Net and Java are really worlds apart but still not that different... really!

Adam Bien posted some while ago: JAVA EE OR .NET - AN ALMOST UNBIASED OPINION
I agree with a lot of what was said there and a lot of the comments, trolls notwithstanding, have kind of kept the material up to date. What I don't agree with is LINQ for SQL.
I have been playing with LINQ for SQL and it under pressure it cracks. With even moderate amounts of data things like paged data access becomes slower and slower and memory leaks all over the place.
LINQ is still excellent for queries on generic collections and especially XML though.

The thing is that the Java vs .Net arguments live because people are way too married to the favorite language or platform and are missing the point in the abstract. Can I use either platform to provide solutions in software which fulfill the customer's requirements without having to reinvent the wheel doing it?
The answer is a resounding yes because so much of the progress made on design ideologies, eg. Patterns and development practices, eg. Agile, are applicable to any application platform in general use. Not only that but the tools available use the results of such progress regardless of which platform.

What am I waffling on about? The Backend!

As I do most of my work in the Java World I was looking for a decent all purpose ORM tool seeing as the MS one is, well, only good for the MS World and still not very good at that either.

A colleague of mine pointed me in the direction of NHibernate, a project I was already aware of.
Yes, this is similar to Hibernate from the Java World. It does suffer a lot from "A Sea of XML  Configuration" though, similar to old style EJB.
It does have a lot of advantages though

  • Database agnostic with the caveat that a driver and possibly dialect exists for it
  • It is very well supported and is used in a lot of Projects.
  • There are a lot of similarities with Hibernate and JPA and for me the jump from JPA to NHibernate was not that wide.
If it weren't for all the XML though...
Enter ActiveRecord.
  • Uses NHibernate
  • Domain objects are classes which determine the structure in the backend.
    I find it easier to do the domain at the Object level and have the engine build the car as it were, ie have the ability to create or modify the Database Schema via changes to my domain classes and their relations.
  • The only XML you really ever need is for configuring the connection, this is a snap
  • Is really, really, easy to Unit Test, I have not seen the need to mock anything yet, I can test against a real DB. You can still mock things up really easily though.
The makers of ActiveRecord, Castle, also have other goodies. I have been using their Proxy tool for quite a while now.

I am almost fanatical about the Java Platform and I do really believe that it is the best general server platform in terms of cost, reliability, performance and freedom of choice. Having said that I am able to do my thing, developing middle tier components, in either environment, and only have to deal with the differences at the surface. With .Net you just have to work a little bit harder on the backend, with Java on the UI.

Now, when are PrimeFaces going to give me all their wonderful UI Components working under ASP.Net?

No comments:

Post a Comment