The South Carolina DVM expects to use my car's license plate to advertise for the state... we'll see about that!
Every few years the state of South Carolina sends me a new license plate. For some reason, they just can't pick a color and design and stick with it. But this time... they have really managed to pissed me off.
Here is the new license plate that arrived in the mail yesterday.
First of all, I don't give a rat's ass about the plate being pretty. I was fine with the plain white & blue plates with the high-visibility red font they used to use in the 80's. The purpose of the plate is to give police a way to identify the car. That's all it has to do. But if they want to spend my tax dollars making it all pretty then that's OK with me.
What gripes my ass though is that "TRAVEL2SC.COM" written at the bottom of the plate. Never mind that it's in all upper-case... it's the idea of having it there at all that pisses me off.
I don't mind branding to some extent. If you make some physical thing that I buy and you want to have your name on it then that's fine as long as your branding isn't over-the-top annoying and doesn't negatively impact the usefulness of the thing you brand. Take my car for example... it has the Toyota logo on front and back, and on back the word "Toyota" and the model of the car. That's fine with me. If someone looking at my car likes it, they might find it useful to know what kind of car it is so they can see about getting one themselves. I always like to be able to look at other people's car and know what kind it is too.
Same with most things and branding... as long as you keep it kinda subtle, tactful, and out of the way.
Advertising is a different matter though. I fucking refuse to advertise for you, especially not for free.
Take my car as an example again. I went to several car lots before I bought my car. One of them had a car that I liked, but it had a big-ass steel logo for the car dealer bolted onto the back. The dealer logo was actually larger than all the Toyota logos combined. I asked them if they could order me the car without the logo or remove the logo and "repair" the hole that the bolts would have left.
They looked at me funny and said they couldn't do that. So I told him that the only way I'd buy his car is if he gave me $100/month each month I owned it or knocked off $7200 off the price ($100/month times the 6 years I'd financed the car for). He laughed thinking I was joking... so I got up and walked out of the sales office.
I ended up buying the same car from a dealership that had a simple "sticker" logo that I could remove. I made sure they knew that the only reason I bought their car instead of the other guy was because I could remove the logo.
Its just a thing with me. I will allow you to brand my stuff if you can do it tactfully... but I'm not running around throwing someone else's name in everyone's face. That's why I don't buy a lot of name-brand clothing lines. If your logo is the prominent feature of the shirt, then fuck-off! You aren't charging me $20 to $40 for a shirt AND getting me to do your advertising for you.
But in this case with the license plates, it is even more offensive to me. The state requires that I have a license plate, and I have no alternative vendor I can go to get a plate from. I could buy a "custom" license plate from the state that doesn't have advertising on it... but why should I have to pay $50 more for the "privledge" of dodging having to do the governments dirty advertising.
In the end... duct tape came to the rescue:
I'm serious... I will not advertise for you. I don't give a damn if you are the government or my mom. If you want me to advertise for you.... pay me!
Thursday, June 26, 2008
Thursday, June 5, 2008
ASP.NET: web site vs. web application project - Part 2
My previous article about web sites vs. web applications seems to be a popular article, generating about 1/2 of the total traffic for this site. Most of that traffic comes from searches. Unfortunately, I doubt the old post really contains what people are actually looking for. So I'd like to spend a little text describing these two project types and how they compare.
A little background:
I'll omit a detailed technical description of the differences between web sites and web applications. This territory has been better covered elsewhere on the web, and the MSDN documentation that ships with VS 2008 covers it in detail too.
What most people want to know is, which is better?
The answer does depend a little on personal preference and what kind of application you are building.
I write and maintain several web applications. Some are very small personal sites with mostly static content, while others are huge data entry applications. My largest solution includes about 22 different class library and database projects that support a single web site project.
The web site project has always disappointed me, even with my smaller applications. The Web Application project type has become my preferred approach for all new projects, and I've since converted most of my older web sites to web applications as well.
Web site projects:
A little background:
Visual Studio 2005 introduced the asp.net "web site". Not only was this the only project type for asp.net when VS 2005 shipped, is was also major change from the old VS 2003 web project. In web sites the code is compiled on the fly by asp.net and there are no visual studio specific project files or auto-generated classes involved. This makes web sites simple and easy to deploy (just copy source to a web server and browse).
Not long after VS 2005 shipped, MS released the Web Application Project. This was an add-on initially, but has since been folded into VS 2005 with SP1 and shipped with VS 2008 out of the box.
The Web application project is an updated version of the old VS.NET 2003 project type. It organizes the project using the familiar VS project files and such. It requires you to compile the application before you can run it, but you gain more control over how the application is compiled.
I'll omit a detailed technical description of the differences between web sites and web applications. This territory has been better covered elsewhere on the web, and the MSDN documentation that ships with VS 2008 covers it in detail too.
What most people want to know is, which is better?
The answer does depend a little on personal preference and what kind of application you are building.
I write and maintain several web applications. Some are very small personal sites with mostly static content, while others are huge data entry applications. My largest solution includes about 22 different class library and database projects that support a single web site project.
The web site project has always disappointed me, even with my smaller applications. The Web Application project type has become my preferred approach for all new projects, and I've since converted most of my older web sites to web applications as well.
Web site projects:
Web sites are a little simpler if you are doing inline code instead of code behind. Web sites also reflect changes in code files without needing to be manually compiled. That means you can edit a file and just refresh the browser.
If you need to explicitly "build", so you can ensure your code doesn't have errors for example, you can still do so. However, the "build" command doesn't really compile the project... it just verifies it using the dynamic compiler. While 99% of the time this is fine, I have come across a couple of minor cases where the verification compiler didn't find an error, but attempting to run the site for real did.
Major advantages of web sites:
- Everything in the project's folder is part of the project. This makes it easy to use other editors or tools with web sites. If you add files outside Visual Studio, they will still be part of the project. If you edit a file outside VS it will still be compiled and the changes visible when the site is viewed in a browser.
- You can deploy without having to compile... just XCOPY and go. Web sites do support pre-compilation if you choose to use it.
- Files don't have to be written in the same language. VS will support having a mix of VB and C# code on a file-by-file basis. Sounds good, but I've never found this useful personally. Maintaining a site is much easier if you stick with one language.
- The add "item" dialogs in Visual Studio are more intuitive for web sites. I'm not sure why both projects don't use the same dialogs, but they certainly don't.
- Profile's design time compilation is automatic. The ProfileCommon class is created dynamically making it easy to work with the profile provider in a strongly typed way.
The biggest annoyance for me with web sites are:
- No way to really "exclude" a file without renaming it. Refactoring tools and the "compiler" have to crawl through every file in your application. This can get slow if you have a lot of files. For example, I often use FCKEditor, which has a dump-truck load of files. Most of them are not asp.net files. But just having to scan through them when I build or refactor can really slow things down. This has gotten a little better in VS 2008, but not fast enough for my tastes.
- No control over your namespaces. Sure, you can manually add namespaces to pretty much anything, but visual studio will fight you every step of the way. With generated code such as ADO.NET DataSets and such, this gets very hard to control. Eventually you will give up and just let VS put everything in the default namespace. In large applications this gets very annoying, especially if you like a well structured application.
- It is hard (read, nearly impossible) to reference pages, user controls, etc from custom classes in the app_code folder. This produces some interesting problems if you are doing anything fancy like dynamically loading pages or controls and such.
- The application compiles to the asp.net temporary internet files folder. This is a drop location for all that dynamically compiled code that the asp.net compiler will produce. This is a fine mechanism until it breaks. When it breaks you can get really weird errors from the compiler that don't make obvious sense. These are pretty easy to cause by accident. For example, if you tell VS to "build" then refresh a browser pointed at the site at the same time.... the two compiles often conflict in some bizarre manner corrupting the temp asp.net files. When this happens, assuming you figure out that this is the cause of the problem, you have to shut down VS and the web server, manually remove the files from the temp folder, then restart everything.
- No ability to product XML comment output files. I use the crap out of XML comments, so this is the big deal breaker for me.
- Not much control over build outputs. In most projects you can set whether a file is compiled, copied to the output directory, and such. But not with web sites. If a file is in the project's folder structure, it is part of the project.
- Team Build hates web sites. Lacking a project file, you can use the web deployment project add-on to help out, but even still I've found that trying to automate a build for any significantly complex web site is a disaster and time-sink.
- Disconnected Source Control. VS supports working disconnected from source control these days, but I find that it often has problems keeping web sites in sync when you reconnect. This is a sporadic problem, and hard to reproduce, but seems to be more common with delete, rename, and add operations.
The web application project is a little more formal than web sites. You get an actual project file by which Visual Studio tracks the files that are in your project. Web applications do generate "designer" files for your pages that link the code-behind to the controls you've put in the markup, but unlike old VS 2003 projects these are much simpler and leverage partial classes and such.
The drawbacks are:
- The site has to be compiled/built before it will run.
- Your project is specific to only one language.
- No automatic support for a Profile class. You have to use a separate tool to generate ProfileCommon or write one manually.
The major advantages are:
- Compile and refactoring is much faster since VS has a way to track what is in the project and doesn't have to scan everything in every folder. Also, you can have stuff in the folders that aren't part of the project (I find this useful sometimes).
- You can control namespaces, assembly names, and build behavior for various files in the project. Namespaces are also automatically managed by VS based on the application's folder structure. This includes a real "project properties" editor too with all those familiar things like build options, references, settings, etc.
- You can generate XML comment output files.
- You can exclude files from the project without having to rename them.
- MSBuild and Team Build work much smoother with web application projects.
- Custom code files don't have to be in a specific folder, you can put them anywhere and organize them however you see fit.
- Classes can refernce pages and controls.
- You can split the site into multiple projects.
- Include pre and post build steps to compilation.
- Disconnected source control seems to work more consistently with web application projects.
Web applications scale better and are just plain smoother than web sites assuming you plan to do most of your development directly in Visual Studio. The only major difference is that you have to build manually... so get used to CTRL + SHIFT + B. At least it's pretty fast in VS 2008 and it won't blow up the temporary internet files folder like web site projects can.
I can't say that web sites are inferior to web applications overall. There are cases where web sites do work very well, especially with smaller and simpler projects. I just personally don't find that having on-the-fly compilation is really much extra value, while more control over the application's compilation is always a good thing.
Monday, June 2, 2008
C Snobs
Recently, I ran across one of the many little spats that develop between bloggers. This time it was between Alastair Rankine of girtby.net and Jeff Atwood of Coding Horror.
It's the typical spat.
One blogger decides that another blogger is no longer writing what they want to read. Rather than just unsubscribe, they write a big public post about why they have decided to unsubscribe and why the other blogger sucks.
And, as is typical of these kinds of spats, the blog post starts by talking about how they don't normally slam on people they unsubscribe from... then they slam on them anyway.
Sigh....
Anyway... you can read the spat at the two links below if you want... but the details aren't that important to what I have to say.
What really got my attention in reading Rankine's part of this train-wreck (this is the nerd version of Jerry Springer right here) was that Rankine jumped Atwood's shit for not knowing C. In fact, he went as far as to say that by not knowing C, Atwood was not credible as a programmer.
Every time I see this opinion put forth by otherwise smart programmers it makes me foam at the mouth in rage and frustration.
This isn't a minority opinion in my experience.
I see this "must know C" prejudice all the time. I've even been passed over after a job interview had revealed my lack of a C background. There isn't any telling how many interviews I didn't even get to attend because my resume lacked C/C++ (even though I've never applied for a C/C++ dev position).
I also see this idea put forth by people that I otherwise respect... even Joel Spolsky, a hero of mine, makes a big deal out of knowing C. In his legendary advise to college students article #2 on his list is "Learn C before graduating".
He even gives an amazing (in terms of stupidity if you ask me) example:
So how does knowing this help me write better C#? This doesn't directly apply in C#. Wouldn't it be better if I knew how C# does string stuff, which mechanisms are more efficient in specific cases, and why?
I could take Joel's advice and go off wasting my time learning C. Then, like him, I'd be able to translate my C# concepts into C in order to understand how it all works under the hood... or I can just learn how C# works and skip the C translation step. Both are valid approaches, but I think it's unfair and narrow minded to discount my ability to understand what goes on under the hood just because I lack a formal C background.
I'm not saying that knowing C would hurt me. In fact, I've often wished I had the patience to go back and learn C. But honestly, writing in C makes me want to die. How did any of those old C guys actually get anything done?
Besides, if everyone based their understanding of higher level languages on C then where is the diversity? In some ways, my understanding of some areas of C# is actually better than that of people with C backgrounds precisely because I DON'T have a C background.
While Joel has good reasons for preferring C experience in his employees due to the kind of development his company does, that doesn't map well to other areas of the programming field.
I do asp.net web applications. When I'm hiring, I'd MUCH rather you have a solid understanding of how IIS works internally. I don't care if you can write a fancy-pants sorting algorithm in C. I trust that the .NET framework guys will work out most of that anyway. As long as you understand the internals of C# or VB and the .NET framework you'll do fine in my field without knowing any straight C at all.
When someone like Rankine makes such a prejudicial assumption about an otherwise competent person based just their lacking a C background... well... it strikes me about the same as the racial prejudices I've had to hear all my life.
See, I live in the Deep South of the USA where all Mexicans are illegal, all black men have 15 kids by 5 different women, and all Arabs are terrorists. Here most narrow minded ass-holes blame their minimum wage income on the irrefutable fact that non-English speaking illegal Mexicans have stolen all the jobs. While everyone here complain that Mexicans should be wasting their time learning English instead working, the Mexicans are working their asses off, getting shit done, and getting paid.
I guess it's fair that all you C snobs can watch those ignorant non-C speaking savages steal all your jobs too.
It's the typical spat.
One blogger decides that another blogger is no longer writing what they want to read. Rather than just unsubscribe, they write a big public post about why they have decided to unsubscribe and why the other blogger sucks.
And, as is typical of these kinds of spats, the blog post starts by talking about how they don't normally slam on people they unsubscribe from... then they slam on them anyway.
Sigh....
Anyway... you can read the spat at the two links below if you want... but the details aren't that important to what I have to say.
What really got my attention in reading Rankine's part of this train-wreck (this is the nerd version of Jerry Springer right here) was that Rankine jumped Atwood's shit for not knowing C. In fact, he went as far as to say that by not knowing C, Atwood was not credible as a programmer.
Every time I see this opinion put forth by otherwise smart programmers it makes me foam at the mouth in rage and frustration.
This isn't a minority opinion in my experience.
I see this "must know C" prejudice all the time. I've even been passed over after a job interview had revealed my lack of a C background. There isn't any telling how many interviews I didn't even get to attend because my resume lacked C/C++ (even though I've never applied for a C/C++ dev position).
I also see this idea put forth by people that I otherwise respect... even Joel Spolsky, a hero of mine, makes a big deal out of knowing C. In his legendary advise to college students article #2 on his list is "Learn C before graduating".
He even gives an amazing (in terms of stupidity if you ask me) example:
"...if you can't explain why while (*s++ = *t++); copies a string, or if that isn't the most natural thing in the world to you, well, you're programming based on superstition, as far as I'm concerned"
So how does knowing this help me write better C#? This doesn't directly apply in C#. Wouldn't it be better if I knew how C# does string stuff, which mechanisms are more efficient in specific cases, and why?
I could take Joel's advice and go off wasting my time learning C. Then, like him, I'd be able to translate my C# concepts into C in order to understand how it all works under the hood... or I can just learn how C# works and skip the C translation step. Both are valid approaches, but I think it's unfair and narrow minded to discount my ability to understand what goes on under the hood just because I lack a formal C background.
I'm not saying that knowing C would hurt me. In fact, I've often wished I had the patience to go back and learn C. But honestly, writing in C makes me want to die. How did any of those old C guys actually get anything done?
Besides, if everyone based their understanding of higher level languages on C then where is the diversity? In some ways, my understanding of some areas of C# is actually better than that of people with C backgrounds precisely because I DON'T have a C background.
While Joel has good reasons for preferring C experience in his employees due to the kind of development his company does, that doesn't map well to other areas of the programming field.
I do asp.net web applications. When I'm hiring, I'd MUCH rather you have a solid understanding of how IIS works internally. I don't care if you can write a fancy-pants sorting algorithm in C. I trust that the .NET framework guys will work out most of that anyway. As long as you understand the internals of C# or VB and the .NET framework you'll do fine in my field without knowing any straight C at all.
When someone like Rankine makes such a prejudicial assumption about an otherwise competent person based just their lacking a C background... well... it strikes me about the same as the racial prejudices I've had to hear all my life.
See, I live in the Deep South of the USA where all Mexicans are illegal, all black men have 15 kids by 5 different women, and all Arabs are terrorists. Here most narrow minded ass-holes blame their minimum wage income on the irrefutable fact that non-English speaking illegal Mexicans have stolen all the jobs. While everyone here complain that Mexicans should be wasting their time learning English instead working, the Mexicans are working their asses off, getting shit done, and getting paid.
I guess it's fair that all you C snobs can watch those ignorant non-C speaking savages steal all your jobs too.
while (*bigot++ = *asshole++);//see, natural isn't it?
Linq to SQL Bug - "System.FormatException: String must be exactly one character long."
Ran into a very annoying bug today. When I tried to use Linq to SQL to read values from a rather unexciting table, the site threw up with
It took a while to narrow it down, but it turned out to be a field in the table that was defined as NVARCHAR(1). The LINQ to SQL mapping was System.Char. All the other NVARCHAR fields were mapped to System.String.
Not much out there on the forums about it when I did a casual google search either so I thought I'd post about it here.
I did find it listed as an active bug on the Microsoft Connect site here.
The problem is that Visual Studio's LINQ to SQL designer incorrectly maps this to char instead of string. Since char types cannot be "empty" you will get an error at runtime if any of your columns contain empty values. Null will work fine though.
The easy work around is to just manually toggle the type to System.String in Visual Studio's property window. If that doesn't work for you, you could change the column to char(1) in the DB instead and just not put empty strings in there.
In my case, I'm using a middle initial field. I like to treat null in my database as "undefined"... meaning that no value was specified at all or the question hasn't been answered. This is different from empty... empty would mean that the question was asked, and the answer was "no value". The difference is subtle, but important sometimes.
System.Web.HttpUnhandledException: Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
System.FormatException: String must be exactly one character long.
It took a while to narrow it down, but it turned out to be a field in the table that was defined as NVARCHAR(1). The LINQ to SQL mapping was System.Char. All the other NVARCHAR fields were mapped to System.String.
Not much out there on the forums about it when I did a casual google search either so I thought I'd post about it here.
I did find it listed as an active bug on the Microsoft Connect site here.
The problem is that Visual Studio's LINQ to SQL designer incorrectly maps this to char instead of string. Since char types cannot be "empty" you will get an error at runtime if any of your columns contain empty values. Null will work fine though.
The easy work around is to just manually toggle the type to System.String in Visual Studio's property window. If that doesn't work for you, you could change the column to char(1) in the DB instead and just not put empty strings in there.
In my case, I'm using a middle initial field. I like to treat null in my database as "undefined"... meaning that no value was specified at all or the question hasn't been answered. This is different from empty... empty would mean that the question was asked, and the answer was "no value". The difference is subtle, but important sometimes.
Subscribe to:
Posts (Atom)