Member-only story

Bad Coding Practices That Seem Fine (But Aren’t!)

Bad Coding Habits You Didn’t Realize Were Hurting You

Skilled Coder
Javarevisited
7 min readJan 6, 2025

--

Photo by Chris Ried on Unsplash

Below are some less-discussed code and design “smells” — things that might appear harmless but can cause maintainability or testing headaches down the line.

Don’t be afraid to refactor away from these patterns, even if they seem “minor,” because technical debt grows exponentially over time.

Overuse of Private Methods Hiding Complexity

What’s the problem?

  • Having a few private methods is normal for breaking down large public methods. However, when a class has a large number of private methods, it often signals that the class is doing too much.
  • Complex private methods make testing harder , most testing frameworks can’t directly test private methods without reflection, so you end up either skipping important tests or resorting to hacky solutions.
  • It can violate the Single Responsibility Principle if the class has many responsibilities hidden away in private methods.

Avoid doing this

public class OrderProcessor {
public void processOrder(Order order) {
// Some high-level process
validateOrder(order)…

--

--

Javarevisited
Javarevisited

Published in Javarevisited

A humble place to learn Java and Programming better.

Skilled Coder
Skilled Coder

Written by Skilled Coder

Sharing content and inspiration on programming. Coding Newsletter : https://skilledcoder.substack.com

Responses (13)

Write a response