• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Five Lines of Code

Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How long were you programming before you came up with the 5 lines and other rules of coding practice in the book?
Posts: 31
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Thank you for the question! I have chosen to answer this with a large part of my life story :P

TL;DR: Quite a long time. See the last paragraph for actual numbers.

My father taught me to code JavaScript and PHP when I was very young, which I then did on/off until I was 15 when I started my first company building custom Content Management Systems for small businesses. At the end of my teens, I started building small online computer games, just before I started university. Although this taught me a lot about the problem-solving aspect of programming I did not think at all about quality of code, and therefore the code I produced was not very maintainable or scalable. It was somehow stable though, since some of the systems are still running to this day.

During university, I learned that "number of lines" was not a good metric for code, so my next metric for quality became performance. I was just about to read the original Gang of Four book when a professor told me to get Martin Fowler's book Refactoring instead. When I read about refactoring and started viewing code itself as something that could be manipulated, my mind was blown. As I shifted my focus towards provably bug-free code using functional programming and type theory, I always kept looking at code as something "moldable" through refactoring.

By the end of my uni years, I also started hosting two-hour tech talks every Friday, each time on a new topic. Which meant I quickly ran out of things I knew in advance and had to speed-learn a lot of new concepts. Shortly after I graduated I was talking to my best friend, and he asked if I could improvise a talk like those. I opened my computer and started typing and implemented the game that is in the book. I then said, let's try to make it better. I didn't want to explain the concepts of "code smells" so I instead I came up with rules that had the same effect. The five lines rule was the first.

All in all, that means I did seven years of "kids-programming", then five years of web, then five years of uni before I came up with the first rule. But really, the rules were already there in the form of "code smells", I only came up with an idea to make them easier to learn, and make them applicable from day one. Refactoring changed my life, so I wanted to make it as widely available -- and as easily digestible -- as possible.

I hope that answered your question.
paul nisset
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was an interesting back story.
I asked because everybody sort of goes through the same steps of-  Learn to code, get it to compile, just get it working ,make it better...
Thank you Christian.
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic