Tuesday, 29 March 2011

Why I hate Open Source development

Why I hate Open Source

I don't often use my blog to rant about things but I am proper pissed off today and I am going to vent my spleen on the topic of open source.

Why am I pissed off? Well apart from the fact that I have a serious health issue that my GP won't refer me to the relevant clinic due to our primary care trust not willing to pay for the treatment I am getting more and more annoyed with open source coding and the numpties that contact me constantly asking me to do their work for them for free.

Don't get me wrong. From a coders point of view it is great to be able to take code from a wide variety of sources and then use it for free or more often than not tweak it to accommodate the changes you require for your own system. I have no problem with that aspect of it whatsoever. If I didn't want people to use my code I wouldn't have put it online for everyone to download.

However my inbox is a testimony to the fact that there seems to be a lot of people out there who
a) can't code.
and
b) expect you to do all their work for them for free.

I am pretty sure there are people all across the world (cough India) that are basically making a living by using other peoples code and then getting people to fix, upgrade, tweak and build all their work for them for diddly squat. These people really tweak my nips!

If you can't code and have put a stupid $50 bid on Rentacoder.com to develop a whole website by next week and expect me to do all your work for you just because you found a piece of my code that does 90% of what you need and you require the other 10% doing for free then you can take a running jump.

People like you are the reason good coders work 50 hour weeks for tech companies and then spent all their free time trying to come up with something that might make some money if the world of programming actually behaved like any other kind of market place.

From the point of view of actually making real money I cannot think of a worse idea f0r anyone than open source coding. Off the top of my head I cannot think of any other business model that acts in a similar way and leaves the person who produced the goods with bog all and the customer with all their hearts desire at a cost of zilch!

Giving your code away for free in the hope that people either donate you some money, hire your services on unrelated matters or if you have created an application pay for value added services is akin to a builder spending months building a house, giving it away to the owner for free and then hoping that the new occupants either throw a few quid your way out the kindness of their heart or hire you to build them an extension.

What grates me the most however is the non coders who take all the hard work that you didn't have to make public and then expect you to either add in all the features that they require for free and then complain when you tell them that you can't help out due to pesky little problems such as having a full time job or wanting a life.

Personally I thought the whole idea of open source code was that you took the original code and made of it what you could. I only really got into PHP / MySQL within the last year and in that time I have made a number of sites and Wordpress plugins that are all well reviewed, have been downloaded tens of thousands of times yet have earned me less money from donations than any Saturday Mall Chugger would with their mouth glued shut.

The only reason I created my plugins in the first place was due to a lack of features in those that existed already.

I didn't hassle the developers of the plugins by email, twitter and message board asking them to do my work for me or expect them to add in my custom features for free like many people seem to. No I took their good ideas and made my own versions and then put them up online so others could do the same.

I can totally understand the fact that many people are not capable of developing their own code or taking other peoples code and tweaking it but it is really starting to grate me when I receive email after email asking when I am going to do X or Y and in a tone that seems to expect that I have nothing better to do than do all their work for them.

Having emails in broken English that say "I need your plugin to do BLAH and need it done by Monday very urgent please help!" is not the right way to go about getting things done.

I have even had people ask me how to steal my own code so they could leach my bandwidth by hosting it on their own site.

And worst of the whole lot is the two people now who have literally begged me for a feature to be implemented in one of my tools and then when I implemented it they don't even give even the most basic donation.

I mean if I have just spent 5+ hours adding in code that makes your life easier surely that is worth at least a score or a tenner. Even the nice bloke who donated me a solitary pound the other day ranks higher in my estimation than the scrotes who take the piss like that.

And before I get inundated with a load more emails promising me donations as soon as I just do X Y and Z I want to say NO NO NO. I've had it up to here with the whole shabang.

Server bills don't get paid by magic you know so the next version of any plugin releases are all going to be paid only. If people really want these features then they will be willing to pay, either that or learn how to code. It's not like there aren't enough Google 101 guide's on the web to get started with.

Rant over.

Monday, 14 March 2011

SQL Varchar Comparison Ignores Right Hand White Space

MS SQL Server Text Comparisons

I was doing some work in SQL 2008 today that involved some data cleaning from a scraper that was extracting specific data from a webpage and trying to match it in a DB. The data was very dirty and not consistent in the slightest so I was running it through a number of custom parser functions to try and find matches.

Whilst doing this I came across something that I certainly thought was odd and hadn't seen before. I don't know if this is a well know "quirk" in MS SQL or not but a couple of colleagues had never seen it either.

It involved string comparisons where one string had white space to the right hand side of it and the other had no space either side and a string comparison matched.

This only occurs when the white space is to the right hand side of the text and not to the left hand side as the following test shows.

I had never come across this quirk before so I thought I would make a note of it incase others hadn't either. I ran this test on 2008 and 2005 with the same results.

DECLARE @Test1 varchar(100),
@Test2 varchar(100),
@Test3 varchar(100)

SELECT @Test1 = 'Stratford ',
@Test2 = ' Stratford',
@Test3 = ' Stratford '

IF @Test1 = 'Stratford'
PRINT 'Is Stratford'
ELSE
PRINT 'Is not Stratford'

IF @Test2 = 'Stratford'
PRINT 'Is Stratford'
ELSE
PRINT 'Is not Stratford'

IF @Test3 = 'Stratford'
PRINT 'Is Stratford'
ELSE
PRINT 'Is not Stratford'

SELECT '"' + @Test1 + '"', '"' + @Test2 + '"', '"' + @Test3 + '"'




The output I get is the following


Is Stratford
Is not Stratford
Is not Stratford

and then a recordset.

"Stratford    " "   Stratford" "   Stratford   "
Maybe this is a well known behaviour but I wasn't expecting it to behave like this so it threw me off a bit during my cleanup process.


Thursday, 10 March 2011

Problems and solutions whilst creating an ASP.NET Web Service

Problems setting up an ASP.NET Web Service

I was recently following a guide to setting up a .NET web service in Visual Studio 2010 and I ran into a few problems.

The guide I was using was Microsoft's own Knowledge Base article which runs through the setting up of a very simple Maths based web service.

Missing Web Service Project Template

The first problem was trying to find the ASP.NET Web Service project template on the start up page of Visual Studio. Step 2 of the guide says:

On the File menu, click New and then click Project. Under Project types click Visual C# Projects, then click ASP.NET Web Service under Templates. Type MathService in the Location text box to change the default name (WebService1) to MathService.
However in Visual Studio 2010 this option was missing. I found out that the reason was due to the default Framework being set to .NET 4.0. The solution is to change the framework to .NET 3.5 and low and behold the Web Service template option was available to select.

I don't know the reasons behind this so don't ask and maybe it's possible to create a web service in .NET 4.0 some other way. If I find out I will update this article.


How to resolve "Could not create type MathServices.service1" error

The second problem I ran into was due to the advice given in step 3 which was to rename the default web service to something else.

Change the name of the default Web service that is created from Service1.asmx to MathService.asmx.
This is fine until you actually build the project and try and access the service on your localhost as it says to do in Step 7.

Browse to the MathService.asmx Web service page to test the Web service. If you set the local computer to host the page, the URL is http://localhost/MathService/MathService.asmx.
When the page loads I was met with an ASP.NET error along the following lines:

Server Error in '/' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not create type 'MathService.Service1'.

Source Error:


Line 1: <%@ WebService Language="C#" CodeBehind="MathService.asmx.cs" Class="MathService.Service1" >

Source File: /MathService.asmx Line: 1



The reason behind this was that even though I had changed the name of the service I had not changed the code in the .ASMX file to point to the new codebehind. Therefore you need to right click on the .ASMX file in the project explorer and choose the "View Markup" option. Once that is open just change the code to point to the new class like so.

<@ WebService Language="C#" CodeBehind="MathService.asmx.cs" Class="MathService.MathService" %>


Incorrect location for the web service

The knowledge base guide I was following said that the web service would be located on my local machine at the following location:
http://localhost/MathService/MathService.asmx

However when trying this gave me a 404 error. So instead after building the application I clicked the play button which took me to the following location:
http://localhost:1271/MathService.asmx

As you can see this differs due to the port number and missing sub directory. I am pretty sure I haven't missed any steps out along the way and the namespace for my Web Service was setup correctly so I am not sure why this differs from the example.


Creating a Consumer application for the web service

The previous step was important because the next part of the guide was on creating a consumer console application to make use of the web service.

In Visual Studio you select the "Add Service Reference" option from Project menu and then click the "Advanced" button.

On the next page choose the "Add Web Reference" button at the bottom and then on the next page you need to enter the location of your web service in the "URL" box at the top and then hit the little green arrow to the side of it. This will search for the reference at the specified location.

Make sure you know where the web service is located before trying this as the location of my own local web service was not where the knowledge base article said it would be:
http://localhost/MathService/MathService.asmx
instead it was located at
http://localhost:1271/MathService.asmx
Once the web service is found you can add it in the normal manner.

After that change, a re-save and a re-build everything worked fine.

Hopefully this might help others out there who are following the same guide if they run into the same problems.