lambda

2

lambda wrote

The gist of service locators being anti-patterns is that it's essentially an obfuscated form of global variables. Instead of having your class directly look up its dependencies, your class should just accept said dependencies in its constructor. Essentially, you can put off service location until the "end of the world" (yes, I know that's a functional programming term, but it's still the same idea here). In the case of a DI container, the container's service registry is your end of the world, and you don't need to explicitly wire anything together.

To really get a better feel for DI and inversion of control, I'd recommend practicing test-driven development. If you can't write good unit tests without having to set up a ton of support code or services, then everything has gotten tied together too much.

Also, the factory pattern isn't as useful when using dependency injection. The DI container is essentially a generic object factory for everything so you don't have to.

2

lambda wrote

From what I've seen in the past, DjVu files are all scanned books and similar things. They're essentially the lowest fidelity you'll get unless you OCR the text.