Can Of Code

To update, or not to update, This is the Question

Let me begin with my frustration with Fedora. A while ago I had decided in true geeky fashion to get a Linux Distribution, install it on a spare PC and have a little play. So I had a little play… well to be honest, I spent hours trying to install graphics card drivers, but that counts as play.

Anyway… A few weeks later i decided to go back to the spare PC and have another look around Fedora. I learnt that there was a new Release of Fedora OS. This annoyed me greatly!

Why? well as a user, it meant that I had to go and download the new version which was no easy tasks when you think these disc images are normally 4GB and my internet connection was around 1Mbps. That is a long time to wait and if I remember correctly I only had a 10GB download limit at the time, so it was also a risk. The second point of frustration was that I would have had to format the hard drive and lose my hours of Nvidia driver progress.

Updates, diffrent for diffrent people

So am I saying that Linux is frustrating? Well kinda, But the point I’m makIing is, How frequently should updates occur?

Firstly as far as i can see there are two methods of rolling out updates:

Nagging Updates

Restart or... restart, The choice is yours

The Nagging Update is one where you have to do something before it updates, Like in OS X when the little icon is bouncing up and down in your dock until you finally go insane and click it! Windows can be just as frustrating when it asked to restart after installing updates. It will pester you more and more frequently until you finally give in to it.

Home users hate nagging updates, because well… they nag and nag until you do something. To be honest the users don’t even have a clue what the update is for. So they have to do something even though they don’t have a clue why. Rather like if they were at work? The System Admin types like nagging updates as long as they can turn the nagging off and do some magical updating procedure in the middle of the night, pretty much turning them into ninja updates.

How frequently should I do nagging updates? This depends on how much you want to annoy your users? because who likes being nagged at. If you decide to go for a nagging approach, the less updates you have to release the better!

 

Ninja Updates

Ninja update in progress

Ninja update in progress

The ninja update is sneaky. When you least expect it, it will update your software and the first thing your know is something looks slightly different.

Your basic home user likes ninja updates because they don’t have to do anything. The key issue is, if something goes wrong, they wont understand why on earth its happened. System Admins hate Ninja updates because they are very protective over there software, they don’t want it updating itself without them doing some kind of testing to make sure this update doesn’t break everything.

Nobody really notices that a ninja update has happened so it doesn’t really matter how frequently it occurs. But of course you can still annoy users if your ninja updates keep moving the save button to different places because the development team cant agree where it should belong.

So we have now established that there are different methods of updating and each one will annoy a different type of user.. Great! 500 words down and I am yet to come up with a solid answer to how frequently you should release updates. But one key point we have discovered is, ninja updates can be done more frequently and nagging updates less so.

Posted in Uncategorised |

C# Quick Tip 1 – The Using statement

If you have ever dealt with C# enough to hook up to a database and use a DataReader you would of properly seen a Exception along the lines of “There is already an open DataReader associated with…”. You would get this exception  because you had forgot to close a previous DataReader somewhere, annoying right?

Well I had this problem a little while ago but it was happening because an exception was getting thrown which meant it skipped right past my .Close() call. It was at this point I found out about the joyous using statement.

So Here it is:

using (SqlDataReader reader = com.ExecuteReader())
{
       // Some Database reading
}

Its the same as:

SqlDataReader reader = com.ExecuteReader();

 // Some Database reading

reader.Close();

But… In the second example, if the code is within a Try..Catch and the wizzy database reading  code throws an exception. it will miss the .Close() statement and then you’ve got  to go and find out why.  The first example will automatically close the reader as soon as it leaves the block! which save you the pain! and I think it looks much cleaner then having .Close() statements everywhere.

If you enjoy reading the MSDN site here is a link to the using statements page

Posted in Uncategorised |

WPF – How To Create Image Rollover Buttons

Here is how to create WPF Rollover image buttons.

The way I achieved the rollover images is pretty simple, I create a ControlTemplate then add a Trigger  to change the background when the user moves the mouse over the button.

Here is the sample code:

<Window.Resources>
   <ImageBrush x:Key="RO1"
             ImageSource="/HTMLRolloverWPF;component/Images/4.ico" />
   <ImageBrush x:Key="RO2"
             ImageSource="/HTMLRolloverWPF;component/Images/3.ico" />

        <ControlTemplate TargetType="Button" x:Key="imageRoll">
            <Grid Name="gridy" Background="{StaticResource RO1}">
                <ContentPresenter  />
            </Grid>

            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter TargetName="gridy" Property="Background"
                                                Value="{StaticResource RO2}" />
                </Trigger>
            </ControlTemplate.Triggers>

        </ControlTemplate>
</Window.Resources>
<Grid>
   <Button Content="Button"  Template="{StaticResource imageRoll}" />
</Grid>

The first part of that XAML is where I create a ControlTemplate. You can place the ControlTemplate in
which ever Resources collection that is most relevant. I have also set the target type and given the whole thing a key.

The Next chunk of code is where we add a Grid to the ControlTempalte. We will use the grid to display the background. We set the background of the grid to a imagebrush resource we defined earlier in the resource collection.

Now for the bit that does all the work, the Trigger!  We set a trigger to activate when the “IsMouseOver” Property is True. Then we use a setter to change the background of the grid to our rollover ImageBrush which in the example is called RO2.

Its as simple as that!  If you don’t want to do a image rollover you can just change the background to a different colour which is just as easy.

Posted in WPF |