cover-img

Code Smell 20 - Premature Optimization

Planning ahead of time needs a crystal ball no developer has

28 October, 2022

1

1

0

Planning ahead of time needs a crystal ball no developer has.

TL;DR: Don't guess things that might not happen.

Problems

Coupling

Testability

Readability

Solutions

1.

Create great models and bijections first.

2.

Create a conclusive benchmark once the model is working.

3.

Programmers waste enormous amounts of time worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. Donald Knuth

5.

Use Test Driven Development technique. It always favors the simplest solution.

Examples

Weird data structures

Caches

Singletons

Sample Code

Wrong

Right

Detection

This is a design smell so it can not be detected by mechanical tools (yet).

Tags

Premature Optimization

Antipattern

Conclusion

Defer performance decisions until functional models are mature enough.
Donald Knuth created/compiled the best/fastest algorithms and data structures. With great wisdom he warned us of abuse. Why do we think we are smarter than him?

Relations

More info

Credits

Premature optimization is the root of all evil.

Donald Knuth
This article is part of the CodeSmell Series.

1

1

0

Maxi Contieri

Buenos Aires, Argentina

🎓Learn something new every day.📆 💻CS software engineer 👷coding👨🏽‍🏫teaching ✍🏾writing 🎨Software Design 🏢SOLID 🌉TDD 👴Legacy 💩Code Smells

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2024. Showcase Creators Inc. All rights reserved.