Stats for January 2008

Top 10 posts

Position Last Month Title Posting Date
10 New Entry Why is it so hard to hire good software developers? 19-Aug-2007
9 New Entry A simple challenge 22-Jan-2008
8 4 Follow up on hiring a software developer 19-Dec-2007
7 7 Getting started with Spatial Data in SQL Server 2008 01-Dec-2007
6 8 Visual Studio 2005 on Vista 15-Apr-2007
5 3 What is a DAL (Part 3) 13-Oct-2007
4 5 SQL Exception because of a timeout 17-Oct-2005
3 6 What is a DAL? (Part 2) 5-Sept-2007
2 1 What is a DAL? 28-Aug-2007
1 2 Internal Error 2755 caused by folder encryption 15-Oct-2006

Browser Usage

Position Last Month Browser Percentage this month Percentage last month Change
4= 3 Opera 1.01 4.17% -3.16
4= 5 Mozilla 1.01 0.58% +0.43
3 4 Safari 1.31 1.01% +0.30
2 2 Firefox 32.58% 29.33% +3.25
1 1 Internet Explorer 63.85% 64.85% -1.00

Location of Visitors

Position Last Month Location
10 New Entry France
9 6 Poland
8 New Entry Sweden
7 7 Germany
6 9 Netherlands
5 5 Australia
4 4 Canada
3 3 India
2 2 UK
1 1 USA

Solution: A simple challenge

For personal reasons I’ve not been very active in the last week or so. Therefore the solution I promised has been a bit late in coming.

Here is the “reference solution” for the simple challenge that I set last week. It is by no means the only solution, nor is it necessarily the best solution (depending on how you define “best”)

class Program
{
    private static void Main(string[] args)
    {
        Console.Write("Width:");
        int width = Convert.ToInt32(Console.ReadLine());
        Console.Write("Height:");
        int height = Convert.ToInt32(Console.ReadLine());

        DrawBox(width, height);

        Console.ReadLine();
    }

    private static void DrawBox(int width, int height)
    {
        // Work out the interior width and height (i.e. the width
        // and height of the space inside the box)
        int interiorWidth = width - 2;
        int interiorHeight = height - 2;

        // Work out what the top and bottom of the box should look like
        string topAndBottom = new string('*', width);

        // Work out what the interior rows should look like
        string interiorRow = string.Concat(
            "*", new string(' ', interiorWidth), "*", Environment.NewLine);

        // Work out the entire interior using the "trick" of defining
        // a string with a repeating character for as many rows as the
        // interior needs to be, then replacing each of those characters
        // with the pattern for a row of the interior.
        string interior = new string('-', interiorHeight);
        interior = interior.Replace("-", interiorRow);

        // Write the box to the console.
        Console.WriteLine(topAndBottom);
        Console.Write(interior);
        Console.WriteLine(topAndBottom);
    }
}
Technorati Tags: ,,,,

JetBrains Sponsors Developer Day Scotland

JetBrains, the makers of ReSharper and dotTrace, have sponsored Developer Day Scotland with 6 bundles of ReSharper and dotTrace to give away as prizes. That’s $550 worth of software to each lucky winner.

Developer Day Scotland, based on the highly successful Developer! Developer! Developer! events, is being held on 10th May 2008 in Glasgow.

The call for speakers is still open, but hurry, it will be closing soon!

 

 

 

A simple challenge

A homework question was posted on a forum recently. As usual it was met with the cries of “We won’t do your homework for you” (We will, of course, help if you get stuck. But don’t expect any assistance without at least trying first)

The assignment was to write a console application that accepted a width and a height from the user and then created a rectangle using asterisks. e.g. This might be the result of the program

Width:8
Height:5
********
*      *
*      *
*      *
********

Now the query was asked how to complete this using loops (or conditional statements, we weren’t really sure – he said loops, but proceeded to talk about if/else statements)

One of the responses was along the lines of “I can do this without loops”, modified to add “Or conditional statements”, and modified again to add “Or recursion”

So, my challenge to you is to write a small program above without loops, conditional statements or recursion. It sounds difficult, but it isn’t really. I have a solution (from which the example output above has been taken) which I’ll post this evening.

Technorati Tags: ,,,,

Creating Many-to-Many joins

A topic that comes up from time to time in forums is how to join two tables together when there is a many-to-many relationship. Typical examples include teachers-to-students or articles-to-tags (to create a “tag cloud”)

If you have made any relationships in a database you will see that it is very easy to create a one-to-many join. For example, a web forum may have many posts, but a post only belongs in one forum.

To create a many-to-many relationship you need to create an intermediate table. This is a table that each side of the many-to-many can have a one-to-many relationship with. The following diagram shows the many-to-many relationship between a blog posts and the tags on it (This is not a full model, just enough to show the relationship)

Many-to-many

The BlogPost has its primary key (BlogPostId), as does the Tag (TagId). Normally you would see that key being used as the foreign key in the other table, however that wouldn’t work with a many-to-many relationship.

In order to join the two tables together an “intermediate table” needs to be created that just contains the two primary keys from either side of the relationship. Those two foreign keys make up a compound* primary key in the intermediate table.

It is normal to name the intermediate table after the each table that forms the relationship. In this case it would be “BlogPostTag” after BlogPost and Tag.

In order to join a row in the BlogPost table to a row in the Tag table you only need to insert a new row in the BlogPostTag table with the keys from either side. e.g.

INSERT BlogPostTag VALUES(@blogPostId, @tagId);

In order to remove the relationship between a blog post and a tag you only need to delete the row from the intermediate table. e.g.

DELETE BlogPostTag WHERE BlogPostId = @blogPostId AND TagId = @tagId;

 

 

* a “compound key” is one which is made up of more than one column.

 

New Year! New Events!

It is 2008 already! Time really does fly as it only seems like yesterday when I was starting to plan out how to get user group events going in Glasgow and now I’m planning a conference.

I’m still in the process of putting an event schedule together for Glasgow for the upcoming year, so if there is any thing specific you would like to hear about then please let me know and I’ll try to find some speakers to talk on that subject. In the mean time we have one excellent event coming up this week and more in the works.

Wednesday 16th January in Glasgow (Evening)

Gary Short: My Favourite Design Patterns

He’ll show you what they are, what they are used for  and he’ll rustle up a coded example. If you’ve heard of design patterns and want to find out a bit more, or if you know about them already and just want to see how someone else does it, then this talk might just float your boat.

This talk is a repeat of the talk Gary gave at DDD6 where he got excellent feedback from the audience. We are in for a real treat on Wednesday evening and we’ve given Gary some extra time he didn’t have at DDD so this will be an even better extended version.

Tuesday 12th February in Glasgow (Evening)

Richard Fennell: Team Foundation Server

The talk will be on Team Foundation Server, but the exact aspect is, as yet, to be decided. The page linked to will be updated when the details are finalised.

Wednesday 13th February in Edinburgh (Evening)

Colin Mackay: Where’s my data? An introduction to Spatial Queries in SQL Server 2008

It is reckoned that 80-90% of data has a spatial component to it. But what do we do with it now? At best, we constrain it to postcodes. Well, that would be great if we were delivering letters, but the majority of us aren’t. In this session we look at Spatial Queries in SQL Server to see how it works and what can be done with it.

Martin Bell: SELECT TOP(@x) Name FROM MyFavouriteDMVs ORDER BY MyRanking

Dynamic Management views were introduced in SQL Server 2005 and have made management and troubleshooting of SQL Server significantly easier than in previous versions. Even if you do not write your own queries against these DMVs you may be using them in Performance Dashboard Reports or other performance reporting applications. In this talk I will go through my TOP favourite DMVs and show how and when they can be used and why I like them!

Saturday 1st March in Birmingham (All day)

SQLBits II (The SQL)

Following from the fabulous success of the first SQL Bits conference last year in Reading they are moving to a bigger venue in Birmingham.

Wednesday 5th March in Edinburgh (Afternoon)

Oliver Sturm: Business Apps with WPF – The Full Monty

Lots of demos of WPF show flashy UIs with animations and videos and trickery worthy of a Hollywood production worked over by ILM. Is that what your next business app is going to look like? Probably not. Nevertheless, WPF can do a lot for you, because it’s the most powerful and most productive UI platform out there. Full stop. This double session walks you through the whole process of creating a business application with WPF, focusing on how it saves you development time.

NOTE: This is a paid event. Prices start at £10 for members and £25 for non-members with the early bird discount.

Saturday 10th May in Glasgow (All day)

Developer Day Scotland

An event that is being run by the community for the community. Currently the call for speakers is open, so if you would like to submit a talk please just email me and let me know. In early February the voting opens and you will then be able to vote for the sessions you’d like to see.

Keep an eye on the Scottish Developers website for more information about upcoming events.

Developer Day Scotland - BY the community FOR the community - 10th May 2008 in Glasgow

 

[This is a copy of the Scottish Developers events newsletter I just sent out]

Design Patterns talk by Gary Short

Just a wee reminder that Gary Short will be presenting his excellent talk on Design Patterns on Wednesday 16th January.

I don’t just say it is excellent just to encourage you to go, although I do encourage you to see this presentation. I have good (some might say excellent) cause to say this and I have the numbers to back it up. Gary has recently released the scores he got when he did this presentation at DDD6 in Reading last November and they are, to say the least, impressive. You are in for a real treat with this session.

The full details are here.

DDD6 Feedback

Well, I’ve received the feedback from my session at DDD6 and here it is:

Overall: 3.73
image
Knowledge: 4.13
image
Presentation: 3.93
image
Content: 3.4
image

 

By the looks of it, the session was quite well received by most people. As you can see from the Histograms there are a small number of people who obviously really didn’t like it, but you can’t please everyone I suppose.

I also received some text comments to which I’d like to respond.

One person indicated that the panel re-enforced what he already thought about recruitment agents. I wonder if that Included Karl. I suppose he did spend some time apologising for the rotten apples in his industry. It is unfortunate that a few rotten apples can spoil the whole barrel. I’ve had my (un)fair share of dealings with rotten agents, but I’ve also dealt with some really good professional ones.

One person wanted more questions that were relevant to contractors. I actually did try to get a contractor on to the panel, but unfortunately it wasn’t to be. Also, only 2 questions directly mentioned contracting or freelance employment, which actually represents 40% of the questions (There were only 5 questions in total). I’m sure that had there been 3 questions that dealt with contractors, there would have been a comment from others that it was too one sided in the other direction. Finally, remember the audience were given an opportunity to direct the questions by submitting questions. I did my best to choose a fair representation.

One person regarded Barry Dorrans as “the bastard boss (and proud of it)”.  However, as I recall, Barry did say that this was just his interview technique to ensure that the candidates could stand up to difficult clients. I know some people may not like that, but if that’s the way the business operates then it is important to know if a person is likely to fold under pressure from a client. This also reminds me of a story I heard a while ago about interviewing potential police officers. One of the questions upset of of the candidates. The question was “What would you do if someone vomited on you?” However, it is a valid question. Police Officers are regularly vomited on and so the question helps the interviewer understand how the candidate will react in that situation.

One person thought the topics were too narrowly focused. From my point of view it was a difficult call. The subject area is quite large and I wanted to cover a variety of topics. If I had been too broad with each topic I’m sure I would have received complaints too as we would have had to spend more time on each topic. As Bart Simpson so succinctly put it “You’re damned if you do! You’re damned if you don’t.”

Finally, although someone did say they thought the session was “very good” they didn’t find it interesting. I’m wondering if they submited any questions for the panelists? If they did, did we go off topic with it? (We actually asked every question that we received – although we did have some in reserve in case we ran out.) This session was highly geared to running in the direction that the audience (hopefully) wanted it to go in. So, I am obviously disappointed if someone attended and found it not to be interesting.

I also received some compliments, but I wanted to respond to some specific points that were raised.

Where's my data? An introduction to Spatial Queries in SQL Server 2008

I’m speaking at the Scottish SQL Server UG on Wednesday 13th February.

My talk is on the new Spatial features of SQL Server 2008 (previously code named Katmai)

It is reckoned that 80-90% of data has a spatial component to it. But what do we do with it now? At best, we constrain it to postcodes. Well, that would be great if we were delivering letters, but the majority of us aren’t. In this session we look at Spatial Queries in SQL Server to see how it works and what can be done with it.

At the same meeting Martin Bell will be talking about DMVs:

Dynamic Management views were introduced in SQL Server 2005 and have made management and troubleshooting of SQL Server significantly easier than in previous versions. Even if you do not write your own queries against these DMVs you may be using them in Performance Dashboard Reports or other performance reporting applications. In this talk I will go through my TOP favorite DMVs and show how and when they can be used and why I like them!

You can find registration details here: http://www.sqlserverfaq.com/?eid=104