Skip to main content

Constructor injection designed with OOP in mind.

Project description

Dependencies

azure-devops-builds azure-devops-coverage pypi conda python

Constructor injection designed with OOP in mind.

Documentation | Source Code | Task Tracker

Dependency Injection (or simply DI) is a great technique. By using it you can organize responsibilities in you codebase. Define high level policies and system behavior in one part. Delegate control to low level mechanisms in another part. Simple and powerful.

With help of DI you can use different parts of your system independently and combine their behavior really easy.

If you split logic and implementation into different classes, you will see how pleasant it becomes to change your system.

This tiny library helps you to connect parts of your system, in particular - to inject low level implementation into high level behavior.

Pros

  • Provide composition instead of inheritance.
  • Solves top-down architecture problems.
  • Boilerplate-free object hierarchies.
  • API entrypoints, admin panels, CLI commands are oneliners.

Example

Dependency injection without dependencies

>>> from app.robot import Robot, Servo, Amplifier, Controller, Settings

>>> robot = Robot(
...     servo=Servo(amplifier=Amplifier()),
...     controller=Controller(),
...     settings=Settings(environment="production"),
... )

>>> robot.work()

Dependency injection with dependencies

>>> from dependencies import Injector

>>> class Container(Injector):
...     robot = Robot
...     servo = Servo
...     amplifier = Amplifier
...     controller = Controller
...     settings = Settings
...     environment = "production"

>>> Container.robot.work()

Questions

If you have any questions, feel free to create an issue in our Task Tracker. We have the question label exactly for this purpose.

Enterprise support

If you have an issue with any version of the library, you can apply for a paid enterprise support contract. This will guarantee you that no breaking changes will happen to you. No matter how old version you're using at the moment. All necessary features and bug fixes will be backported in a way that serves your needs.

Please contact proofit404@gmail.com if you're interested in it.

License

dependencies library is offered under the two clause BSD license.

— ⭐️ —

The dependencies library is part of the SOLID python family.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dependencies, version 6.0.1
Filename, size File type Python version Upload date Hashes
Filename, size dependencies-6.0.1-py3-none-any.whl (14.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size dependencies-6.0.1.tar.gz (10.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page