← Previous · All Episodes · Next →
Baffling C++ Code Practices Unveiled in CodeSOD Madness Episode

Baffling C++ Code Practices Unveiled in CodeSOD Madness

· 01:15

|

Welcome to today's episode of CodeSOD, where we dive into some particularly baffling coding practices. Today, we're exploring strange choices made in C++. An anonymous submitter came across a seemingly normal class with standard getters and setters. But things took a turn with the implementation.

The setField method was fine, but the getField method was a shocker. Instead of the expected behavior, it called a method named setGetField, passing a boolean flag to differentiate between setting and getting a value. Yes, you heard that right—a method managing both tasks based on a boolean.

Even more bizarre, setGetField contained a static variable. Our submitter was left reeling, thinking, "WTF? This must be some kind of joke." The use of static fields meant that the value was shared across all instances of the class, completely violating encapsulation principles.

After seeing this pattern repeatedly, their frustration grew: “Who hired these developers? And can that hiring manager be fired? Out of a cannon? Into the sun?” A fair question, indeed.

Join us next time for more tales of coding oddities and the lessons we can learn from them!
Link to Article


Subscribe

Listen to jawbreaker.io using one of many popular podcasting apps or directories.

Apple Podcasts Spotify Overcast Pocket Casts Amazon Music
← Previous · All Episodes · Next →