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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

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
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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Is Agile Right for Every Project? When To Use It and When To Avoid It
  • Breaking Bottlenecks: Applying the Theory of Constraints to Software Development
  • 7 Effective Conflict Resolution Strategies for Software Development Teams
  • Seamless Security Integration Strategies in Software Development

Trending

  • A Complete Guide to Modern AI Developer Tools
  • Mastering Advanced Traffic Management in Multi-Cloud Kubernetes: Scaling With Multiple Istio Ingress Gateways
  • The Human Side of Logs: What Unstructured Data Is Trying to Tell You
  • Transforming AI-Driven Data Analytics with DeepSeek: A New Era of Intelligent Insights

The Boy Scout Software Development Principle

Leave your code in a better state than you find it, in every single pull request

By 
Thomas Hansen user avatar
Thomas Hansen
DZone Core CORE ·
Aug. 21, 20 · Opinion
Likes (15)
Comment
Save
Tweet
Share
9.3K Views

Join the DZone community and get the full member experience.

Join For Free

Boy scouts have an easily understood philosophy, which is that they should always leave their campsites in a better condition than the state which they found it in. Cleaning away one piece of garbage each, or something equivalent, creates a situation where a visit from a boy scout group, becomes a great experience for everybody else. Developers can learn a lot from this philosophy.

Every single time you create a pull request, the code you commit should "pick up one piece of garbage", by refactoring it somehow, making it more easily read, and/or performing better somehow. If you make a habit out of this, then over time your codebase will slowly become better.

Pick up other people's garbage

If you do it, and you instruct your developers to also do it, after a while everybody will do it. Below is an example to get you started.

C#
 




x
10


 
1
void Foo(int val)
2
{
3
  if (val != 0)
4
  {
5
    /* ... Do stuff with val ... */
6
  }
7
  else
8
  {
9
    throw new ArgumentException("Val is 0");
10
  }
11
}


For the seasoned developer, spotting the garbage in the above method is fairly simple. Hint: Invert your if! Let me show you a simpler version, with less garbage, to illustrate my point.

C#
 




xxxxxxxxxx
1


 
1
void Foo(int val)
2
{
3
  if (val == 0)
4
    throw new ArgumentException("Val is 0");
5
  /* ... Do stuff with val ... */
6
}


By simplifying and inverting our above if statement, we reduced the size of the code from 11 lines to 6 lines. 50% of the code gone! And we did it without changing any logic what so ever. The code is more easily read, which makes it more easily maintained, and the method as a whole more easily fits into a single screen, without scrolling, making it a much more pleasant experience to go back to it 6 months down the road, to add another feature to it ...

I could add more to this article - However, that would only add garbage to it - So I'll leave it here for now :)

Software development

Opinions expressed by DZone contributors are their own.

Related

  • Is Agile Right for Every Project? When To Use It and When To Avoid It
  • Breaking Bottlenecks: Applying the Theory of Constraints to Software Development
  • 7 Effective Conflict Resolution Strategies for Software Development Teams
  • Seamless Security Integration Strategies in Software Development

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!