Tuesday, February 21

Sequential or parallel loading of web pages

When a web page is downloaded, lots of text and images are downloaded in parallel. This means pages are slower to respond than they need to be. You can work out which parts of the page your users are most interested in, download these first, then download the remainder. Typically, images are less important than the text on your page and some images are more important than others. One way of doing this is described here.


http://www.cryer.co.uk/resources/javascript/script3.htm


This will result in the important part of the page being downloaded quicker (see the graphs below). Users can read what interests them in less time.





As I was reminded last night at an excellent talk by Ted Neward at the London .NET users group, bandwidth isn't infinite. Many users have dial-up connections. Over a dial-up connection, a 20K image takes about 5 seconds to download.


However, not everyone has JavaScript (but about 98% of readers of this blog do). Also, the JavaScript itself takes a few bytes of bandwidth, so this may not be the best solution for very small images, and overall load time is slightly slower.

Monday, February 13

Passed Exam 70-300

I took the exam 70-300 (Analyzing requirements and defining Microsoft .NET solution architectures) today, and passed with a score of 967. I thought I had answered about 2/3 of the questions correctly, and the other 1/3 I thought had several correct answers which you could make a case for, so I was surprised that so many of my answers must have been in agreement with Microsoft's and my score was this high.

However, these things aren't worth doing unless you learn something. So what did I learn from this?

1) How to take a series of differing views of a system and extract requirements from these, splitting them into business needs, user needs, system requirements and requirements to manage the system when it is operational.

2) How each requirement might impose demands in terms of performance, availability, security, scalability, maintainability, accessibility, deployability or extensibility of the system.

3) How security issues can be considered using the STRIDE model – I’ve thought a fair amount about security before, but I somehow missed this model. It’s described in more detail here:

Have I been converted to the "Microsoft Solutions Framework" approach? – I'm not sure – I think you do a better job if you find it rewarding, and you find things more rewarding if you are doing them, not planning them. So some aspects of planning are better deferred until later in development.

I also think people are more motivated if they feel personally involved part of a system, and are not an interchangeable resource. The Microsoft approach, by e.g. having coding standards that teams follow and documentation in a similar format across many projects makes you feel like an interchangeable resource who can be moved around different projects. If teams understand requirements and how these might impose demands on the system, they should be more free to develop their own processes to suit the talents of their members.

Tuesday, February 7

Which technologies do I need to know?

New programming languages, databases, productivity tools and ways of doing things are constantly being developed. It's impossible to become an expert in everything.

I've been trying to think which new things are merely hype, and which I should be learning about and getting to know.

To help work this out, I've come up with some questions I’m asking myself about technologies I'm considering.

Am I likely to be asked to use in the next 2 years?
  • Is the technology one that generates a lot of noise, or does anyone actually use it to make a living at the moment?

Is the technology easily learnable?
  • Is the only way to gain meaningful experience by using it on an enterprise class application?
  • Are books and web sites available to help learn it?
  • If I invest time learning skills in this technology, can the skills be transferred to something else?

Would I be able to persuade anyone to introduce this to help their business?
  • Are the benefits of the technology understandable by someone who isn’t interested in computer science?
  • Can a business case be made for the technology saving costs?
  • Can a business case be made for the technology reducing risks?
  • Can it be cheaply introduced on a small project?

How good is it for me?
  • Does it lead to a fun environment to work in?
  • Does it mean that I can achieve great results in a shorter time, allowing me to go home early?
  • Would it enhance my career prospects, salary or job security?

How would you rate the technologies you use or are interested in against these criteria?

Monday, February 6

First attempts at SQL Server 2005 CLR Stored Procedures

Having just returned from the "Get ready for SQL Server 2005 roadshow", listening to Niels Beglund's excellent presentaion, and also hearing that there is a possibility that we might actually be migrating to SQL Server 2005, I thought it might be a good idea to try and write a .NET CLR stored procedure for myself. These things always look easy when they are demonstrated, but never seem so easy when you do them for yourself. However, this time, I was proved wrong, but I'm recording it here in case it's more difficult when I need to do it again and to help anyone else trying to do the same thing:

Here's what I did:

1. Write your function
Create a class library project containing a public and static function. I wrote the following to convert someone's name into having an upper case first character and lower case characters after that. CLR stored procedures are good for string handling, and often people enter their names in a database in an inconsistent format.
public class NameProcessor
{
public static String ProcessName
(String name)
{
String rv;
rv = name.Substring(1,1).
ToUpper() + name.Substring(2).ToLower();
return rv;
}
}

I know there is a mistake in this, but we'll debug it later.
2. Compile this.
3. Go into SQL Server 2005 Management Studio
4. Create an Assembly
create assembly processstring from 
‘c:\Documents and Settings\Richard\My
Documents\...\classlibrary1.dll’

5. Check it exists
select * from sys.assemblies

6. Map an SQL function to your function
Create function dbo.pn(@name nvarchar(100))
returns nvarchar(100)
external name processstring.NameProcessor.ProcessName

Note this has to use an nvarchar type
7. Check it works
select dbo.pn('abc')

Oops - this returns 'Bc', not what we wanted
8.Try and debug it
Add the PDB file to your assembly:
alter assembly processstring
add file from 'c:\Documents and Settings\Richard
My Documents\...\classlibrary1.pdb'

9. Debug in Visual Studio

  • Select "Attach to Process" from the tools menu

  • Select "Show Processes from all users" in the bottom left.

  • Select "sqlservr.exe", and select "Attach to Managed Code"

  • Add a breakpoint in your function

10. Check your breakpoint is fired
Go back into Management Studio
select dbo.pn('abc')


Your breakpoint is hit. Correct the code.
As this is .net, you can add a unit test for
this with nUnit if you're so inclined.
11. Update your assembly
Drop your PDB File from your assembly
alter assembly processstring
drop file 'c:\Documents and Settings\Richard
My Documents\...\classlibrary1.pdb'

Update your DLL
alter assembly processstring from 
'c:Documents and Settings\Richard
My Documents\...\classlibrary1.dll'



12. Run the function
select dbo.pn('abc')

Excellent - this now works correctly.