top | item 46261995

(no title)

beagle3 | 2 months ago

OOP is different things to different people, see e.g. [0]. Many types of OOP that were popular in the past, are, indeed, dead. Many are still alive.

[0] https://paulgraham.com/reesoo.html

discuss

order

bpavuk|2 months ago

I'd personally declare dead everything except 3 and 4 because, unlike the rest, polymorphism is genuinely useful (e.g. Rust traits, Kotlin interfaces)

trivia: Kotlin interfaces were initially called "traits", but with Kotlin M12 release (2015), they renamed it to interfaces because Kotlin traits basically are Java interfaces. [0]

[0]: https://blog.jetbrains.com/kotlin/2015/05/kotlin-m12-is-out/...

i_am_a_peasant|2 months ago

1 is about encapsulation, that makes it really easy to unit test stuff. Say you need to access a file or a database in your test, you could write an abstraction on top of file or db access and mock that.

2 indeed never made sense to me since once everything is ASM "protected" means nothing, and if you can get a pointer to the right offset you can read "passwords". This claim of enforcing what can and cannot be reached from a subclass to help security never made sense to me.

3 i never liked function overloading, prefer optional arguments with default values.. if you need a function to work with multiple types of one parameter, make it a template and constrain what types can be passed

7 interfaces are a must have for when you want to add tests to a bunch of code that has no tests.

8 rust macros do this, and it's a great way to add functionality to your types without much hassle

9 idk what this is