Archive for November, 2004

Don’t underestimate the value of a good debugger

Monday, November 29th, 2004

This morning I followed a trail of breadcrumbs…

Aq pointed me at Simon’s complaint about downloading Eclipse and Ned’s comments about just writing code, which led me to Oliver’s The IDE Divide and Bob’s response.

As stated numerous times, I am a big fan of Visual Studio .NET, as I believe it makes me faster. This is because of its:

  • Syntax Hightlighting
  • Documentation (especially inline)
  • Code completion (to a lesser extent)
  • Visual Debugging

The last entry on that list is my main reason for using an IDE. Being able to step through my code, set breakpoints, evaluate/modify variables and see exceptions as they happen is worth the money (or not as the case may be) to me. Combined, all of the features make me a faster developer, but it’s manual debugging and minor syntax errors that really slow me down.

Since really getting into Mono coding, I’ve mainly been using vim and gedit combined with Monodoc and the command line Mono tools instead of MonoDevelop. Part of this is habit – MonoDevelop was slow and unreliable under my old FC2 install – and part of it is that it doesn’t add a huge amount of benefit if you are used to using make (which I even use for Delphi projects on Windows!). But if it had a built-in visual debugger, it would be top of my list.

In the past I was (to use Oliver’s terminology) a tool maven – I would hop from IDE to IDE, try plugins to get the most out them, and choose my languages based on their IDE (which is why I never really got into JavaScript). These days they’re just electric screwdrivers to me – they do the job faster, but you don’t need them.

Mono on Ubuntu

Sunday, November 14th, 2004

Spent a little while figuring out the correct incantation to get Mono installed on Ubuntu so I thought I’d post it as a reminder for myself (and possibly as an instruction for others).

Step 1.

Enable the universe repository (see here for instructions if you’re really not sure how to do that).

Step 2.

Do the following from a terminal:

 $ sudo apt-get install mono monodoc libgnome-cil

Updated
It turns out libgtk-cil doesn’t provide all the dependencies you need to run monodoc (and possibly other applications) – using libgnome-cil does provide them.

NB: This is based on the Debian install instructions in Mono: A Developers Notebook but the gtk-sharp package has been renamed (this will also apply to Debian unstable).

Step 3.

There is no step 3. Don’t you just love apt-get?

Mono WebServices - Part 2

Sunday, November 14th, 2004

On a roll here…

I’ve converted my Mono -> MySQL demo page to exist as web service as well. Essentially the same background code, just with a bit of abstraction and the ASP.NET web service syntactic sugar.

So, now you can read a list of blog entry titles into your own application! Well, as long as your language-of-choice supports DataSets that is.

To re-hash some of the instructions in my previous post:

Generate a proxy client with:

  $ wsdl -n:Schwuk http://schwuk.com/wip/titlelist.asmx?wsdl

Save the following as TitleListClient.cs:

 using System;
 using System.Data;
 using Schwuk;

 class MainClass
 {
   public static void Main(string[] args)
   {
     TitleList ws = new TitleList();

     DataSet ds = ws.GetTitles();

     foreach (DataRow row in ds.Tables[0 ].Rows)
     {
       Console.WriteLine(row[1 ]);
     }
   }
 }

I’ve had to include some extra spaces in that code to make Textpattern play nicely…

Compile with:

 mcs -r:System.Data -r:System.Web.Services TitleListClient.cs TitleList.cs

That’s it. No MonoDevelop project this time, but you can get a pre-compiled executable if you’re feeling lazy…

Mono WebServices

Sunday, November 14th, 2004

Whilst converting fellow CLUG’er Mark to Mono (on Windows no less!) last night, I decided to revisit my promise to publish my ‘Hello’ web service. Whilst chatting to him, I re-coded it as a Mono ASP.NET Web Service which can be seen here.

Writing the Web Service

My web service ‘page’ consists of one line:

 <%@ WebService Language="c#" Class="Schwuk.HelloWorld" %>

Whilst my web service ‘logic’ (code behind as usual) consists of:

 using System;
 using System.Web.Services;

 namespace Schwuk
 {

 [WebService(Namespace="http://schwuk.com",Description="Very simple test webservice")]
         public class HelloWorld : System.Web.Services.WebService
         {
                 [WebMethod(Description="Says Hello")]
                 public string SayHello(string Name)
                 {
                         return String.Format("Hello {0}", Name);
                 }
         }
 }

This is compiled with:

 $ mcs -t:library -r:System.Web.Services -out:bin/HelloWorld.dll HelloWorld.cs

Consuming the Web Service

The easiest way to consume the web service is to use it’s WSDL file (you can find mine here) to create a proxy client.

You’ve got two ways of doing this from Mono/.NET:

  1. Use the proxy client generated by the web service itself
  2. Generate a proxy client using the WSDL tool

Since the first option is pretty self explanatory, I’ll quickly demonstrate the second option.

 $ wsdl -n:Schwuk http://schwuk.com/wip/HelloWorld.asmx?wsdl

This generates a HelloWorld.cs file that can be included in your project. I specify a namespace with the -n: option, but that’s optional.

Demonstrating the Web Service

I re-implemented my original HelloWorld app as HelloWorldClient using this new web service. You can grab the MonoDevelop project here or the client itself in the following forms:

Here it is running on Linux:

and here running on XP (courtesy of Mark):

This is the same executable – no recompilation was required.

Powered by Mono?

Friday, November 12th, 2004

OK, it’s not true yet, but it will be…

I’ve decided to live by the phrase

Eat your own dog food

and switch my personal site over to Mono. I can hardly go around extolling the virtues of Mono for web applications when I run a PHP-based CMS can I?

Of course it is very early days yet, and I’ve got a long way to go before I can replace Textpattern fully. What I can do though is re-implement the presentation layer, so that is where I have started…

Show me something!

After some experimentation today. I have now got an ASP.NET page up and running that talks to my MySQL database that stores the Textpattern data. You can view it here – go try it out!

Update

I’ve revised the page somewhat, blending it with the rest of my site, adding more information and changing controls.

Decisions, decisions

I’m not sure whether I’ll remain with MySQL – PostgreSQL provides the features (Stored Procedures, Triggers) that I’m already used to developing with/for on MS SQL – it seems stupid to me to go back to building SQL statements on the fly. I know MySQL has/will have these, but PostgreSQL has them now.

Besides, if I make that switch I can keep the LAMP acronym – it will just mean Linux Apache Mono PostgreSQL instead of Linux Apache MySQL PHP/Python/Perl. :)

More Mono on Ubuntu

Wednesday, November 10th, 2004

If you want any of the following:

…but can’t be bothered to compile them, you can get them from:

http://www.getsweaaa.com/~tseng/ubuntu/debs/

Enjoy.

User Friendly

Wednesday, November 10th, 2004

Had to post about this…

Following on from my recent experiences with printing in Linux I’ve just had cause to print from Ubuntu for the first time.

It worked.

First time.

I was well and truly gobsmacked. I fired up the printer configuration tool and select “New Printer” thinking “here we go”, and it came straight up with my printer. All I had to do was select a driver and confirm paper size etc.

Wow.

Do the Jigdo

Tuesday, November 9th, 2004

Due to my lack of broadband, I got my ADSL-enabled friend to download the Ubuntu install CD for me. He delivered it last night, and I attempted to install today

Not good – CD was truncated, and I blew away my FC2 install for Ubuntu. Not good at all.

Since re-downloading was not an option, I decided to see if I could ‘repair’ the CD.

Bear with me – it’s not as daft as it sounds…

Enter Jigsaw Download or jigdo to its friends. Jigdo downloads an ISO file by file. You can also use it to patch or repair an existing ISO by telling it to pull valid files from the CD/ISO and retrieve the rest from the ‘net. How cool is that?

So I now have a working install CD, and a working intall of Ubuntu!

Ubuntu, Ubuntu…

Tuesday, November 9th, 2004

…they drink it in the Congo…

Plagarised from LugRadio Episode S2E2 – go listen

Replaced my FC2 install with Ubuntu today – so far so good…

Open Source .NET Development

Tuesday, November 9th, 2004

I said in my review of Coder to Developer:

My only real criticism is that when discussing various tools to help with the various tasks, the emphasis is placed on the authorĂ¢??s favourite commercial tools over the Free/Open alternatives. While this may suit some people, I disagreed with it and made me feel as though parts of the book are more advert than advice.

There now seems to be the book I was hoping for – Open Source .Net Development: Programming with NAnt, NUnit, NDoc, and More (it’s on my wishlist if someone wants to treat me!). If this book is as good as I hope it is, then I will be buying copies for the other developers on my team.

My only comment (without reading the book) is:

Do they mean “Developing Open Source with .NET” or “Developing .NET with Open Source”? Hopefully it’s both…