Is it important to write good code?

The last three weeks I have visit several companies and talked about writing good code. It's amazing to see how different developer thinks about writing good code. Here are some comments when I asked if it's important to write good code:

- I don't care as long as it works it's fine.

- I don't have the time to write good code.

- The customer don't see the code, so as long as the application works, I'm satisfied.

- Most customers want to pay as little as possible for as much as possible, and to deliver it in time, I make sure the code only works.

- I know that we can use refactoring to make the code more readable, but we don't have the time to do it.

When I asked about reading other peoples code and also maintain it, most people answer:

- It's not easy all the time

- It's horrible and hard to understand what the code does.


That are some of the results when developers only write code to make stuff works and write code for them self and don't care to write code for other humans to understand.

Here is an example which I use during my presentation, it's a method which will calculate the price for renting a movie, the price differs between different type of customers and also different types of movies.

public class MovieRenter
{
    public double CalculatePrice(string customerType, string movieType)
    {
        if (customerType == "VIC" && movieType == "Transfer")
            return 20;
        else if (customerType == "Regular" && movieType == "Transfer")
            return 30;
        else if (customerType == "VIC" && movieType == "Normal")
            return 10;
        else if (customerType == "Regular" && movieType == "Normal")
            return 20;
        else
            return 50;
    }
}
 
MovieRenter movieRenter = new MovieRenter();
double price = movieRenter.CalculatePrice("VIC", "Transfer");


I asked the attendance if the method looks ok, I got surprised when the answer was "Yes". Some one told me, well I should have used enumeration and switch statement instead of strings and if statements. I did some refactoring and use an enumeration and switch statement instead with the help of the attendance, the result was the following code:

public class MovieRenter
{
       public double CalculatePrice(CustomerType customerType, MovieType movieType)
       {
           switch (customerType)
           {
               case CustomerType.VIC:
                   switch (movieType)
                   {
                       case MovieType.Transfer:
                           return 20;
                       case MovieType.Normal:
                           return 10;
                       default:
                           return 20;
                   }
                   break;
               case CustomerType.Regular:
                   switch (movieType)
                   {
                       case MovieType.Transfer:
                           return 30;
                       case MovieType.Normal:
                           return 20;
                       default:
                           return 30;
                   }
                   break;
               default:
                   return 30;
           }
}

public enum MovieType
{
    Transfer,
    Normal
}

public enum CustomerType
{
    VIC,
    Regular
}
MovieRenter movieRenter = new MovieRenter();
double price = movieRenter.CalculatePrice(CustomerType.VIC, MovieType.Transfer);

When I asked if we can do it even better, someone wanted to split the switch statement inside of the case CustomerType.VIC into a separate method, the same with the switch statement in the case CustomerType.Regular. I did that changes to the code and everyone was happy. The problem with conditional statement in code, is that they can be hard to maintain, if I need to add a new kind of movie and customer, I need to add more conditions to my code. Sooner or later it will be difficult to maintain. So one thing we can do, is to replace a conditional statement with polymorphism.

If we look at the code, we can see that we have a customer and a movie to which a customer wants to rent. So we create two entities, one Customer entity and one Movie entity. We can then add a Rebate property to the Customer class and a Price property to the Move class. A movie have the price, and Customer have a rebate. Now when we have a Customer and a Movie, we need to make sure we also have the different type of Customers and Movie represented as classes, we don't want to add a CustomerType or MovieType property to the Customer and Movie class, if we do so, we will en up with a new conditional statement. So we create a new class called CustomerVIC which will inherit from Customer, and we create a MovieTransfer class which inherits from the Movie class. We let the Customer class represents a regular customer and the Movie class as normal movie. Because a VIC Customer should have it's own Rebate and a Transfer Movie should have it's own price, we make sure the base classes properties are virtual so we can override them in our sub classes.

public class Customer
{
    public virtual double Rebate
    {
       get { return 0; }
    }
}

public class CustomerVIC : Customer
{
    public override double Rebate
    {
       get { return 10;  }
    }
}

public class Movie
{
    public virtual double Price
    {
       get { return 20; }
    }
}

public class MovieTransfer : Movie
{
   public virtual double Price
   {
      get { return 30; }
   }
}

If we compare a normal customer with a VIC, we can see that a VIC will have 10 in rebate. So we make sure the CustomerVIC class Rebate property returns the price a VIC Customer should have in Rebate over a regular customer. The price of a Transfer movie is 30 and the price of a normal movie is 20.

Now when we have created our Customers and Movies, we can change the MovieRenter's CalculatePrice method, which in this case should take a Customer as an argument and a Movie.

public class MovieRenter
{
   public double CalculatePrice(Customer customer, Movie movie)
   {
      return movie.Price - customer.Rebate;
   }
}

CustomerVIC vicCustomer = new CustomerVIC();
MovieTransfer transferMovie = new MovieTransfer();
          
MovieRenter movieRenter = new MovieRenter();
double price = movieRenter.CalculatePrice(vicCustomer, transferMovie);


So by using polymorphism and more Object Oriented Programming over a normal functional programming, we can remove conditional statements. If I need a new type of Customer or Movie, I just create a new class and inherits from its base class and override the Rebate and Price property. Anyone have another suggestion of making the first code example better, and do you think it's important to make it better even if it works?

What do you think is most important when it comes to writing code?

What is the most common thing you think a developers are doing wrong when they write code?

Published Sunday, October 12, 2008 1:53 PM by Fredrik N
Filed under: , ,

Comments

# re: Is it important to write good code?

Sunday, October 12, 2008 9:10 AM by John_Idol

Good post - this perfectly captures, between other things, one of the never-ending dilemmas developers face on a daily basis: "what's best\worst: adding an conditional statement or creating a new class?"

I agree with the polymorphic approach adopted here; usually when you end up with too many IF statements or SWITCH CASEs you should ask yourself if it is possible to go either with polymorphism (as in this case) or inheritance.

Back to the core of the discussion, It is certainly worth improving code quality even if it works.

In my experience I had to jump in a number of so called "stable" projects where maintaining what was in place and adding new features was a nightmare.

Real problem is that you find yourself constantly fighting fear of change from management on this kind of projects - and often developers are forced to be "consistent" even if it means writing BAD code.

# Interesting Find: October 12, 2008

Sunday, October 12, 2008 10:41 AM by Jason Haley

# re: Is it important to write good code?

Sunday, October 12, 2008 11:41 AM by Fredrik Kalseth

Spot on - maintainability is the most important aspect of the code, in my opinion. Most software is going to be maintained (bugfixing, new/modified features etc) for much, much longer (years) than the initial investment made building v1 (weeks/months).

# Is it important to write good code?

Sunday, October 12, 2008 2:09 PM by DotNetKicks.com

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# re: Is it important to write good code?

Sunday, October 12, 2008 3:18 PM by Roger Alsing

>>What is the most common thing you think a developers are doing wrong when they write code?

IMO, the most common mistake is to be affraid of Exceptions.

People associate exceptions with bugs, and if there are no exceptions, they think that there are no bugs.

So they go to great extent to avoid exceptions and resort to methods returning error codes and other crazy stuff.

Lacking refactoring is another common mistake imo.

# Dew Drop - October 12, 2008 | Alvin Ashcraft's Morning Dew

Pingback from  Dew Drop - October 12, 2008 | Alvin Ashcraft's Morning Dew

# re: Is it important to write good code?

Sunday, October 12, 2008 8:33 PM by Steve

Thanks Fredrik.  Now I have a question for you:

Somewhere you'll eventually need a conditional to determine which customer type ?

# re: Is it important to write good code?

Monday, October 13, 2008 1:01 AM by Fredrik N

@Steve:

Good question!

If we assume we have our customers into a database we will probably have column in our Customers tables which indicate the type of the customer. So it will now be up to the Repository to return the correct type of the customer. So yes there will actually be a conditional statement. If we have used an Object Oriented Database, we would not need the conditional statement, so it’s based on how the customers are persisted.

# re: Is it important to write good code?

Monday, October 13, 2008 4:41 AM by dkl

In my opinion, this is not the best usage of polymorphism. Different value of a property (Rebate) is not reason good enough to create new subclass. What if you add new type of customer? Will you add another subclass just to return different value of Rebate property? And what will you do if you would like to promote ordinary customer into VIC customer?

The same is true for Movie and MovieTransfer classes.

I would split the Customer to two classes: Customer would keep data specific for one customer (like name, address etc.) and CustomerType would hold data common to a whole category of customers.

public class CustomerType

{

   public double Rebate {get; set;}

}

public class Customer

{

   public CustomerType CustomerType {get; set;}

   double _rebate = -1;

   public double Rebate

   {

       get { return _rebate==-1 ? CustomerType.Rebate : _rebate; }

   }

}

This way you can add new type of customers without changing your code, and set the rebate for each customer individually (if needed). Yes, it is more complicated to do this right (you must decide what should the Customer do if it's CustomerType is null), but that could be easily handled by small set of unit tests. I think it's no worse than deciding which class to instantiate (Customer or CustomerVIC). And there will be no problems with promoting ordinary customer into the VIC customer - you just change the CustomerType of the customer object.

# re: Is it important to write good code?

Monday, October 13, 2008 5:03 AM by Johan Normén

I got confused regarding this comment:

"- I don't have the time to write good code." hehe that was funny.

The thing with good code is that it doesn't take time. I think people need to be more lazy :-) a lazy programmer is often a better programmer. The hardest part of being lazy is that you must stay unlazy to be better lazy :-) A lazy programmer doesn’t love to write 100 of lines methods. They don't have time or are so lazy so they don't write the same thing more than once. They are also so lazy so they write automatic test so they don't need to test more than once etc etc...

The biggest problem regarding good code is often the lack of creative thinking. To write good code you need some creative skills regarding design of code. We must be able to think outside the box if we can't we will never be good at writing code...

# re: Is it important to write good code?

Monday, October 13, 2008 5:32 AM by Fredrik N

@Dkl:

Nice. In my case I don’t need to specify different rebate on individual customers, so I just keep it simple and thinking in the term of YAGNI and the demonstration is about how to remove conditional statements by using polymorphism. 

# re: Is it important to write good code?

Monday, October 13, 2008 6:31 AM by Mario S

Hi !

I enjoy reading your blog, and I also try to be a perfectionist writing code (and I even get some criticism for it sometimes...)

After several years of experience in the IT business, and many big and small projects where I had different responsabilities, that question is easily answered by asking a similar question (altough it doesn't mean we developers like it):

Is it important to grow potatoes with a good technique ? Do we care when we buy potatoes if they were grown the "best possible way" ? Do we care if the farmer will not reutilize the tools he used ? Do we go and analyze the potatoes in a lab before eating them, or do we just read the label (if any) ? But do we carefully look at the price per weight ?

It's all in the human nature, it's not a good/bad developers thing. Sure, I wish more developers would do their best to improve their code, to comment more, to write reusable object oriented code, like I try to do everyday. But is it that important when looking at the big picture ? Except for a few specific cases, there is usually a balance between code quality and what the customer wants.

As for me, I can't write bad code if I know I can do it better. But I no longer feel pain if I just have to hack someone's code to make something work for a customer. And now I know that deadlines are far more important for most people than knowing that the code is high quality, highly flexible and easily maintained...

But this is also making me drift away from writing code, and looking towards other functions...

# re: Is it important to write good code?

Monday, October 13, 2008 9:39 AM by David Fauber

I agree with the general theme of the post.  Switch statements generally seem like a code smell, and are a good place to direct refactoring efforts.

I also agree with the above poster that simply changing a property value isn't a compelling enough reason to create a subclass, and the MovieTransfer subclass doesn't feel very orthogonal.  (also I think you have a typo as its listed as MoveTransfer (missing the "i" in movie) in the code snippet)

Really enjoy the blog, keep up the good work!

# re: Is it important to write good code?

Monday, October 13, 2008 12:17 PM by Ryan Roberts

Or you could go data driven and declare a mapping between (CustomerType,MovieType) and the price. You would then end up with something along the lines of:

Dictionary<Pair<CustomerType,MovieType>,double> _priceMap = new Dictionary<Pair<CustomerType,MovieType>,double>

   {new Pair(CustomerType.VIC,MovieType.Transfer),30};

public double CalculatePrice(CustomerType customer,MovieType movie)

{

  double price = 30;

  priceMap.TryGetValue(new Pair(customer,movie);

  return price;

}

This technique can get even more powerful if you use lambdas in the lookup.

# re: Is it important to write good code?

Monday, October 13, 2008 12:27 PM by jp

Did we forget about [Flag]?

I find that most developers define "Good Code" as code they can understand, and I'm realizing that developers are getting tired of learning new things.  It's a shame, I thought that when we decided to get into this industry we realized that you never get to stop learning, and it's actually a difficult job.  Remember, that's why you get paid so much.

# re: Is it important to write good code?

Monday, October 13, 2008 12:52 PM by Marcus Eklund

Whatever you do, don't visit my workplace then.

It is a disaster. I am trying to motivate my collages to look into TDD and so on.

But no, 1 Bosses are idiots and wants us to work faster and not care about bugs (which they said straight into my face) 2 The coworkers keeps saying NO to my ideas or It can't be done.

*shrug* I think i need a new job.

# re: Is it important to write good code?

Monday, October 13, 2008 2:37 PM by Joe M

Why not just look up Rebates and Prices, instead of having to derive a new class for each type.

Something like:

   public class MovieRental

   {

       protected Dictionary<string, double> customerRebates = new Dictionary<string, double>();

       protected Dictionary<string, double> moviePrices = new Dictionary<string, double>();

       public MovieRental()

       {

           Initialize();

       }

       protected virtual void Initialize()

       {

           // Probably really initialized from a database in the real world.

           customerRebates.Add("Regular", 0);

           customerRebates.Add("VIC", 10);

           moviePrices.Add("Normal", 20);

           moviePrices.Add("Transfer", 30);

       }

       public virtual double CalculatePrice(string customerType, string movieType)

       {

           double customerRebate = customerRebates[customerType];

           double moviePrice = moviePrices[movieType];

           return moviePrice - customerRebate;

       }

   }

# re: Is it important to write good code?

Monday, October 13, 2008 3:07 PM by Max Kramnik

To make this example even nicer, you may want to add a factory.

# re: Is it important to write good code?

Monday, October 13, 2008 4:44 PM by mike n

First, I am not a programmer.  I do dabble in it a very little bit.  But programming is writing formulas.  I have used formulas in spreadsheets to handles cases like this.  Question - Would it be possible to create in a database, a table called MovieRenter containing the columns customerType, movieType and rebate; with row 1 containing VIC, Transfer, 20, row 2 containing Regular, Transfer, 30, as so on; then write a single line of code that reads the input data; looks in MovieRenter; matches the correct customerType, movieType combination; then returns the rebate value.  As more customerTypes and movieTypes are created, add a row to the table; the formula remains unchanged.  Does this make sense?

# 2008 October 14 - Links for today &laquo; My (almost) Daily Links

Pingback from  2008 October 14 - Links for today &laquo; My (almost) Daily Links

# re: Is it important to write good code?

Tuesday, October 14, 2008 12:25 PM by Schneider

In my opinion this is a continuous balancing act. Better code is usually easier to maintain and adapt to new business changes, but takes longer to deliver a product. At some point the company pays the price for bad code, either later to add changes or fix bugs. Another thing to consider is an experienced programmer will avoid a lot of design flaws even when building something too quickly.

# re: Is it important to write good code?

Tuesday, October 14, 2008 9:57 PM by bob

Eliminating conditional code has the effect of "spreading out" the logic into classes.  While in the hands of a solid OOP developer, that seems powerful.  But you have to allow for code which is being maintained and cannot for various reasons be rewritten.  It is this mindset that drives the conditional code after initial design.  Someone in a hurry could modify the if statement much more quickly that creating new classes and understanding the functioning of the heirarchy.

You see, while your idea makes sense, when expanded to say 50 developers on a project none of them will likely choose similar levels of abstractions and implement conceptual patterns in the same way.

Overlaying lots of OO patterns in a decent scale application with many developers, can be harder to maintain than conditionals in the long run due to the pattern ramp up curve which is seldom documented clearly as to how things fit together.

If I had a shop of mid tier developers I would stick with conditionals and use architectural patterns at a higher level rather than worrying about trivial logic expressions.

# Interesting Finds: 2008.10.13~2008.10.15

Tuesday, October 14, 2008 10:33 PM by gOODiDEA.NET

Other Is it important to write good code? Must Have Software 2008 Edition Database OUTPUTing Data from

# Interesting Finds: 2008.10.13~2008.10.15

Tuesday, October 14, 2008 10:37 PM by gOODiDEA

OtherIsitimportanttowritegoodcode?MustHaveSoftware2008EditionDatabaseOUTPUTingDat...

# re: Is it important to write good code?

Wednesday, October 15, 2008 1:33 AM by Jenny

Writing good code is not only important but very essential. Program length can be reduced if you are a good programmer. It gives a good look and feel of the program.

==================

Jenny

[url = http://www.legalx.net] DUI [/url]

# re: Is it important to write good code?

Wednesday, October 15, 2008 2:24 AM by Fred

Refactoring is always a good thing.

In this specific case, you are making it worst though. The original code was easier to read and maintain.

Unless you have at least 5 other kinds of tickets or customer, not worth it.

It took me 5sec to understand the first version, about 30 sec for the switch one, and a minute for the other.

Second of all, your switch/poly implementation is broken. It won't pass the initial unit tests, since you changed the "default" value from 50/50/50 to 20/30/30. Or that was an actual bug fix?

In a real world application, this would not be coded like that, but simply put in a database table or flat file, so that it can be edited without recompiling. Think about inflation and taxes.

For that few cases, up to 10 if/else, if it fits on a page don't touch it, not worth the fuss.

Second, if someone added two new rules to the first version and then augmented the price by 3% on the if/else version, and you decided to refactor it in your branch, would you be volunteer to figure out how to merge all this to the head or to even know 3 months later that the thing is actually "equivalent", how about a coworker 9 months after you left for a better job offer?

How about if four different point releases, needs to be synchronized? Let say customer A, B, C and D have 4 customized versions of the code with various iterations of that one?

A has original if/else,

B has original if/else with 3% inflation,

C has original in polymorphism and

D has original with 3% in polymorphism.

What's your strategy to merge back changes safely? (where this file is just one in about 1,000 others, what happens if you do that to let say 50 different files, what happens if you split those changes to many files, since you created new classes, now someone must read and keep track of all those classes while back merging?)

Instead of reading just few lines, now I have to read how many different files to really "get it" ?

Finally, the business use case was not explicitly commented in the code, so unless you spoke to the business analyst you should not touch the code. PERIOD.

Don't get me wrong, I'm the first one to refactor code and merge things, but this "school assignment use case" is simply way overkill to be refactored like you did.

Not worth it. If you actually did that, then you have to put a nice note in the source code, saying what you did and where so people who actually merge back don't screw things up.

Also, the point of using polymorphism is to make things BETTER not WORST.

If you use polymorphism and it makes less code to maintain and less bugs and more obvious business rules, then kudos.

So, if I were you when I would have actually make the change?

The boss comes to me and he have 10 changes to make to the price table and he wants to implement a more complicated algorithm, then it's worth refactoring.

1. He will explain me the business rules, which I will write down as comments.

2. Mark the old code as "Version 1: did that old logic" and commit and tag.

3. Change the code "Version 2: those all these complicated things", commit and tag.

*** If it ain't broken, don't fix it yet.

*** Wait until someone explains it to you and have a business occasion for you to refactor the code.

# re: Is it important to write good code?

Wednesday, October 15, 2008 10:23 AM by Human Being

Is your house spotless?  Is your car cherry?  Do you tell your wife and children you love them every day?  Do you only eat "perfect" food?  Do you exercise 60 minutes every day?

It's an imperfect world.  Perfect = obsessive/compulsive.

# re: Is it important to write good code?

Wednesday, October 15, 2008 4:24 PM by Brett Wejrowski

I think the biggest area programmers lack experience and knowledge in is project management.  A good rule for a project is the rule of thirds: 1/3 of your time is spent planning, 1/3 spend coding, and 1/3 spent debugging.  Most people like to jump right into writing code, and it causes the code to get sloppy by creating the need to fixes or hacks in your own code.  

The more you can learn to plan a project well, the easier it will be to code and code well.  Try taking a little extra to plan your progam out, and the code will start to clean itself up.

# re: Is it important to write good code?

Wednesday, October 15, 2008 6:30 PM by Jerome Paradis

I agree with Joe M that it should be data driven.

Prices should not be in code (except in unit tests) they should be in a some sort database (rel DB, config, whatever). Otherwise, it is not maintainable in the long run. Who expects prices to never change? In any case, the application using this code needs a database anyway since it depends on customers.

In my opinion, for this code to be future proof, you need the type of customer and the price/rebate depending on the customer type to be in tables. This way you can add customer types, new pricing and edit prices. Load them once in static properties or though caching.

# re: Is it important to write good code?

Thursday, October 16, 2008 2:53 AM by Fredrik N

I was interesting to read all the comments I got. About the price being fixed to the Customer classes and Movies, well maybe I used a too easy and stupid example, but assume the Price is calculated from something, in that case the number 30 could have been an algorithm and they are different for different customers.  In that case a data driven approached will not help us, and of course somewhere we have probably saved the “original” price. Most comments are based on your earlier experience and how you solved stuff. This post was more about using one of Martin Fowlers stated Refactoring methods, replacing conditional statements with Polymorphism.

# re: Is it important to write good code?

Friday, October 17, 2008 5:29 AM by OA

I would write it as:

Price=20

if Trans then Price += 10

if VIC then Price -= 10

# re: Is it important to write good code?

Saturday, October 18, 2008 11:39 PM by James Dunne

I heartily disagree with almost all of your post, except that writing good code IS important.

The grounds for your example are erroneous and misleading at best.  We, as software engineers, are tasked with the problem of designing *systems* to process data, not writing "programs" full of "code" to handle explicit business logic like this example.  This is the distinction we as software engineers need to be making in the first place.  Your business customer should not care about this distinction.  "Everything should be made as simple as possible, but not simpler."

By refactoring this code, you're driving the decisions that need to be made by your program at a higher level down into the lower level of the runtime type system.  This just makes things more wrong than they were before.  In my experience, object-oriented design (and polymorphism thereof) is best suited to serve developers' interests in writing clean, elegant, reusable code in systems, almost never for mapping business problem domain models directly in to code form.

# re: Is it important to write good code?

Sunday, October 19, 2008 3:13 AM by Fredrik N

@James Dunne:

"Your business customer should not care about this distinction. Everything should be made as simple as possible, but not simpler."

"In my experience, object-oriented design (and polymorphism thereof) is best suited to serve developers' interests in writing clean, elegant, reusable code in systems"

How about the people that should maintain it after you are done? Of course we should deliver something that solves a customer’s business need, but isn’t it also important to make sure our code is easy to understand and easy to maintain for our successor?

"almost never for mapping business problem domain models directly in to code form."

I totally disagree with you; a domain model is based on objects, like Customer, Order, Container, Ship etc. Take a look at Eric Evans book about Domain Driven Design if you haven’t done it before. Object thinking by David West is also an interesting book, as David West and David Parnas wrote: "Thinking like a computer is the prevailing mental habit of traditional developers. It’s a bad habit." Instead he is talking about thinking as an Object.

# Weekly Web Nuggets #34

Monday, October 20, 2008 9:20 AM by Code Monkey Labs

Pick of the week: Productivity 2.0: How the New Rules of Work Are Changing the Game General Is It Important To Write Good Code? : Fredrik Normén says, “absolutely yes”, and I completely agree! Mocking and Stubbing Easier Then Ever With Moq 2.6 : Daniel

# Delicious 081013 ~ 081019 | ur-ban.com - Richard Hart

Tuesday, October 21, 2008 6:19 AM by Delicious 081013 ~ 081019 | ur-ban.com - Richard Hart

Pingback from  Delicious 081013 ~ 081019 | ur-ban.com - Richard Hart

# 10 conseils non techniques pour debugger votre application - applicable à toutes technologies

Wednesday, October 22, 2008 11:30 AM by Atteint de JavaScriptite Aiguë [Cyril Durand]

Lorsque l'on code, on passe une grande partie de notre temps à debugger notre code, voici donc 10 conseils

# re: Is it important to write good code?

Thursday, October 23, 2008 8:20 AM by DranDane

Hello,

Your example is not really correct. What if you don't work with a price and a rebate ? It's not a bad example but it doesn't reflect the reality. I think you can't always simplify a double switch/case statement (matrix) in a simple method.

I already asked the question on a french forum (www.developpez.net/.../principe-programmation-switch-case). How to simplify, to better write a  switch/case statement. Some solutions are interesting.

# re: Is it important to write good code?

Tuesday, November 04, 2008 6:44 AM by Stefan Bergfeldt

The #1 most important thing must be to write working code. There's no point writing readable or maintainable code if it doesn't work.

However, I like the example.

# re: Is it important to write good code?

Tuesday, November 04, 2008 7:05 AM by Fredrik N

@Stefan Bergfeldt:

"The #1 most important thing must be to write working code. There's no point writing readable or maintainable code if it doesn't work"

That is why TDD and Refactoring goes well in hand. Problem with some developers is that they are satisfied only if the code works and don't care about the rest. So the #1 rule must be: Most important thing must be to write working code which other people can understand, just a thought ;)

# gearhed.com &raquo; Blog Archive &raquo; Best of the web - my pick for October 2008

Pingback from  gearhed.com  &raquo; Blog Archive   &raquo; Best of the web - my pick for October 2008

# Best of the web - my pick for October 2008 | zbStudio.net

Thursday, January 01, 2009 2:06 PM by Best of the web - my pick for October 2008 | zbStudio.net

Pingback from  Best of the web - my pick for October 2008 | zbStudio.net

# Weekly Web Nuggets #34

Sunday, February 22, 2009 10:44 PM by Code Monkey Labs

Pick of the week: Productivity 2.0: How the New Rules of Work Are Changing the Game General Is It Important To Write Good Code? : Fredrik Norm&eacute;n says, &ldquo;absolutely yes&rdquo;, and I completely agree! Mocking and Stubbing Easier Then Ever With

# re: Is it important to write good code?

Tuesday, June 01, 2010 9:04 AM by Abhishek

Nice example, I was just wondering what all solutions could be possible to this problem statement. I never thought of having new property rebate that solution looked very tailored made to this problem, nevertheless I loved your approach and believe as a developer I will always think twice before implementing any switch statement. Thanks again.

# Writing good code

Friday, January 21, 2011 6:48 AM by Writing good code

Pingback from  Writing good code

Leave a Comment

(required) 
(required) 
(optional)
(required)