DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Are you a boy scout coder?

Swizec Teller user avatar by
Swizec Teller
·
Jan. 22, 12 · Interview
Like (0)
Save
Tweet
Share
9.56K Views

Join the DZone community and get the full member experience.

Join For Free

the boy scouts have a rule: “always leave the campground cleaner than you found it.” if you find a mess on the ground, you clean it up regardless of who might have made the mess. /../ the original form by robert stephenson smyth baden-powell, was “try and leave this world a little better than you found it.”

what if we followed a similar rule in our code: “always check a module in cleaner than when you checked it out.” no matter who the original author was, what if we always made some effort, no matter how small, to improve the module. what would be the result?

by uncle bob at o’reilly commons

lieut. gen. robert stephenson smyth baden-powe...

image via wikipedia

when i first saw this rule in clean code i loved it! it’s just such an awesome rule. you come into a file, you clean it up a little bit. remove a stupid comment, indent something better … anything.

it makes the world a better place and everyone a happy camper right?

well, this might be great in theory and work well when you are employed by a company where you will spend the next few years of your life. the software you’re working on will live and grow with you, with your team. you are the guy shouting “fuck this! who the fuck made this code! this is bloody impossible to maintain!” a year from now.

for a freelancer the situation is a bit different.

here you are, plomped into the middle of an ongoing project. decisions have been made, rabbit holes have been followed. the deadline is in a month and as a crack team of one specialist on a tight deadline, you’re making nice gold per hour.

right there in front of you. a mess. code so ugly, so horrible, it would make a grown man cry. you’re just supposed to add a feature. figure out the mess, add two or three lines of code, cross your fingers and hope for the best.

or should you rewrite the whole function?

rewriting would be the right thing ™ to do. the code will be more maintainable, easier to test, it will save your client a bunch of money down the line. you won’t be maintaining this so you have a responsible towards everyone coming after you to fix something.

but, right now, right this very instance, you are strong-arming the poor client to pay more. sure, you’re making the code better, but they care about that one feature. should you really spend three hours rewriting the code instead of one hour adding something and hoping for the best?

on the other hand: when the messy code breaks, and it will break, it will be your fault. you’re the last guy who touched it. not rewriting will come back to haunt you. the guy who maintains your code will curse you in their sleep and dream of delicious murder. and it’s not even your code!

so what do you do?

personally i always try to rewrite crappy code. add testing suites. anything i can do to make the codebase better. but i always carefully explain the situation to my client. why am i doing this, how is it benefiting the client . it’s important to make them understand i’m not just inventing work to rake in more gold.

clients are surprisingly permissive most of the time and i can sleep better at night. win-win!

source: http://swizec.com/blog/are-you-a-boy-scout-coder/swizec/3471

code style

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How Elasticsearch Works
  • Monolithic First
  • Introduction to Container Orchestration
  • Apache Kafka Is NOT Real Real-Time Data Streaming!

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: