Tim H writes:

Some say that OOP was the greatest mistake of all. I say they weren’t trying hard enough.

This code is C++, though Tim submits it as "C with classes." That usually means "we write it as much like C as possible, but use classes to organize our modules." In this case, I think it means "we use classes to punish all who read our code".

Let’s look at an example. They’ve been anonymized, but the shape of the code is there.

class Base {
public:
enum class Type {
derived_1,
derived_2
};

Base(Type t) : t_{t} {}

Type getType() const { return t_; }

private:
Type t_;
};

class Derived_1 : public Base {
public:
Derived_1() : Base(Base::Type::derived_1) {}
};

This is what one might call "inheritance". You shouldn’t, but you might. Here, the ba…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help