March 2006 - Posts

So last week Frans Bouma and me presented the Visual Basic or C# battle. So what was the outcome?
 
Well in both cases C# took the lead and won. However I am not sad because I lost ;-) In fact I think we showed that in most cases there isn’t a technical advantage to either of the two. There are some exception thought.
 
When Visual Basic has an edge:
  1. Office/VSTO development.
    The Office object model was created with optional parameters, a feature of VBA, in mind and makes heavy use of it. As Visual Basic supports this it has an advantage over C#, unless of course you like typing Type.Missing :-)
  2. COM interop with older applications.
    And in this case I am specifically referring to COM interop without a complete type library, something common in VB6 or Visual FoxPro. This is where Option Explicit Off is a great helper and time saver.
 
When C# has the edge:
  1. Very large projects.
    In these cases the complete background compilation of the VB IDE and related updating of the Error List window might become a drag. That said I have not worked on a Visual Studio 2005 project where I experienced this.
  2. Unmanaged code.
    While there is no speed difference between C# and VB when it comes down to managed code C# leaves the option of unmanaged code open. Unmanaged code makes direct memory manipulation possible, something we showed in a graphics demo where the unmanaged C# version was more than 20 times faster than either the managed C# or VB code.
 
So what to choose?
  • Well keep the product team focus in mind. The C# team focuses in correctness while the VB team is more focused on RAD. So if you want to develop applications faster you should consider VB and if you want more predictable and verifiable results take C# instead. This difference exists today but will increase in the future so choose wisely.
  • If you are a manager you might want to consider the average developers background. The C# developer is more likely to have an academic background, something that translates into more theoretical knowledge, higher pay and lower availability.
  • Your development focus. C# translates into framework/library building and VB into the glue that puts everything together. Of course you can use either language for either purpose but if you make a choice depending on your activities this is it :-)
  • If you want to work with multiple languages that’s ok, although I would recommend not. Just make sure you stick to C# for the library/framework stuff and VB for the application glue. Doing it that way should work fine but doing it the other way round is a big nono in my book.
  • Personal preference. And that is the big one and the reason most choices are made. Just be fair and admit its only personal preference and don’t hide behind fake technical arguments :-)
 
So now you are in a position to make a more informed choice. So choose, code and enjoy .Net :-)
 
BTW if you are looking for the PPT and samples you can download them from here.
 
Maurice de Beijer
with no comments
Filed under:
Yesterday evening I installed Vista for the first time. I guess I am both pleasantly surprised and not so :-)
 
Good
  • While the installation took its time there was relatively little user interaction and all of it in the beginning. All I had to do was leave my old notebook alone and come back an hour later.
  • Even though my old notebook is over 2 years old, closer to 2.5 actually, the speed isn’t that bad. Sure it is slower than XP but I guess that is to be expected. Now if I could only remember why that is supposed to be the case :-)
  • Security seems to be better. Several times I received a notification that a driver needs to be installed and would I grant it the required privileges. Now I am not a security expert so I can't comment on how secure it is but I am sure someone else will.
Bad
  • First I tell the installer that I want to use the Dutch language settings. Next when we come to the clock part it suggest using US time. Now how likely is it that I am living in the US and want Dutch language settings? Not very is my take. So how about a slightly more intelligent default?
  • I tried to run Charles Petzold samples from http://www.charlespetzold.com/wpf/ and they wouldn't run because the WinFX runtime wasn't present. Seems kind of strange that the WinFX runtime isn’t part of Vista when that is supposed to be the way to develop .Net applications. Than again maybe there was an older version or MS can’t include it by default because of the lawsuits.
 
But what I am wondering about most of the time is why people need to upgrade from XP to Vista. Sure it is more secure but most people don't care all that much, large numbers still connect to the internet without a router or decent firewall! Large companies do care but they typically tend to keep their PC longer so my take is that their average machine is going to be to slow to run Vista. Specially when you consider that most business PC's have only mediocre graphics cards and Vista want's a fast graphics card with hardware acceleration.
 
So I guess that leaves techno nerds, who are going to upgrade to any new gadget, and new PC's sold with Vista preinstalled. Sure sounds like Vista adoption is going to take a while :-(
 
Maurice de Beijer
with no comments
Filed under:
In a recent blog post Anko raises the question if functional exceptions exist or if business rule validations should be handled differently. He states that he strongly believe that functional exceptions should not exist.
 
I have to say that I disagree with him. I do believe there is a case for both technical and functional exceptions. That doesn’t mean that exceptions are the only error notification strategy though.
 
Take for example a daybook entry in an accounting system. This consists of two general ledger accounts and the amount to be charged to each account. If the data entry form is designed so that the user can only pick two existing general ledger accounts they should never cause a business rules violation right? Wrong, because another user might delete one of the accounts before the daybook entry was written. Now the business rules could first check if the general ledger accounts exist but as the user can only pick valid ones this is not going to fail very often. Even if this check was done it there is always a moment between the check and the actual update. Sure you can prevent the account from being deleted by either locking the data, god forbid, of by wrapping everything in a single transaction. While this would work it would also mean that the connection to the database is kept open longer and the transaction lasts longer, both bad for scalability.
 
So what was the definition for an exception? According to Anko “An exception is the fact that something happens during the execution of the program you do not expect.” something I completely agree with. So can we consider the case where one user deletes a general ledger account at the same time as another user first uses it an unexpected event. You can argue this either way and both would have a point :-) However this is not going to happen very often. In fact it is very unlikely to happen at all during the lifetime of the application. Now writing the code inside a transaction that is automatically reverted in the case of an exception is easy and takes very little, if any, code. Writing the checks and reverting the updates manually takes quite a bit more code and most, if not all, of the exception code is never going to execute. I don’t like writing code that is never going to execute, seems like a waste of time :-(
 
That leaves another point, the execution speed.
It is completely true that exceptions are slow, even every slow, as compared to checking for and returning a boolean or enum indicating the failure. For that reason I would never use exceptions as the only means to indicate failure in a tight loop. However the scenario described above is the result of a user saving a single daybook entry, hardly a tight loop in my book :-) Suppose the same business code can be executed from another business process that might be in a loop. In that case I would add a validate function to check, without exceptions, of an entry is valid. This code can be independent of the first update code, manage it’s own connections etc. The tight loop could use this extra function to validate bookings before actually committing them, greatly decreasing the likelihood of an exception.
 
So what is my recommendation?
  • Write the code using exceptions as this produces more reliable and readable code.
  • Add optional validation functions that validate the business data without throwing exceptions.
 

 
Maurice de Beijer
with no comments
Filed under:
Microsoft recently announced the Visual Basic 2005 “Experience the difference” Tour. One of the stops in this tour would be in Amsterdam. Regrettably this meeting is canceled. I consider this quite unfortunate as we don’t often get VB developer from Redmond in the Netherlands. I can only hope we soon get another chance to hear from them. Fortunately the ASP.NET tour is still on so we are not left completely in the dark ;-)
Maurice de Beijer
with no comments
Filed under:
This is intentionally in Dutch as it is target at Dutch developers.
 
Microsoft organiseert dit voorjaar een aantal trainingen om ontwikkelaars voor moet bereiden op de komst van Vista. Deze trainingen zijn niet duur, € 50,- of zelf gratis voor partners, dus dat kan geen belemmering vormen.
 
Windows Presentation Foundation, voorheen bekend onder de codenaam Avalon, is het geünificeerde presentatiesubsysteem van Microsoft voor Windows. Het bestaat uit een weergave-engine en een managed-code framework. Windows Presentation Foundation unificeert de manier waarop Windows-documenten, media en de gebruikersinterface creëert, weergeeft en manipuleert.
 
Dit stelt ontwikkelaars en ontwerpers in staat om visueel zeer aantrekkelijke, aangepaste gebruikerservaringen te creëren die de band van de gebruiker met de toepassing verstevigen. WPF is beschikbaar in Windows XP, Windows Server 2003 en alle toekomstige versies van het DataBinding-besturingssysteem.
 
Deze sessie is een kennismaking met Windows Presentation Foundation. De architectuur en de toepassing van WPF worden besproken en gedemonstreerd. In detail wordt ingegaan op DataBinding en XAML. XAML is een taal met opmaakcodes waarmee de gebruikersinterfaces declaratief kunnen worden beschreven voor Windows-toepassingen. Hiermee krijgt een ontwikkelaar nog betere en preciezere gereedschappen in handen voor het samenstellen en ombouwen van gebruikersinterfaces voor eigen doeleinden.
 
Voor webontwikkelaars biedt XAML een vertrouwd model voor de beschrijving van gebruikersinterfaces. XAML biedt ook de mogelijkheid om het ontwerp van de gebruikersinterface te scheiden van de onderliggende code, wat ontwikkelaars en ontwerpers in staat stelt om nauwer samen te werken.
 
Datum:   18 april 2006
Tijd:        09:00 - 16:30 uur
Maurice de Beijer
with no comments
Filed under:
This afternoon Frans Bouma and myself will be presenting a repeat of the session we did last night on the question on everyone's mind: should I use VB or C# when developing a .NET application. Frans is a C# MVP and will take care of that side of the table while I as an VB MVP will try to convince him that VB is the better tool :-)
 
If you are a member of the SDN usergroup this meeting is free so quickly go to the SDN web site and register.
 
 
Maurice de Beijer
with no comments
Filed under:
This evening Frans Bouma and myself will be presenting a session on the question on everyone's mind: should I use VB or C# when developing a .NET application. Frans is a C# MVP and will take care of that side of the table while I as an VB MVP will try to convince him that VB is the better tool :-) You can still join us tonight if you register for this free event at the DotNed site.
 
 
Maurice de Beijer
with no comments
Filed under:
This is intentionally in Dutch as it is target at Dutch developers.
 
Microsoft organiseert dit voorjaar een aantal trainingen om ontwikkelaars voor moet bereiden op de komst van Vista. Deze trainingen zijn niet duur, € 50,- of zelf gratis voor partners, dus dat kan geen belemmering vormen.
 
Windows Communication Foundation, voorheen bekend onder de codenaam Indigo, is de nieuwste webservicetechnologie van Microsoft. Het breidt de functionaliteit van het .NET Framework 2.0 en Visual Studio 2005 uit, maar kan ook worden gebruikt in combinatie met BizTalk Server 2004 en 2006.
 
Door dit alles worden Visual Studio-ontwikkelaars in staat gesteld verbonden systemen te maken met de programmeertalen die zij al kennen. Dit resulteert in:
 
  • minder complexiteit voor ontwikkelaars
  • minder onderdelen die moeten worden beheerd door IT-professionals
  • minder training voor ontwikkelaars en IT-professionals
  • een aanzienlijke kostenbesparing voor de organisatie
 
Deze sessie is een kennismaking met Windows Communication Foundation. De architectuur en de toepassing van WCF worden besproken en gedemonstreerd. In detail wordt ingegaan op het programmeermodel van gedistribueerde applicaties en de keuzes die daarmee samenhangen.
 
Datum:   21 april 2006
Tijd:       09:00 - 16:30 uur
Maurice de Beijer
with no comments
Filed under:
Next Friday, march 24th we are hosting another Software Developer Event in Ede. There are a number of interesting session to go to, and don’t forget to come to Frans and my session about Visual Basic versus C#.
 
If you are a member of the SDN the meeting is free. If you aren't a member yet this is a great opportunity to do so :-)
 
 
Maurice de Beijer
Its been a while with the long and miserable winter but finally I got some air time again :-) The weather was actually surprisingly nice with a lot of sunshine. Now if spring just got around to a real start I can get a lot more airtime. And I am still waiting for my new wing, should be done any day now.
 
 
Maurice de Beijer
with no comments
Filed under:
If you subscribe to the Dutch version of the .Net magazine you are in luck :-) In it is an article I wrote about the new language features in Visual Basic 9 and LINQ.
 
Enjoy the article.
 
Maurice de Beijer
with no comments
Filed under: ,
Web services are cool and really neat but they do suffer from one drawback and that is that the need Internet Information Server (IIS) as a host application.
 
Ok maybe it isn't that much of a drawback but would like to be able to host one without running IIS at least some of the time. Well the good news is that it isn't all that hard of you first install WSE 3.0. One of the features of WSE 3 is the ability to host web services in a service (or a console or similar application for that matter). The only requirement at runtime is that the WSE 3.0 runtime is installed on both the client and server machines.
 
To create a simple server:
  • First create a normal web service.
    This service is only used for development.
  • Next create a console application
  • Add references to:
    • Microsoft.Web.Services3
    • System.Web.Services
  • Copy the Service.vb from the web service to the console application
  • Add the following line to the HelloWorld function:
            Console.WriteLine("Request received")
  • Add the following code to the sub main:
            Dim Address As New Uri("soap.tcp://localhost/Service")
            Dim endPoint As New EndpointReference(Address)
            SoapReceivers.Add(endPoint, GetType(Service))
                Console.ReadKey()
 
Next we need to create a client application.
  • Create a second console application.
  • Add references to:
    • Microsoft.Web.Services3
    • System.Web.Services
  • Add a reference to the real web service created while developing the service.
  • Add the following code to the sub main:
                Dim ws As New localhost.ServiceWse
                ws.Url = "soap.tcp://localhost/Service"
 
                Console.WriteLine("Press escape to stop.")
                While Console.ReadKey(True).Key <> ConsoleKey.Escape
                        Console.WriteLine(ws.HelloWorld())
                End While
 
                Console.ReadKey()
  • Run the server.
  • Run the client.
 
Note that we create an object of type localhost.ServiceWse not localhost.Service. This is because adding the WSE reference added some logic to the proxy generation process resulting in two proxy objects. Using the wrong proxy object results in a "The URI prefix is not recognized." NotSupportedException. In that case just change the proxy to the Wse variant. If you don’t have the localhost.ServiceWse proxy class you probably didn’t add the Microsoft.Web.Services3 reference before adding the web service. In that case just add the Microsoft.Web.Services3, right click on the localhost icon below the Web References node in de the Project Explorer and select Update Web Reference to regenerate the proxy object.
 
Good luck in exploring WSE 3.0
 

 
Maurice de Beijer
with 1 comment(s)
Filed under:
More Posts Next page »