Chris McGrath’s Blog

Just another Developer’s Blog

Archive for July 2009

Another cool thing about chrome

leave a comment »

Chrome is a great example of how an user interface should be done. There’s so many small things about it which are so useful. My current favourite is the ability to resize text areas (aka multi-line textboxes).

They put a subtle gripper on the corner which you can grab and increase the size.

I can’t believe how many sites provide you with ridiculously small text areas. They ask for a detailed description then give you 3 lines with enough space for maybe 40 words. Of course a scroll bar appears but they’re annoying with only 3 lines.

I hope all other browsers copy this function, it is a brilliant idea.

Advertisements

Written by Chris McGrath

July 29, 2009 at 2:13 pm

Posted in Blog

Tagged with , ,

The worst thing about Batch files

leave a comment »

Date manipulation. So very painful. Not only do you have to do the annoying string manipulation dates are made worse by something else – stupid formats. I’m Australian and I believe in the 2 logical formats for dates day-month-year and year-month-day. It makes sense – smallest unit to largest unit or largest to smallest. But then there’s the American format of month-day-year. Seriously how does this make any sense to anyone? why not we change general numbers to act like this, 842 can become 824 (hundreds-ones-tens).

Anyway, it’s this fact which makes it really annoying. The batch date doesn’t allow you to enter the format you want it outputted as. So if I extract the values to a day, month, year variable then put it on a computer which doesn’t have the same format it doesn’t work.

Luckily we now have Powershell which allows us to manipulate objects instead of strings. Thank you for logic.

Written by Chris McGrath

July 28, 2009 at 12:59 pm

Posted in Blog

Tagged with

Application Data

leave a comment »

I’ve never really got Window’s AppData concept. Local, LocalLow and Roaming. What the hell do they mean. Admittedly, I haven’t bothered researching it much, but to me how it should be handled is quite clear.

Some background…

I’m a big believer of 2 partitioned systems – the system partition and the data partition.

The System partition holds the windows files and program files, while the data partition obviously holds data including the desktop and documents folder. The most important part of the system partition is that it should be treated as volitle – I should be able to format it at any time and not lose any data.

This makes it great for create an image of the drive – if something goes wrong, I can restore it and have a fresh install without losing any data.

There is one problem with this and that’s the AppData.

From the name AppData you’d think that it should belong on the data partition. And definitely some does belong there, but it is used for so many other thing that could potentially be causing the problem you want to restore your image to get rid of. As such we have to leave it on the system partition.

And how it should be done…

AppData should be treated to support this distinction between Applications and Data. So AppData should be divided into…

  • Volatile App Data
  • Non-Volatile App Data

Volatile App Data would remain on the system partition and Non-Volatile on the Data Partition.

A great example is a web browser. A web browser has temporary internet files since they are temporary they are volatile. But they also have bookmarks which the user will want to keep. Also I want to keep a history of where I have been so that should be non-volatile.

This system is very clear what the meanings are. It is also an important step in what I consider a critical issue – the standardisation of the 2 partition system.

Written by Chris McGrath

July 26, 2009 at 12:21 pm

Posted in Blog

Tagged with , ,

Grids suck

leave a comment »

I’ve heard a lot of people ask, “What is the benefit in moving to WPF? I’m just making a plain line of business app I don’t need any special effects.”  Well I think that using WPF there is one thing that it really makes stand out – Grid suck.

I know all you winform enthusiasts out there are saying, “Have you seen the DataGridView? I can create a list in seconds.” Well I’ve got news for you DataGridViews suck too.

I’m not talking about from the programming point of view, you’re right nothing compares to the DataGridView for quickly showing data. The problem is from the user experience point of view, it’s ugly and anything more than three columns is really hard to use.

So here is the big problem with WinForms, it’s hard to create “ViewAll” screens without using a DataGridView, as such you don’t bother with anything else. So if you want a reason to change to WPF, you no longer need the DataGridView.

Instead of Grids WPF focuses strongly of List Items. You provide a template for one item – and it’s as customisable as you like, any control can go in it, you can use multiple lines – and it repeats that template for every item in the list.

Written by Chris McGrath

July 18, 2009 at 6:03 pm

Posted in Blog

Tagged with , , ,

A really sneaky SQL join problem

leave a comment »

I was creating a query the other day and it wasn’t returning the amount of rows I was expecting. I did quickly figure out what was causing me but how to solve it stumped me. Luckily a co-worker who was much more experienced with SQL knew how to fix it. But it’s a case that those of us who don’t live and breath SQL probably don’t know about and it’s so easy to get this wrong all developers should be aware of it.

Here’s the problem…

You have a person table and a phone number table. A phone can be work or home. In the person table there is John, Michael, Chris and Dan. John has neither number entered. Michael has both entered, Chris just has work number entered and Dan has home number entered.

You want to display a list of every Person and if they have their work number entered, to grab that as well, else null.

Easy right? How about giving it a go?

Did you come up with this…

select Person.*, Phone.Number
from Person left outer join Phone on person.id = phone.personid
where Phone.Type = ‘w’ or Phone.Type is null

That was easy, the left outer join stops the person row from disappearing if no phone number exists and we get rid of the home numbers through the where – we are also careful not to remove the items without a phone number with a “OR IS NULL” check.

Well you’re wrong. If you were to run it only 3 of the 4 people would show up. Can you think why? Here’s a clue, the person would be Dan.

If you still haven’t got it, the Dan rows that exist before the where is just when type = ‘h’. It doesn’t have a null value their like John has. So the where then says, “is it w? is it null? well get rid of it.”

But how do we fix this? It doesn’t look like we can, our check is happening too late we want to filter the phone table and then outer join it. Not possible? Must require some complex subquery? Well actually it doesn’t…

select Person.*, Phone.Number
from Person left outer join Phone on person.id = phone.personid
AND Phone.Type = ‘w’

That’s it. We move the check inside the join.

It’s quite a nice solution for it really. I think as long as you are aware of this you won’t have any problem but I do wonder how many bugs are out there exist because this wasn’t taken into consideration.

Written by Chris McGrath

July 17, 2009 at 9:10 am

Posted in Blog

Tagged with ,

The facebook phone

leave a comment »

I’ve been thinking about the future of phones lately, mainly mobiles and it has lead me to some interesting ideas. Pretty much at the moment the phone companies are ripping us off. And like many I think it is inevitable that mobiles will become voip phones and we will be charged for data not calls. But that’s an evolution of mobiles, how can we create a real revolution?

I think the revolution will be a merger with a fast evolving trend – social networking. I’m not talking about second class apps or sending sms messages which go on your profile, I’m talking about making the social network the primary purpose of the phone.

I see this as completely replacing phone numbers. The profile represents the person instead of a number. And since I’m calling a person not a number, I don’t care how it is answered. You could answer using your mobile, or on your computer.

And just imagine the integration this brings. When you call me I could see your latest status update, maybe see where you currently are.

I think this would push social networking to a level where it is completely integrated with your life.

But which social network, since phone carriers will most likely oppose such an idea it has to be a well established site. That really gives us three options. MySpace, facebook and twitter.

MySpace I don’t see this working for, and it’s dying fast. If they did invest in this it could save them (and put them back on top) but I don’t see this happening.

Twitter has potiental. It’s very much written as a service instead of a website, which gives it an advantage over facebook. The thing is twitter is great because it is simple, it says with tweets and doesn’t add anything else. So such services would need to be third party (like twitpic). This gives it an advantage of not one company being responsible for it all (which is anti competitive) but I question the reliability and how we can really integrate everything with it.

Now Facebook seems to be the clear winner. Huge user base, lots of functionality we want already. But there is one thing which really makes facebook the winner. On Facebook you are identified by your name. It seems simple but this really setup how facebook would be used. And it’s that culture a social networking phone needs. I don’t want to see that I’m getting a call from BuZzKill337, I want to see I’m getting a call from Greg Black.

If I was facebook this is what I would be investing in. It truly is a system that could make facebook one of the biggest companies in the world.

Written by Chris McGrath

July 15, 2009 at 1:46 pm

Posted in Blog

Tagged with

To anyone distributing an installer online…

leave a comment »

Please don’t call your installer Setup.exe. It might be fine when initially installed but people will forget what it contains within a week. And clearing out your downloads folder is really annoying when you have no idea what an file is. This especially goes out to the Microsoft Virtual PC team.

Written by Chris McGrath

July 13, 2009 at 3:23 pm

Posted in Blog

Tagged with ,