Giter Site home page Giter Site logo

di's People

Contributors

lemoer avatar

Watchers

 avatar  avatar

di's Issues

Design Idea

Tree Structure

A real tree structure should be used. There should be two ways to access/manipulate the child elements: python indexes with fast access node["Options/Test"] and properties node.Options.Test. Changes should not be allowed.

A Node should have:

  • Features
  • 0/1 Provider
  • N other Nodes
  • 0/1 Parent

Leafs should be like Providers. Possibilities:

  • A Leafs is a Provider
  • A Leaf has a Provider

In the main tree structure should be only Providers. If a Feature get's accessed the di library searches for a provider that implements it.

From outside the library it should not be possible to access a leaf. You should always get the Feature provided by the Provider

User's of the library should never change the features directly. Every changes should be done by calling method's or function.

Providers

Every Feature should have a Provider. A provider can have a subnode tree, where it is provides features. So a Provider can have multiple Features (1:N). When a Feature shoud get injected the Provider should decide wheter to give the Feature or not. So the Feature structure can be dynamic and isn't known at the application start. That would be a very flexible, but not the easiest way.

Services

Service Providers should convert the Service (A) in a Node. So if an other Service or Controller (B) needs a single function from (A), it just needs to require this single function. So the function is it's own Feature and can be mocked a lot easier.

Flow

  1. The tree of the Providers get's initialized.
  2. The application starts.
  3. A Feature get's loaded and needs a dependency:
    1. The Feature asks the di module for a certain path.
    2. The di module does not know yet, wheter it's a Node or Feature.
    3. It walks from the root node downwards the path
      1. It find's a Node => return it
      2. It find's a Provider => call it
      3. It can't reach the path
        1. => It's no node.
        2. Go the tree structure upwards
        3. Check whether there is a Provider providing the path

Provider

It would be cool to have a function that provides one or more features in the dependency tree. It should be able to use wildcards. Something like this:

di.implements(ConfigProvider, "Config/*")

When a feature e.g. "Config/ServerIP" is needed for an injection, the di module should ask the Provider to return this feature. So the Provider has the possibilty to create the feature, do some setup on it and return it.

(This function could also used for creating a mocking function)

No Implementation Check

Maybe I should add a check if there is an existing implementation for the module and throw an specific exception relevated to this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.