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

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • AI Philosophy and Its Part in Digital Design
  • Goodhart's Law: A Basic Introduction
  • Building Reactive Scalable Systems
  • The Laws of Computer Science

Trending

  • Breaking Free From the Cloud With Kamal: Just Enough Orchestration for Your Apps
  • Traffic Management and Network Resiliency With Istio Service Mesh
  • How to Configure Istio, Prometheus and Grafana for Monitoring
  • Supercharging Productivity in Microservice Development With AI Tools

Non-Redundancy and Testability

Have you ever inherited a code base full of redundancies? One dev argues for the need to standardize practices such as the Open-Closed Principle.

David Bernstein user avatar by
David Bernstein
CORE ·
Jul. 28, 17 · Opinion
Like (4)
Save
Tweet
Share
3.41K Views

Join the DZone community and get the full member experience.

Join For Free

Redundancy is always a maintenance issue. If you have to change redundant code, you have to do it in multiple places. If you have to extend redundant code, you have to do it in multiple places. When you have to test redundant code, you have to modify tests in multiple places.

You get the idea.

Have you ever heard of Shalloway’s Law? Al Shalloway is a brilliant thought leader, the CEO of Net Objectives, and a good friend. He was trained as a mathematician at MIT and likes to poke fun at himself so he has what he calls Shalloway’s Law—I actually own a t-shirt that has Shalloway’s Law written on it.

Shalloway’s Law says that “When n things need to change and n is greater than one, Shalloway will find at most n-1 of these things.”

In other words, like the rest of us, he’s fallible, and when there’s more than one thing that needs to change in a computer system, it’s easy to miss at least one of them.

As a result, he came up with what he calls Shalloway’s Principle, which states: “Avoid situations where Shalloway’s Law applies.”

This is good advice. Build code that’s maintainable by minimizing the impact of what needs to change when business rules change.

This relates to the Open-Closed Principle, which states that software entities, such as classes and methods, should be open for extension but closed for modification. In other words, I want to limit the code in my system that needs to be changed as I extend the system. I want to build systems in such a way that whenever I extend it I’m having a minimum impact on existing code even if that means I have to write a lot more new code to compensate for or accommodate this new requirement.

Developers don’t mind writing new code. They actually like it. It’s what we do. What developers don’t like is changing existing code, especially if someone else wrote it.

First of all, you have to understand it and invariably when someone else writes software they do it differently than the way we would. We then have to sort of get into their minds because there are currently very few standards and practices in our industry. I do hope and pray that it will change soon. But as of now, and in the foreseeable future, we’ll be dealing with a lot of poorly written and difficult to work with legacy code.

I do have faith that we’ll slowly dig ourselves out and start building software that’s more in alignment with those principles because this, I believe, is the guiding light in software development. We developers should focus on finding ways to support the Open-Closed Principle by building software that can be extended rather than changed to accommodate more features. We do this by centralizing business rules, centralizing instantiation by taking common routines and putting them in a shared place so they can be used by multiple callers rather than having each caller have its own implementation.

How much software in production today would you say is redundant?

Even within a single operating system, I propose that if we pay attention to collapsing redundancy we can reduce the executable footprint by at least 50%. That’s my guess. I have no facts to back that up, but I do have a lot of anecdotal evidence to suggest that we developers reinvent the wheel over and over but with subtle and sometimes not so subtle differences.

Sometimes I don’t see the redundancy in my code but I find myself writing a redundant test and realize that my code is redundant as well. There are lots of techniques for finding redundancy and eliminating it in code, and I’ve written about this here and in my book Beyond Legacy Code: Nine Practices to Extend the Life (and Value) of Your Software.

The bottom line is: the less redundancy in a system, the more straightforward and cost-effective testing and maintenance becomes.

philosophy

Published at DZone with permission of David Bernstein, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • AI Philosophy and Its Part in Digital Design
  • Goodhart's Law: A Basic Introduction
  • Building Reactive Scalable Systems
  • The Laws of Computer Science

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

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

Let's be friends: