Beer Cardinality

There is a trend in the IT industry that really gets my back up.

A new technology comes out, people ignore it for a while.

People come to understand the technology and start to use it.

Before long said technology is being used to do EVERYTHING, often things it was not intended to do.

I've struggled for years to come up with some way to describe this succinctly. Well, Jeffrey Snover has come to my rescue; he has coined the term 'Beer Cardinality' in this excellent post on PowerShell and DSLs.

LINQ to SQL and wildcard searches

Recently I had cause to perform a wildcard search in LINQ to SQL.

Originally I had something like:

database.Table.Where(p => p.Column == SomeValue).ToList()

The customer came back with an update to the requirement, as they do. They now wanted a wildcard search not a straight equality test. Being new to LINQ to SQL I had a quick chat with Neil and he pointed me straight at .Contains, .StartsWith and .EndsWith.

I got to wondering what the generated SQL for .Contains, .StartsWith and .EndsWith would look like.

It's fairly simple, and obvious, when you think about it;

.Contains will spit out ..... LIKE '%YourSearchTerm%'

.EndsWith will spit out ..... LIKE '%YourSearchTerm'

.StartsWith will spit out ..... LIKE 'YourSearchTerm%'

A quick Google shows me that David Hayden has already covered this, here.....

There is more to add to this story, however.

Performance.

Any SQL dba worth their salt will tell you that when using the LIKE statement, 'YourSearchTerm%' will perform much better than either of the other two options.

Again, this is fairly simple and obvious when you think about it;

'YourSearchTerm%' will result in an Index seek, the other two will result in an Index scan.

Again, a Google shows that John Kane has already covered this, here.....

 

Neither of these provide a full end to end picture, now you have one ;-)

So if you need to perform this kind of wildcard search in LINQ to SQL, use .StartsWith.

Presentation Patterns (part 1)

"What's in a name? That which we call a rose
By any other name would smell as sweet."

Over the coming weeks I am going to be preparing a course covering presentation patterns for staff at iMeta. This started out known as a course for MVC and all its incarnations. I feel that presentation patterns is a better description for what this course is going to provide, after all that is what it will really be about.

MVC (model-view-controller) has become something of an umbrella term, used to 'define' a whole plethora of different presentation approaches. Some people refer to something being MVC when in fact it is MVP. I have known people refer to something as MVC when in fact it was a Front Controller. Sometimes something is referred to as MVC only for it be discovered as, well, frankly, who knows!

There are some important points which are worth making at this juncture:

  • As far as MVC goes there is a very well defined and understood definition of what MVC actually is and where it has come from.
  • The raison d`être for MVC (Separation of Concerns) is very much the same as for the majority of other presentation patterns, as always the devil is in the detail.

Now for some people Shakespeare was bang on the money when he penned the phrase at the top of this article. And sure as far as concrete things, for example a rose, are concerned he was dead right. What does the name matter, it is the substance of a thing that really counts.

However, referring to something as MVC when in fact what was meant is Supervising Controller is just plain bad. The minute the term is used a mental picture is formed that supplies a great deal of context for any conversation going forward. If you start out with the wrong mental picture, you are going to get in a mess real quickly!

So while the solution under discussion is meeting a need that can be approached with one of a multitude patterns, the subtlety of the approach taken can be lost. The incorrect use of terminology will add to your woes!

The course I am developing intends to highlight these subtleties and, thereby, ensure that attendees will be on sure ground when discussing presentation patterns.

Over the coming weeks, as the course develops, I shall continue this series with posts covering the content of the course.

Next time...... I will talk about the 'strict' definition of MVC and provide a little history.

One Comment Filed Under [ Patterns MVC MVP ]
ClickOnce and Authenticated Proxy Servers

The standard setup for clickonce applications will not authenticate to a proxy server.

This manifests itself as an http 407 error.

A hot fix is required to make it work;

http://support.microsoft.com/kb/917952

 

Add Comment Filed Under [ Smart Client ]
Visual Studio 'Add Reference' Woes

My first foray into the world of blogs!

For some unknown reason visual studio has stopped showing me .Net 3.0 assemblies in the list generated when you right click -> add reference.

A quick google found me this:

http://support.microsoft.com/kb/306149

Following on from this, a quick squiz at another vista machines registry shows me this key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\Microsoft .NET Framework 3.0 Reference Assemblies for Visual Studio

which contains the following default value:

c:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\v3.0\\

Well, that path exists on my machine and the dlls are there too, woohoo ;-)

Adding the above key and default value, then closing and re-opening VS solved my problem.

Add Comment Filed Under [ Visual Studio ]