Archive for the ‘CSharp’ Category

Software Ethnocentrism: Staving Off Tunnel Vision

February 17th, 2008

Loosely typed / weakly languages are amazing! But… for myself, coming to this conclusion was like an acquired taste.

Many people appreciate loosely typed languages for the how expressive, elegant, simple, and Zen like they are – and I agree, but I haven’t always thought this way. You see; strictly typed (statically typed) programming languages have always been the mainstay of my programming vocabulary, C++, Java, and C# were the meat and potatoes of my programming language diet. I used these languages (strictly typed) because they were familiar, I understood how their compilers, IDEs, and comfortable class-based inheritance model worked. If someone asked me whether I liked C# (insert strict typed language) or JavaScript (insert weakly typed language) I would immediately have given preference to the strictly typed language. Why? Because that’s where I felt safe, and that’s what I understood – besides who wants to admit they prefer the “weak” language? My preference wasn’t based on knowledge or experience it was based on my familiarity with the strictly typed culture.

I was suffering from Software Ethnocentrism.

Software Ethnocentrism often entails the belief that one’s programming language or development environment is the most important and/or … are superior to those of other software developers. Within this ideology, software developers will judge other groups in relation to their own particular development environment or culture, especially with concern to programming language, methodologies, behaviour, customs, and religion.  - the derived definition (above) is based on Wikipedia’s article on Ethnocentrism

I had the tell tale signs of Software Ethnocentrism:

  • I thought strictly typed language were “the bomb”  – the only viable solution :)
  • I thought Test Driven Development (TDD) and Unit Testing was the panacea
  • I was completely obsessed with refactoring tools like ReSharper and Refactoring
  • I thought my Compiler and IDE were superior
  • and I had complete faith in multipurpose strictly typed languages like C#

Then things changed. I started diving deep into the hearts of weakly typed languages: JavaScript, Ruby, and LISP. Now today, I wonder If the time I spent hung up on strictly typed languages, TDD, and unit testing could have been better spent by expanding my programming vocabulary. If I had only delved deep into the heart of weakly typed languages (like JavaScript, 3 years ago) and grocked the fundamentals of these other languages, then I could have achieved this richer understanding of programming languages that I have today. It’s important to note, that i’m not stating that weakly typed languages are better than strictly typed languages or vise versa, only that both have their place, are equally useful, and should be used when appropriate.

Do you too suffer from Software Ethnocentrism? Try staving off this programming language tunnel vision, learn a new type of programming language. It might be a better investment in your time than becoming obsessed over a microcosm (like say unit testing and TDD).

Steve Yegge makes some humorous jabs at the static type culture:

… I think we can conclude that people who rely too much on static types, people who really love the static modeling process, are n00bs. … Hee hee. – Steve Yegge: Portrait of a N00b

… I think there’s some mystical relationship between the personality traits of “wakes up before dawn”, “likes static typing but not type inference”, “is organized to the point of being anal”, “likes team meetings”, and “likes Bad Agile”. I’m not quite sure what it is, but I see it a lot. – Steve Yegge: Good Agile, Bad Agile

… you have your slob type systems and your neat-freak type systems, and it comes down to personal preference. The neat freaks (Java, C#, C++, Pascal) know damn well that the slobs (Perl, Python, Ruby, JavaScript) are just as productive. Maybe even more so. – Steve Yegge: Egomania Itself

Cartoon Notes: I took this cartoon from Steve Yegge’s blog titled Egomania Itself. It represents the irony of static type languages where everything is a named type – presumably the owner of the property is naming all his objects so he can remember what they are, but in loosely type languages, If it walks like a dog and barks like a dog, I would call it a dog. Read more about Dog Typing er… Duck Typing.

Distilled: Fixing the Global.asax in ASP.NET 2.0

June 20th, 2006

Visual Studio 2005 no longer adds a code behind file to the Global.asax file.

To add a code behind file for the Global.asax file (in C#) follow these steps:

  1. Open your project in Visual Studio 2005
  2. Add New Item from the context menu (right clicking on your project)
  3. Select the Global Application Class
  4. Make sure your Global Application Class file (the .asax file) is opened
  5. Delete all the contents of this .asax file
  6. Add the following to this .asax file:  <%@ Application Language=”C#” Inherits=”Global” %>
  7. Create a new class named Global in the App_Code directory
  8. Copy the following source into your new Global class:
    /// Summary description for Global 
    public class Global : System.Web.HttpApplication {
     Global() { }
     void Application_Start(object sender, EventArgs e) {
      // Code that runs on application startup
     void Application_End(object sender, EventArgs e) {
      // Code that runs on application shutdown
     void Application_Error(object sender, EventArgs e) {
      // Code that runs when an unhandled error occurs
     void Session_Start(object sender, EventArgs e) {
      // Code that runs when a new session is started
     void Session_End(object sender, EventArgs e) { }
  9. Save, you are done

The preceding has been distilled from Ross Nelson’s article: Fixing the Global.asax in ASP.NET 2.0.

On a related thread: Consider using HttpModules instead of the Global.asax file, Learn more in Karl Seguin’s article titled: Global.asax? Use HttpModules Instead!

Author: Adam Kahtava Categories: .NET, ASP.NET, CSharp Tags: