Wrecking Balls and Code Falls: Demolishing Anti-Patterns in Software Construction

Lucia Xypteras
Platform45
Published in
6 min readJun 22, 2023

--

The basic premise of anti-patterns is that while coding, we often follow certain repetitive practices known as patterns. However, within these patterns, there are some specific approaches that may initially seem beneficial but eventually have negative consequences and unforeseen drawbacks. These problematic approaches are referred to as anti-patterns.

Characteristics of anti-patterns:

1.Common Pitfalls:

Reflect recurring mistakes or poor practices that are commonly encountered.

2.Negative Consequences:

Can lead to increased complexity, reduced maintainability, decreased performance or poor quality.

3.Suboptimal Solutions:

Suboptimal solutions in terms of design, efficiency and can lead to code that is hard to understand and maintain.

4.Contrast to Best Practices:

Contrary to best practices, design principles or industry standards.

5.Identifiable Patterns:

Often exhibit recognizable patterns or characteristics that can be identified and analysed.

To put it simply, anti-patterns are commonly encountered mistakes or poor practices in coding that have negative consequences, provide suboptimal solutions, deviate from best practices, and can be identified through their recognizable patterns or characteristics.

To better understand anti-patterns, let’s use the analogy of building a house. Imagine you have a blueprint and commence the construction process. However, during the construction, you might make errors or take shortcuts that appear convenient at the time but end up causing long-term issues. These mistakes and shortcuts are akin to anti-patterns in coding.

Object-oriented anti-patterns:

These are anti-patterns that occur at the blueprint level of software development, where you define the objects that will be used to build your application.

When designing without proper consideration, you create objects that are hard to use, maintain, or understand for others.

It’s like drawing your blueprint in reverse, or using the wrong measurement system (imperial for a metric blueprint). Theoretically all the information is present, and everything might technically work, but interacting with or interpreting it becomes extremely challenging.

Instead of focusing on doing one thing well, you attempt to combine multiple functionalities into a single location. It’s like wanting a house that doubles as a restaurant, amusement park, hotel, and shopping mall. This leads to anti-patterns such as the “God-object,” “Big Ball of Mud,” “Swiss Army Knife,” and “Lack of Modularity.’

Software Design anti-patterns:

Software design anti-patterns can be likened to adding unusual or surprising behaviours or components to a house, resulting in unexpected consequences.

For example, imagine if all the locks in the house turned in the opposite direction to what is customary, or if all the light switches were installed upside down.

Initially, these deviations may not appear to be significant issues, but once the software is built, they become an ongoing source of frustration and mistakes.

Now, let’s imagine a scenario where the development team is unclear about the proper sequence of construction steps, and step 4 is performed before step 3, chaos ensues, and everything becomes entangled. Moreover, the team may attempt to accomplish too much within a confined space, as they are pressed for time and attempting to handle all tasks simultaneously.

The electrician is attempting to run wires, while the painter is painting the walls, and the tiler is trying to lay down tiles simultaneously. This situation resembles a nightmare episode of the TV show “Clean House,” with Niecy Nash positioned in the corner, shaking her head at you in silent disapproval.

These software design anti-patterns, such as “Input-Kludge,” “Interface Bloat,” “Race Hazard,” “Tight Coupling,” and “Over-Engineering,” ultimately lead to the emergence of “Spaghetti Code.”

When these problems are allowed to occur without effective resolution, they intertwine with each other and create a tangled mess.

Testing anti-patterns:

The purpose of writing tests in software development is to validate that the constructed “system” adheres to the specified requirements.

Just like your house would need to meet safety regulations and design requirements, it’s crucial to validate not only that the structure matches the blueprint but also that it meets your desired specifications.

Imagine a scenario where the blueprint indicates a 300 square metre house, but the actual design and construction result in a mere 10 square metre house — A CENTRE FOR ANTS, if you will!

In testing, anti-patterns emerge when the inspection process is compromised, similar to a situation where an inspector has been bribed. These anti-patterns involve passing tests and giving the impression that everything is fine, but in reality, they fail to verify the critical aspects they were intended to test — such as the structural integrity of the building.

The challenge lies in crafting tests that provide confidence in the codebase, ensuring that the system not only functions as intended but also aligns with the approved design and requirements.

Programming antipatterns:

Programming antipatterns can be likened to making arbitrary choices without clear justification. It’s similar to instructing your team to construct a house on pilings without adequately explaining the unstable nature of the soil. Consequently, they build a garage on regular foundations, unaware of the issue, only for the garage to sink into the ground.

In programming, anti-patterns occur when decisions are made without considering important factors or without proper communication of crucial information. It can lead to unintended consequences and undesirable outcomes.

Methodological anti-patterns:

Methodological anti-patterns occur when a team demonstrates laziness or seeks quick fixes instead of following established methods. It can be compared to a situation where you specify the use of Italian marble, but the team takes a shortcut and opts for chipboard instead, which is far from meeting your requirements. Similarly, if waterproofing is necessary, the team may neglect it to save time, resulting in a leaky house.

In software development, methodological anti-patterns reflect a lack of discipline or adherence to proper procedures. It involves taking shortcuts or neglecting essential steps, compromising the quality and reliability of the final product.

What is the best practice?

Best practices in programming involve learning from the mistakes and experiences of seasoned programmers who have identified consistent patterns. These experts have developed rules and guidelines to help you steer clear of these pitfalls. While following best practices is not foolproof, they provide a level of protection and guidance.

By adhering to best practices, you can benefit from the collective wisdom of the programming community. These practices have been refined over time and have proven effective in improving code quality, maintainability, and overall development efficiency. They serve as a set of standards and guidelines to help you make informed decisions and write high-quality code.

At Platform45, we prioritise the adoption of best practices and are committed to avoiding anti-patterns in our programming approach. By embracing the knowledge and insights shared by experienced programmers, we aim to create code that is robust, maintainable, and efficient. We understand that best practices serve as a foundation for producing high-quality software solutions.

Our team recognizes that while following best practices is not a guarantee of perfection, it significantly reduces the likelihood of encountering common pitfalls and ensures a smoother development process. We continually strive to stay updated with the latest industry standards and guidelines, leveraging the collective wisdom of the programming community to deliver superior results.

By adhering to best practices, we uphold our commitment to providing reliable, tailored and well-crafted software solutions to our clients. Through rigorous testing, code reviews, and adherence to established principles, we strive to exceed expectations and deliver products that stand the test of time.

--

--

Lucia Xypteras
Platform45

Business strategist specializing in brand and marketing.