Archive for the ‘CSharp’ Category

Winforms / Webforms Can Make You Obsolete: Framework or Metaphor Lock-in is a Liability For Your Career

October 13th, 2008

I’ve always been uncomfortable with the ASP.NET Webform / Winform metaphor – I moved to ASP.NET from ASP 3.0 / PHP with no proper Windows development experience. The Webform / Winform metaphor was alien, but the code behind model and the ability to re-use controls drew me in, while the Webform metaphor became a tolerated evil. Today ASP.NET MVC and the announcement that Microsoft has embraced jQuery keeps me interested.

As developers, limiting ourselves to a single metaphor, framework, or programming language is a liability to our career. In order to remain employable and engaged with our work, we need to understand the higher level concepts surrounding our chosen development arena – if you’re working in the webspace this means knowing CSS, JavaScript, HTML, and more than one server-side language. Then beyond technologies and languages we should be looking at transcending principals like design patterns, and good design practices.

identifying with anything so strongly that it starts to give you emotional reaction is really bad. You never know when your language is going to be obsolete or … your favorite framework is going to be replaced. … I would love to see everybody learn a bunch of languages because it does make you a better programmer. … Most people will never switch languages. – Steve Yegge, stackoverflow podcast #25 

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.

Quality Assurance: Advanced Unit Testing: NUnit

July 17th, 2006

Marc Clifton has a great five part series on Advance Unit Testing. Throughout these articles Marc builds a Unit Testing framework based on the NUnit framework – NUnit is a Unit Testing framework for Microsoft .NET, it’s very similar to the JUnit framework for Java. Marc explores Unit Testing, the interworkings of Unit Testing frameworks, and the XP methodology.
Don’t be intimidated by the number or size of these articles – most of the content is source code.

  • Part I: Introduction to unit testing and a case study taking the XP process up to the point of writing some unit tests
  • Part II: Implementation of an NUnit look-alike and developing the case study further with real tests and real code
  • Part III: Implementation of NUnit extensions, revising and progressing with the case study
  • Part IV: Using reflection to create unit tests that are script based instead of code based, and the impact of that on the case study
  • Part V: Unit Test Patterns

Isn’t Microsoft’s C# just a copy of Sun’s Java? (C# vs. Java)

June 27th, 2006

The comparison between Microsoft’s C# (programming language) and Sun’s Java (programming language) is a common water cooler debate. Here’s my general approach / thinking:

C# and Java are both descendents of ‘C’, are based on the object-oriented paradigm and were based on the best programming principals / innovations of their time.
Time in the computer industry moves at a rapid pace, new ideas, changes, innovations can seemingly happen over night.
When Java was released (in the 90s) it was one of the better languages, now 16 years later C# is one of the better languages (C#’s original release date was in 2001 a minor revised version was released in 2005).

Microsoft’s C# is NOT a copy of Java, but it does bear resemblances to most object-oriented programming languages (including Java). Programmers at some point recognize that programming principals (and in this case the object-oriented paradigm) transcend specific languages.

Once a programmer realizes that programming principles transcend the syntax of any specific language, the doors swing open to knowledge that truly makes a difference in quality and productivity. - (Steve McConnell, Code Complete 2nd Edition)

Read more on Wikipedia : the Comparison of C Sharp and Java

Author: Adam Kahtava Categories: CSharp, Musings Tags:

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: