Mar 16 2008

It’s not my problem

Category: ProgrammingPhil @ 11:33 pm

I was MC at my sisters’ wedding recently and whilst I didn’t have a great deal to do with the planning of the wedding, I was around when my I overheard my sister talking about a particular aspect of the wedding plan. The problem was that the venue for the wedding reception was around a 30 minute drive out of town which meant that people either had to drive to the venue and not drink, arrange a designated driver or get a cab which would end up being at least $50 back into town. My sister couldn’t decide if she should hire a bus or not so people wouldn’t have to worry about organising transport home. This then snowballed into questions about if they did hire a bus, should they have it run a couple of times during the night, should it drop people off at their houses or just at central locations, which routes should it take, when should it start running, what happens if people miss the bus and on and on the questions went. The solution to the problem was fairly simple in the end. I explained to my sister that it simply wasn’t her problem. It wasn’t her problem how they arrived at the wedding, it wasn’t her problem how they got home from her wedding. All she needed to concern herself with was ensuring that there was a wedding for them to enjoy between the time they arrived and the time they left.

So what does all this have to do with software development? Well my sister thought that because this problem was somehow related to her wedding, she was responsible for solving it. Similarly, developers often think that because problems have something to do with their application, they are required to write code to solve it.

This isn’t always the case.

As a software developer, you need to constantly be aware of the problem you’re working on and be constantly asking yourself is this my problem to solve?

One example is a company I worked for insisted on getting their applications working in Firefox. This in itself isn’t a crime, except that the standard operating environment within the organisation stipulated that Internet Explorer was the only supported browser. So the developers within the company were spending hours working on getting an application to work that they didn’t even support. The solution to the problem had nothing to do with the developers and everything to do with the managers explaining that we don’t support Firefox.

Another situation is a client of mine wanted to make sure that a payroll application I was building allowed staff to go back and adjust the pay figures from previous pay runs. This was not desirable because it meant that the numbers for the outgoing pay wouldn’t match the actual outgoing pay. To ensure that the payrun data matched the outgoing pay data, it would require some extremely time consuming checks and rules to ensure that people got payed the correct amounts. After a quick discussion with the project manager he went off and implemented a new set of business rules that clearly stated that pay run data was not to be modified once a pay run had been complete and that any pay modifications had to be entered in as manual adjustments in future pay runs. It was a 15 minute decision that saved 2-3 days of development time.

Both these situations highlight the importance of realising that as developers, yes our job is to solve problems, but we should only be using our code so solve our problems and that it isn’t necessarily a bad thing to say “I’m not coding a solution to this because it’s not my problem”


Mar 16 2008

Officially an Iron Speed MVP

Category: ProgrammingPhil @ 12:40 am

Well some exciting news for today’s post. I was officially made an Iron Speed MVP last week which makes me the first Iron Speed MVP in Australia. It’s pretty exciting and hopefully it will lead to some great opportunities to work with some new clients’ long term. I have to say a big thank you to Brooke and Jeremy from the Iron Speed team who helped with my application process.

So what does it mean to be an MVP? Well for starters you get a snazzy little web page on their website which gives you some exposure as a preferred Iron Speed developer, but it also means a few other things that hopefully I can use to my advantage.

More importantly, it means that Iron Speed have recognized that the quality of work that I produce with Iron Speed and the level of competency I have with using Iron Speed as a development tool means that you can have a high level of confidence in the applications I build using Iron Speed. So whether you need a little extra help to finish off that Iron Speed project or would like a complete consulting package, please contact me and we can discuss your options.

In addition I can now run training courses, which I hope to get started sooner rather than later once I get the details finalized with the Iron Speed team. In the meantime, if you’re an Australian Iron Speed Client and are looking for some hands on training, feel free to contact me and I’d be more than happy to arrange some training materials for you.


Mar 12 2008

AJAX Google Maps for ASP.NET

Category: ProgrammingPhil @ 11:10 pm

Google maps have become a very useful tool for web developers wanting to display map based information to users. One of the easiest sets of controls to use to display Google maps is the package released by Subgurim. I’ve attached a very basic demo project that you can use to see how you can use a ModalPopupExtender to display Google Maps. For this demo to work, you might need to setup the following:

  1. First you need to download the GMap.dll file and the AjaxControlToolkit
  2. Then you should open visual studio and add the GMap control to your toolbox. It’s pretty easy to do, just right click on the toolbox, select “Choose Items” and then navigate to the place where you downloaded the dll. Select the GMap control from the list and click “Ok”

  3. Do the same with the AjaxControlToolKit to add those to your toolbox.

Here are some screens from the demo app:

 

Download Google Maps AJAX Demo


Mar 07 2008

Database Version Control Process

Category: ProgrammingPhil @ 9:56 am

Since reading Jeff Atwood’s post on Getting your database under version control I’ve wanted to investigate just how hard it would be and how best to achieve this process. I also read the recommended posts from K. Scott Allen which he refers to in his post to get a general idea of what I should be trying to achieve with my database version control but it all seemed a little too manual for what I wanted.

I checked out Jeff’s other post on database version control which highlighted the quality of the visual studio database tools, so I decided to check it out.

I’ve now got my first database under version control and will get the others up in the near future, but I thought I’d put how I version control my databases up on my blog.

First up, the tools I use are Visual Studio 2008 Team Suite for generating the database scripts and Vault for my source control repository.

Setup

Before I get into the actual change control process, here’s how I setup my database for version control.

  1. The first thing you have to do to get your database under version control, is generate a baseline. VS2008 makes this really easy to do. You go to File -> New Project ->Database Projects and select SQL Server 2005 Wizard

  2. After that, I just went through all the defaults except on the Import Database Schema page where I selected the database schema I’d created in SQL Management Studio

  3. After that VS Creates a nice bunch of scripts for your database schema. You have now created your baseline in around 2 minutes

  4. The final step of course is to check it all into Vault.

The Change Control Process

The change control process is just as simple as setting up your baseline schema in VS2008.

Checking In Changes To The Schema

  1. To check in changes to the schema you first have to do a comparison to get the differences in the schema. VS2008 Comes with a pretty decent schema comparison tool which will allow you to compare a schema from the database server directly with the schema in your generated scripts. To begin a new schema compare, you just go to the “Data Menu” -> “Schema Compare” -> “New Schema Comparison”


  2. Next you need to select your source and target projects. Now if you’re wanting to Check In changes to the schema, you need set your Source as the database that contains the changes and your target as your database project


  3. Once your schema comparison has run, you are then presented with a table that shows your list of items that need to be changed. You are also shown the change script that will be run on the database to implement these changes.
  4. All you need to do now is click the write updates button to write those changes to the database project.

  5. Once you’ve written the changes to the database project, you can check in your script changes to vault.

Propagating Schema Changes

To propagate the changes to the other developers is a simple task. All they need to do is run a get latest on the database project and do a schema compare. The only difference is that they will need to set the source to be the database project and the target to be the database that they want to update. All they then need to do is write the changes and they’re good to go.

And that’s all there is to it really. It took me about an hour to setup, test and ensure my procedure was solid, but now that I’ve got it setup, it will only take around 15 minutes to setup additional databases and given the benefits and how easy it is to do, there are just no more excuses as to why you shouldn’t be getting your databases under version control.

This is my first attempt at database version control, so I’d be interested to hear how others do it, and how I can improve my process.


Mar 06 2008

There’s more than one way to loop in .net

Category: ProgrammingPhil @ 12:43 pm

I don’t know if it’s because people are lazy, or if they don’t realise there’s another way to do it or what, but people seem to think that the only loop available to them in .net is the For loop. If I see one more For Each loop that get’s ended through the use of a break I’m going to blow up. I was browsing a code sample today and I saw this:

public static bool IsNumberBlocked(string phoneNumber)

{

    bool retval = false;

    if (BlockedNumbers.Contains(phoneNumber)) {

        retval = true;

    }

    List<string> sublist = BlockedNumbers.FindAll(EndsWith);

    string s2 = "";

    foreach (string s in sublist) {

        s2 = s.Substring(0, s.IndexOf("*"));

        if (phoneNumber.StartsWith(s2)) {

            retval = true;

            break;

        }

    }

     

    return retval;

}

Now this post was actually about the use of predicates to find elements within an array so I’m going to assume the author has a fair degree of coding competence, but how can you post code like that and be happy with it?. Surely a while loop was designed for this scenario

int i = 0;
    string s2 = "";
    while (i < sublist.Count & retval == false) {

        s2 = s.Substring(0, s.IndexOf("*"));

        if (phoneNumber.StartsWith(s2)) {

            retval = true;

        }

    }

It’s a classic case of give someone a hammer and everything becomes a nail and it’s not just confined to loops. If you’re performing code reviews and see this sort of rubbish going on, please fail the code review and inform the coder that there is more to loops than just For Each


Mar 05 2008

Iron Speed 5.1 New Features

Category: Iron SpeedPhil @ 3:36 pm

Well Iron Speed launched their latest version of their Iron Speed Designer 5.1 and I thought I’d comment on two of the new features that they included, but weren’t necessarily covered in too much detail in the release notes.

  1. You can now launch visual studio 2008 by clicking Ctrl + Shift + V and it will open the page you are currently working on in Visual Studio 2005 or 2008. This is an absolutely brilliant feature and I’ve already used it a bunch of times in the 2 hours since I installed 5.1
  2. Iron Speed has been able to detect changes to the .html files for a while now, but it always baffled me as to why it couldn’t detect changes to the corresponding .vb/.cs files.



    They’ve now included the ability to detect changes to the codefile you are working on and optionally select to reload it in Iron Speed. I can’t remember how many times I’ve blown away changes because I forgot to refresh the code file.

I’ve been using Iron Speed since version 4 and I’m glad to see that they are continually developing their product and putting those nice finishing touches on to help make the users life easier.

The full feature list is available from their website.


Mar 03 2008

Iron Speed and Infragistics Tab Control

Category: Iron SpeedPhil @ 9:32 pm

Iron Speed has the ability to add Infragistics tab controls as a code customization to your web application. The problem with the default implementation is that it uses the URL property to specify the content for the tab. This is ok if you want to display static content within your tabs, but makes it hard to interact with the content within the tabs.

An alternate method to using the URL property of the tabs is to define <ContentTemplate> within the tabs and place user controls within the content templates. The advanelemente of this is that the usercontrols are rendered to the page which means you are able to interact with them.

The aim of this tutorial will be to add an Infragistics tab control to an Iron Speed page and place user controls within those tabs rather than using the Target URL property.

The first thing to understand about the Infragistics tab control is the tab control hierarchy. I spent a bit of time in the documentation and the examples there are really quite poor at explaining how you can add controls to infragistics tabs.

At the top of the hierarchy, is the <igtab:UltraWebTab> element which declares the Tab control on the ASPX page.

Next element is the styling elements which define what each of the tab states will look like. These are:

<DisabledTabStyle />
<DefaultTabStyle />
<HoverTabStyle />
<SelectedTabStyle />
<DefaultTabSeparatorStyle />

I won’t explain too much what these do now, however later on I will define some styles for my tab controls.

The next element in the hierarchy is the <Tabs> element. This element is the key to the Tab control as it is where you define your tabs and tab layouts.

Under the <Tabs> element you have a child element called <igtab:tab> which has another child element called <ContentTemplate> This is where you define your user controls, or any other html you want to appear in the tab.

Let’s take a look at a defining a basic set of tabs within an Tab control.

<igtab: ultrawebtab id=”MyWebTab” runat=”server” SelectedTab=”1″>
<Tabs>
<igtab:tab text=”Employee Details”>
<ContentTemplate>

<h2> Employee Details </h2>
</ContentTemplate>
</igtab:tab>
<igtab:tab text=”Address Details”>
<ContentTemplate>
<h2>
Address Details </h2>
</ContentTemplate>
</igtab:tab>
</tabs>
</igtab:ultrawebtab>

This simple code will define a very simple tab control with 2 tabs. As you can see, the tabs are defined under the <Tab> element using the <igtab:tab> element. Within each <igtab:tab> element there is a content template element which has some basic HTML within it.

Now that you have some basic tabs defined, you can place whatever you like into the <ContentTemplate> element including Iron Speed record and table controls. All you need to do is drag a code driven tab control onto the page from the toolbar as shown below

and then modify the html. all you need to do is copy your table control HTML into the <ContentTemplate> of the tab and it will render perfectly in your web browser. Here’s an example from an application I have been working on recently:

<igtab: ultrawebtab id=”MyWebTab” runat=”server” SelectedTab=”1″>
<Tabs>
<igtab:tab text=”Employee Details”>
<ContentTemplate>

<h2>Employer Details</h2>
<div class=”wizardTable”>
<GEN:RECORD NAME=”EmployerRecordControl”>
<!– Begin Record Panel.html –>
REST OF DESIGNER GENERATED CODE GOES HERE
<!—End Record Panel.html–>
</GEN:RECORD>
</div>
</ContentTemplate>
</igtab:tab>
</tabs>
</igtab:ultrawebtab>

Also, it’s really easy to work with these controls all on the same page because Iron Speed doesn’t render them in tabs, but just renders the HTML output. In the image below, I’ve actually got 2 controls defined in two tab controls but only the HTML is rendered so you can work with the controls really easily

The best part is that because your controls are all defined on the same page, the save button has access to all the controls within the tab so when you hit the save button all your controls defined in the tabs will also be saved.

Here’s some screen shots of what the tabs look like within my application:

The first tab in my application

The second tab in application.

So as you can see it’s really easy to use Iron Speed controls and nest them within Infragistics tabs.