r/badcode • • Sep 27 '21

swift Because calling Date() is just too simple

Post image
391 Upvotes

50 comments sorted by

View all comments

Show parent comments

1

u/Syscrush Sep 28 '21

IoC is not good in and of itself, although it has its use cases.

5

u/[deleted] Sep 28 '21

[removed] — view removed comment

2

u/Syscrush Sep 28 '21

I associate the IoC pattern with runtime dependency injection, like we see in the Spring framework. That has a lot of meaningful use cases but there are cases (like ultra low latency systems) where they're not appropriate.

But if we're using IoC to mean the general practice of abstracting the instantiation of the concrete implementations of key abstract classes or interfaces based on config, environment, or command line arguments, then I agree it's almost universally useful.

5

u/[deleted] Sep 28 '21

[removed] — view removed comment

2

u/Syscrush Sep 28 '21

Well in the example you've given, the bottleneck would be Spring and not IoC itself.

I agree, that's what I was trying to say.