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
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report

Surgery on Legacy Code

Before your legacy code causes your applications to kick the bucket, consider making some serious and robust changes for the future.

David Bernstein user avatar by
David Bernstein
CORE ·
Aug. 27, 18 · Opinion
Like (1)
Save
Tweet
Share
3.55K Views

Join the DZone community and get the full member experience.

Join For Free

One of my early blog posts that I wrote nearly 10 years ago that I called "Sony Baloney" discussed how the electronics giant cultivated some unusual, yet highly successful practices. One of the practices that Sony is known for is taking young and inexperienced engineers and putting them on new product development, while their senior engineers focus on reworking and redesigning their successful products to be more cost-effective. I consider this to be a very wise practice and so do they.

We want innovation in new products but we always want to balance it so that our work is maintainable and cost-effective. The electronics industry pays a lot of attention to this because manufacturing is expensive. Of course, there are no manufacturing costs, per se, in the software industry but there are maintenance and ongoing costs for software and that's actually where the bulk of our funds are spent. So, paying attention to the maintainability of our code is quite important yet often overlooked.

We don't have many common standards and practices around developing software and so while software systems may be functional they are often very difficult to maintain. Most existing systems have accumulated a great deal of technical debt, which makes it difficult to work on, and in many organizations, there is a stigma around touching legacy code. This happens for good reason because when developers touch legacy code they often break it and that can be costly to an organization and embarrassing to the developer so our preference is to leave legacy code alone and when we have to go in to change or extend legacy code, we try to do it as minimally invasively as possible.

I realize that we mean well but this is often not the right choice. Surgery, if done improperly can cause great injury to the patient but that doesn't mean that every time we do surgery to remove a tumor that we should only take a part of it. In software, providing just half a solution can be as fatal to a system as removing half of a tumor in a patient.

Surgeons have figured out how to do the impossible and open a person up so that they can remove a disease. I'm sure there are many important rules and caveats around doing this safely. I would never attempt to do surgery without first going through the process of becoming a doctor; no one should.

The same thing is true when doing "surgery" on an existing legacy system. We have to understand the root causes of problems in poor code and insufficient designs so that we can find safe and effective ways of remedying a situation.

Once we know some basic refactoring skills then it's just a matter of applying them to improve the code. One of our main goals, when we refactor, is to make the design clear and straightforward. Doing this may include renaming methods and fields so that the intention of the extracted code is clear, and even extracting entire classes from methods if needed. As we do this, we call out missing components from our domain model, thus filling it in and making it more robust so it's more understandable when we work with it in the future.

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

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 11 Observability Tools You Should Know
  • Chaos Engineering Tutorial: Comprehensive Guide With Best Practices
  • Cloud Performance Engineering
  • How To Handle Secrets in Docker

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: