this post was submitted on 28 Oct 2024
505 points (98.3% liked)

Programming Humor

2757 readers
36 users here now

Related Communities [email protected] [email protected] [email protected] [email protected]

Other Programming Communities [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 2 months ago (9 children)

This is your brain when you OD on OOP.

[–] [email protected] 16 points 2 months ago (8 children)

There's literally nothing related to OOP in this snippet.

[–] davidagain 5 points 2 months ago* (last edited 2 months ago) (6 children)

You're right, this is just not oop AT ALL.

For the correct OOP solution, you would need consider whether this can be thought of as a kind of stateless leaf method, and therefore implement it as an abstract (singleton) factory, but on the other hand, if you're using a context object with the registry pattern, you should probably do this properly with IoC containers. Of course, if your object graph isn't too complex or entangled, you could always just do constructor injection but you risk manging your unit tests, so I would go cautiously if I were looking in that direction.

[–] Omgpwnies 4 points 2 months ago (1 children)

I was just thinking it needed more factories

[–] davidagain 3 points 2 months ago

What about a factory for the factories! There's nothing more efficient than a tool making tool making tool.

load more comments (4 replies)
load more comments (5 replies)
load more comments (5 replies)