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

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

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

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

  • Open Source: A Pathway To Personal and Professional Growth
  • Enhancing Software Quality with Checkstyle and PMD: A Practical Guide
  • Linting Excellence: How Black, isort, and Ruff Elevate Python Code Quality
  • Mastering GitHub Copilot: Top 25 Metrics Redefining Developer Productivity

Trending

  • Java Virtual Threads and Scaling
  • Unlocking AI Coding Assistants Part 2: Generating Code
  • Evolution of Cloud Services for MCP/A2A Protocols in AI Agents
  • Java's Quiet Revolution: Thriving in the Serverless Kubernetes Era

5 Practices to Eliminate Bad Code

DZone's Community Leader sat down with several industry experts to take a look at how we can put an end to bad code once and for all.

By 
Justin Albano user avatar
Justin Albano
DZone Core CORE ·
Thomas Hansen user avatar
Thomas Hansen
DZone Core CORE ·
Ray Elenteny user avatar
Ray Elenteny
DZone Core CORE ·
Blake Ethridge user avatar
Blake Ethridge
·
Feb. 11, 20 · Interview
Likes (30)
Comment
Save
Tweet
Share
40.5K Views

Join the DZone community and get the full member experience.

Join For Free

person thinking

Have you ever been there? A deployment goes live and almost immediately, someone points out there is bad code somewhere causing an issue. Bad code is not fun. 

There are many ways, tools, and practices that we can take to ensure that bad code never sees the light of day in production. I sat down with several industry experts to take a look at how we can put an end to bad code once and for all.

Eliminating bad code? We got this!

You may also like: 3 Reasons Why People Write Insanely Bad Code

Step One

“Computers do not assign meaning to structures or apply semantics to statements. Instead, they blindly store bits in registers, flip the input of gates, and electrically transfer data across buses. Too often, we make the mistake of writing code that a computer can understand, rather than a human.

We shorten variable names, create cryptic structures, and even provide comments to mask the obscure nature of our code. If we want to write better code, we need to focus on writing code for people. Whether it is a coworker in our office, an open-source contributor half a world away, or ourselves, people are the primary readers of code.

One of the best ways to write good code is to write code for a human audience. We need to change our approach and write code as if it were a book: A book that reads from top to bottom and tells the story of the problem being solved. A book that uses variable names, method names, class names, conditional statements, and the other programming pieces as the sentences, paragraphs, and chapters that explain to a person how our application solves the problem at hand.

This is more of an art than a science, and it takes great discipline and practice, but it pays immense dividends. Always write code so that a stranger can read it and easily deduce exactly what it is trying to accomplish.”

— Justin Albano (@justinmalbano), Software Engineer at Catalogic Software

Step Two

"In order to reduce the amount of bad code we see; I believe in being inspired by alternative sources. For instance, I oftentimes myself perceive coding as more of an art form than engineering. If we then allow for this art form to become inspired by other types of art forms, such as music, painting, sculpturing, etc. — It will draw people into wanting to understand it.

To facilitate this, ask yourself the questions of "What rhythm does my code have", and "What's the color profile of this particular piece of code", etc. This allows you to see the code from a more holistic perspective, making it appear to have a uniform whole, instead of multiple brilliant details, clashed together, resulting in a patchwork of different styles.

Beautiful code should "sing" to the recipient, and be amazingly simple to understand, and the product as a whole should be based upon a single idea, and this idea should be visible throughout the entire product. In such an environment, creating bad code becomes almost impossible. Basically, standardize the way you produce code.

To standardize your code, and make it sing, make sure you use tools wherever tools can be used. Copying things off from StackOverflow, and applying a couple of bugs to it in the process, is something everybody can do. Using the right tools, is something for weird reasons fewer seem to understand the importance of. Neuro typicals use computers because they help with the task at hand. Developers should think the same way"

— Thomas Hansen (@MisterGaiasoul), Chief Crudifier at Server Gardens

Step Three

“Work with and learn with others. Most developers are passionate about their craft. Craftsman continually refines their skill. They try new things. Something that doesn't turn out quite right is looked upon as a lesson learned. Developers that get together with other developers will always learn from one another. Meetups, Birds of a Feather session, etc. provide wonderful opportunities to share and learn.

It doesn't matter how much experience you have. It's never a one-way street. Never stop learning about other languages, stacks, and tools. They were all envisioned to address a challenge. In fact, regularly develop something in new technology.

Let the tools do the mundane work. Spend time configuring IDEs, editors, command-line tools, shell environments. The more these are refined, the better one can focus on the real task at hand - delivering functionality. It's not just about the mundane work either.

Good tools spot problems and offer suggestions. Trust them. There are decades of knowledge behind these insights. Obsess about eliminating all of the observations being made by the tools. The code will be better, people that follow will appreciate the effort, and the author of the code will have improved their skill.”

— Ray Elenteny, Principal Owner Solutech Consulting

Step Four

"In our organization all the coders do is code, but we have a fraction of the number of developers that we used to have. We try not to bury them in bug fixes because we saw so many new things written. By giving them access to the Dynatrace tool it helped them remediate problems quicker. With the DevOps now they're interfacing more with operations.


The advance with the Dynatrace tool in our company started first in software development. I got them into it because of the coding capacity of the product to be able to identify bottlenecks in the code. If I have an error, and it's a SQL error it'll drill down into the SQL statement that's causing the problem.

This saves a lot of time for developers. From there in operations, we deployed session replay so that when a customer has an issue, they can bring up the customer in session replay to and watch what was happening to be able to identify the single area that may give up and walk them through it and get it fixed."

— Mark Kaplan (@MarkDavidKaplan), Senior Director of IT at BARBRI


Step Five

“We talk about quality gates at Dynatrace, and it's basically after you execute your tests you look at these SLIs and SLOs. You hopefully have some automated process that builds, deploys, and runs tests.

Normally, right, you either had no time and just promoted it like throwing it over the wall, and now with Dynatrace, every time you deploy and test, we are monitoring everything. We monitor your response time, your resource consumption, and we monitor architectural KPIs as well.

Hey, your code used only to make one database call for this particular feature. Now you're making 50 calls, and you're making an additional call to external service. Are you aware of that? I want to make you aware of it because maybe this is actually an unintentional bad code change that should not go into production.

The good news is we're doing this fully automatically. That means if you integrate Dynatrace in your pipeline, we can let Dynatrace look at these key metrics. So, the classical response time failure rate memory consumption, but also architectural metrics. How often do we communicate with which other services?

You look at the build by build and then automatically say, "Hey, something is wrong, you just increased the number of database calls by 50%, and you included two new dependencies. Do you really want to push this into production? Yes or no?" That stops bad code, and also configuration and architectural changes before they hit production.

The best thing is if you not only do this at the end of a release if you integrate this in your build cycle of every commit. With every commit you build you deploy, you run some meaningful tests, and you'll look at the Dynatrace metrics. You're doing SLI and SLO validation, but not only on the standard performance metrics also these architectural metrics and scalability metrics.”

— Andy (@grabnerandi), DevOps activist at Dynatrace

Summary

  1. Automate everything you can automate.
  2. Treat code like art.
  3. Collaborate and learn from others.
  4. Write beautiful code human beings can understand.
  5. Use the right tools to become better. Cloud development tools like those from Dynatrace can provide entire organizations with enhanced automation that will enable developers to more rapidly deploy and free themselves from the curse of bad code practices.


Further Reading

Reusable Code: The Good, the Bad, and the Ugly

code style

Opinions expressed by DZone contributors are their own.

Related

  • Open Source: A Pathway To Personal and Professional Growth
  • Enhancing Software Quality with Checkstyle and PMD: A Practical Guide
  • Linting Excellence: How Black, isort, and Ruff Elevate Python Code Quality
  • Mastering GitHub Copilot: Top 25 Metrics Redefining Developer Productivity

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!