Tuesday, February 27, 2007

Sometimes technology is fantastic

I am writing this on my new Macbook Pro, using an HTC Apache EVDO phone connected via Bluetooth as the internet connection.

The Apache is a great data device / PDA - not so good as a phone - bit big. The fact you can use it as a modem is good. The fact that you can use it via Bluetooth as a modem is great. The fact that it all works with the Mac is fricken brilliant. I was a bit worried about switching to OSX that things like this wouldn't work (I have been tainted by bad experiences with Linux) but so far so good. OSX has just about every app I use on Windows or an equivalent.

It's a little mind boggling really if you think about how far the technology sector has evolved. The computer industry has been really only around since the mid/late 70's. How many other industries have moved so far in so little time. If the automotive industry for example moved at the same pace, just imagine what sort of vehicles we would have today - certainly wouldn't be tied to fossill fuels for one.

Anyway for today anyway, mark one up for technology actually working and being useful!

Thursday, February 22, 2007

New tools from CodeGear

Codegear the new name for the development arm of Borland have announced a couple of new tools:

Delphi 2007
Delphi for PHP

The D2007 release is, from what I can tell, a release of Delphi to that includes Vista support and some refactoring of the Database connection components. I don't do much Delphi anymore, so not terribly interested, but will check it out.

The other one, Delphi for PHP, is a little more interesting to me. I don't currently do PHP - I do ASP.NET, but am always keen to see how other technologies work.

All in all, I think a positive couple of announcements from CodeGear. It seems to me they are concentrating on areas they can actually compete. Their Java toolset has been moved over to Eclipse which is a good thing, and they appear to be concentrating on Win32 for Delphi.

I think this is a good move. In all reality they can't hope to compete with Microsoft when it comes to .NET. They are just too far behind the 8 ball, always a release behind. For example the latest Borland Development Studio 2006 uses .NET 1.1. Concentrating on Win32 which a lot of people are still keen to develop for, and looking at new areas - Delphi for PHP, I think they just might be able to create a good niche for themselves.

Tuesday, February 13, 2007

Design Patterns in C#. Part 1 Singleton Pattern

Design Patterns are a useful part of software development reuse. Design Patterns introduce a common problem and common solution to said problem. DP's are usually broken into 3 categories:

Creation Patterns:
As the name suggests, deals with the Creation of Objects
Structural Patterns:
Ease design by identifying a simple way to realize relationships between entities
Behavioral Patterns:
Identify common communication patterns between objects

Design Patterns are bigger in the Java world than they are in the .NET world. It's only in the last couple of years that I come across design patterns and their usefulness.

The most common design pattern, and the easiest to understand is the Singleton Pattern.

The definition of the Singleton Pattern is, "Ensure a class has only one instance and provide a global point of access to it."

Which means that the class will only allow one instance of itself to exist. We do this by hiding the constructor of the object and publishing a public method to instantiate the object.

Example:

namespace Singleton
{
  class Program
  {
    static void Main(string[] args)
    {
      ClassicSingleton s1 = ClassicSingleton.CreateInstance();
      ClassicSingleton s2 = ClassicSingleton.CreateInstance();
      //if new classes were being created, values should both be 1
      Console.WriteLine(s1.CountValue());
      //if singleton works then should output 2
      Console.WriteLine(s2.CountValue());

      Console.Read();

    }
  }


  public class ClassicSingleton
  {
    private ClassicSingleton(){}

    private static ClassicSingleton instance;
    public static ClassicSingleton CreateInstance()
    {
      //if instance doesn't exist create new instance
      if (instance == null)
      {
        instance = new ClassicSingleton();
      }
      return instance;
    }

    //small method to prove only one instance gets initiated
    private int counter = 0;

    public string CountValue()
    {
      return (counter += 1).ToString();
    }
  }
}

The above example is using the classic singleton approach. As you can see it is fairly straight forward and easy to understand.

This example is fine in a single threaded case, but in a multi-threaded application it is possible for an instance to exist on separate threads. To eliminate this issue we change the CreateInstance method to include a lock and another check:

public static ClassicSingleton CreateInstance()
{
  //if instance doesn't exist create new instance
  if (instance == null)
  {
    lock (typeof(ClassicSingleton)) ;
    if (instance == null)
    {
      instance = new ClassicSingleton();
    }
  }
  return instance;
}

These two above examples are using fairly standard approaches to creating a Singleton Pattern and is how you would probably expect to see things in the Java world. C# creators (and VB.NET too) new about Design Patterns when they were creating the language, and added a few nice features that makes it easier to do things such as this. The below is a Singleton Pattern creation the .NET way:

sealed class DotNetSingleton
{
  private DotNetSingleton() { }

  public static readonly DotNetSingleton CreateInstance = new DotNetSingleton();

  //small method to prove only one instance gets initiated
  private int counter = 0;

  public string CountValue()
  {
    return (counter += 1).ToString();
  }
}

As you can see from above the .NET version is much simpler. We create a static readonly property of type DotNetSingleton. Because it is marked static readonly it can only ever have one instance of DotNetSingleton. Note the class is now a sealed class, meaning it can't be inherited.

I am hoping to introduce several Design Patterns in the next few posts, but there are also several great resources on the net.

Do Factory is probably a good place to start, but as usual Google is your friend!

Next time, the Factory Pattern.

Wednesday, February 07, 2007

Macbook Pro First Impressions

Well, it finally arrived. Was it worth the wait. F**K YES!

I have owned PC's in various guises since my first 386SX-20Mhz in 1991. Since then I have owned and used literally hundreds of PC's. I got my first laptop in 1999, it was an IBM Thinkpad and I thought it was Christmas. I have used every version of Windows since 3.0, and Dos 3.3 before that. I am a professional programmer who makes a living off using Microsoft products, and developing for Microsoft OS's.

So in summation, I am not some blatant Apple fan boy. I know the ins and outs of PC's better than most. The reason I am relaying this information is because I think from here on in, this post could get a little Pro Mac.

First Impressions:


The packaging is first class. Every little thing is thought of. The styrafoam packaging is classy, and laid out well. There is nothing in the box that doesn't need to be there. The power cables and adapter are a nice designer white. All in all the packaging is brilliant.

You turn the laptop on, and OSX comes up straight away. That is nice. Usually with a PC laptop, there is still some final installation that is required. Once the obligatory sign on stuff is dealt to, you are away.

Nice touches

It's the little things that make the difference. The power connector is magnetic so it doesn't rip the side of the laptop off, if someone trips over it. It also has a little LED on it that is red when charging and green when finished.
The Apple logo on the back glows, as does the keyboard when it gets dark. This is so you can use it in the dark and still see the keys.

Oh and the other cool feature I noticed right away - you push the off switch and it realises you want to shut down and brings up the shutdown/restart menu. Nice.

The touchpad understands gestures too. For example you can push down with one finger and scroll up and down with another, and it acts like a scroll wheel. Again just a little thing but nice feature non the less.

OSX
I haven't played enough yet to give a full appraisal, but so far I like it. Again it's the little things I like. The fact you don't need to click "OK/Cancel/Apply" when you change something in the System Panel. It realises that if you changed it, you meant it and you don't want to be bothered again.

The integration between OSX and things like iTunes and PDF documents is much better than Windows. I guess this shouldn't be a shock. The great thing about the MBP, is that it comes with a remote, that you can use when using iTunes, or playing a DVD, or showing a photo slide show. It swaps seemlessly between the fullscreen applet and normal OSX. It is instantaneous. I have seen a few other PC makers try this. My work Dell for example has a Media Centre, but it is slow and switching between Media Centre and Windows takes several seconds.

Annoyances
The single mouse button is taking a little to get used to, as is the command key. Also the touch pad seems to freeze when switching applications from time to time.

That's it so far!

Conclusion
It just works. That is the overwhelming feeling I am getting so far. It just works.

Tuesday, February 06, 2007

Black Craps end of tour report card

I just heard Fleming from the press conference from the dismal effort last night against the poms. He said something along the lines of, "We are on track. We feel comfortable where we are, and we are happy in the knowledge we ran Australia close with room for improvement".

Sorry. Happy getting close to Australia? Of course you have room for improvement, you lost every game. I can't understand this mentality. To me the tour was a failure. They failed to make the final, failed to beat Australia, and failed to stand up when it counted against England.

They've had "room for improvement" for the last 5 years. A sign of a good team is playing to your full potential every game. Not looking good getting to 20 odd and then getting yourself out, or dropping easy catches. If catches win matches, then we had no chance of winning. It was the worst display of field I have seen from the current team. The pride themselves on their fielding. The must have dented pride after this tour.

Anyway, here is my end of tour report card in batting order.

Stephen Fleming 2/10
Looked terrible with the bat, scored a hundred in the last game but that was too slow and cost us the game. Let things happen in the field too much.
Nathan Astle 2/10
Saw the writing on the wall and retired. His time had come.
Lou Vincent 7/10
Had the spark we need at the top of the order. Always competes, some other players could have his attitude. Live wire in the field.
Peter Fulton 3/10
Got a start in every game but didn't go on. Needs to sell his wicket a little dearer. Made some awful gaffs in the field too.
Ross Taylor 5/10
Has the makings of a genuine world class player, but needs to get a little more out of himself.
Hamish Marshall 1/10
If cricket ever bought in the pinch runner or fielder law, like baseball he would play every game, but otherwise is not an International player.
Craig McMillian 2/10
Did his usual by playing one good knock on tour. He should take advice from Nathan Astle
Scott Styris 5/10
Came in too late in the tour to be effective but is a crucial part of the team
Jacob Oram 8/10
Shining light of the tour with the bat, which has reached a new level this tour. Bowling needs work, but will come. Brilliant gully fielder.
Brendon McCullum 5/10
Glove work was pass mark, dropped a couple of catches. Not suited to the swinging ball at the top of the order, but can be a devastating finisher.
Daniel Vettori 7/10
Continually gets more out of himself than his ability would indicate. The rest of the team should look to emulate his attitude and aptitude. Would make a good captain.
James Franklin 4/10
Lusty blows with the bat, shouldn't disguise his bowling is up and down at the moment. Dropped several chances in the field.
Shane Bond (100%) 6/10
This is the Shane Bond that actually hits the pitch. Looked good when he did
Shane Bond (50%) 1/10
Looked very ordinary when not at full clip. Bowled a hit-able pace and length.
Mark Gillespie 6/10
Was the find of the tour. Needs more consistency going forward, but looks the goods - particularly at the death.
Jetan Patel 6/10
Made the most of his chances in the limited games he played.

So the average mark was 4 which is a fair result of the tour in my opinion.

Sunday, February 04, 2007

Apple Update 3

So, my Mac Book Pro didn't arrive overnight. Didn't think it would. It however didn't arrive this morning and courier run is usually around 10. Starting to get suspicious. Inquires have found out the the courier company has lost the thing. OMFG.

Man this thing better be good, with all the stress and agrivation it has caused. Someone out there just doesn't want me to have a Mac.

It really shouldn't be this hard.

Friday, February 02, 2007

Apple Update, erm, update

HN rang back, said there were non glossy screened one's in the warehouse in Auckland. I suggested they get one on a courier overnight.

So good work in the end. I finally found someone who was willing to get of their arse and help out, and go some way towards restoring my faith in shop assistants!

More to follow I'm sure when it arrives. Genuinely excited about it arriving, which I guess why I was so frustrated at the delays.

Apple Update

Ok so 3 weeks have passed and no Mac Book Pro. Harvey Norman just rang and said it is going to be another 3 weeks. That's it. I've had enough.

Dell may be unstylish and bland, but at least they can deliver in under 6 weeks.

Ratshit Customer Service

I have been stewing over this for a while. I just seem to keep running into really bad customer service.

It started at Harvey Norman a couple of weeks before Christmas. I went in to buy an iPod for my wife. I knew what I wanted, had the money and just needed someone to get one for me. I stood at the counter for 10 minutes, while the one person on duty at the counter talked to a guy who clearly wasn't going to buy anything. I got sick of that and went over to a bunch of employees who were standing around talking.

"Not our area", was the reply. So I left and bought one from Dick Smith.

I (foolishly) went back to Harvey Norman to purchase a laptop. To call the guy I talked to incompetent was a slight on people who are actually incompetent. This guy if he works at it, could aspire to be called incompetent. Anyway, I ordered the laptop (Macbook Pro) which was over $4000 worth of kit. 3 weeks have passed and I am still waiting. "I don't know when it will arrive", is the response I get whenever I try and find out about shipment date.

No one ever tries to call the Apple supplier (Renaissance I believe) and find out when it was shipped or an expected arrival date. They have my money now, I am of no use to them obviously. I mean how long would it take to at least look like you're doing something? The 5 minutes it would take to find out is obviously eating into their staring at the wall time, or more likely scratching their arse time.

That's ok. It will arrive eventually. Will I spend another cent in Harvey Norman? Not on your life. Even if the same item is more expensive somewhere else, I will never buy another item from Harvey Norman. Ever. People ask me all the time, "Where is a good place to buy X?". I can guarantee I won't be recommending Harvey fecking Norman to anyone. So five minutes making a phone call has potentially cost them a lot of money.

I was out of town this week sorting out a few loose ends for a client. I was walking to their office and went past a Starbucks. Thought I would try them out. It was about 7:30am and there were two staff, and one guy at the counter who was obviously a friend of the serving girl. I stood in line while they talked for about 5 minutes, said excuse me a couple of times, stomped my feet and walked out. So stuff you Starbucks, I am never going to step foot in your establishments ever again either.

It doesn't take much to offer good customer service. It doesn't cost much either. The cost of not giving good customer service can never be quantified of course, but I would imagine that one bad staff member could be costing a lot more than the minimum wage the employers are paying....