this post was submitted on 14 Nov 2024
90 points (95.9% liked)

Programmer Humor

19551 readers
693 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 16 hours ago* (last edited 15 hours ago)

inheritance to avoid code duplication

What no, inheritance is not for code sharing

Sound bite aside, inheritance is a higher level concept. That it "shares code" is one of several effects.

The simple, plain, decoupled way to share code is the humble function call, i.e. static method in certain langs.