Code Monkey home page Code Monkey logo

collections-interface's Introduction

collections-interface's People

Contributors

xedinunknown avatar

Watchers

 avatar  avatar  avatar

collections-interface's Issues

Re-think collections

Time to take a shot again at the problem described in #4. The requirements have changed, and the goals became clearer.

  • The PSR-7 standard provides a means of retrieving values by key, and is being used extensively in both Dhii and RebelCode codebases.
  • This standard has been segregated further in a Dhii implementation - specifically separating has() into a new interface HasCapableInterface.
  • We have a lot more data about the usage of such interfaces, and their forward compatibility.
  • There hasn't yet been a case where we absolutely needed to mutate an object.
  • Looks like utility methods such as intersect() (which could compute a mapping of values/keys that are similar between two collections) is not the concern of the collection itself.

This time, interfaces will look like this:

  • Meaningful and concise names.
  • No mutators.
  • Only the bare minimum.

Add Set Interface

The Problem

Issue #4 mentions multiple subtypes of collections, which are not inter-compatible, but are all compatible with collections themselves. One such subtype should be the Set, which represents an un-ordered key-less collection of unique items.

Suggested Solution

Create SetInterface, exposing all functionality of a set.

Add Missing Container Pieces

With the dhii/data-container-interface repo deprecated, parties still need interoperability with regard to containers. This appears to fit rather well with the concept of collections, which includes maps, which are inherently containers.

Add the missing interfaces.

Split Interfaces Into Smaller Meaningful Pieces

The Problem

Interfaces are currently quite monolithic. For many purposes, a collection that can have items added and removed is suitable. But there are cases where a read-only, or a write-only collection is necessary. Or one that can have items added and accessed, but not removed.

Suggested Solution

Break interfaces into multiple smaller interfaces. This should be done with the following considerations in mind:

  • There can be different kinds of collections, such as sets, lists, or maps.
  • All specialized interfaces of each type must extend a base interface of that type, e.g. ReadableMapInterface extends BaseMapInterface.
  • Base interfaces of all types must extend a single base interface, e.g. BaseMapInterface extends BaseCollectionInterface.
  • Where possible, specialized interfaces of each type should extend a generic collection interface with a similar specialization, e.g. WritableMapInterface extends WritableCollectionInterface

This way, a very large level of generalization and specialization can be achieved, because the consumer can implement any set of interfaces to expose only the functionality that they wish, and their consumers can depend on only that also.
Additionally, "composite" interfaces can be created to help consumers overcome the problem of not being able to typehint more than one type for the same parameter.

Add map factory

Add a MapFactoryInterface. It should extend ContainerFactoryInterface and IteratorFactoryInterface. This could be problematic, because the config key that stores the items must also be the same for LSP.

Correct version and docs

  • The API has changed also completely, which must be followed by an increase in the minor version number.
  • The readme appears to have a broken link.

Add writable set

It's useful to be able to write items to a set.

Extend set interface with method add().

BC-Breaking Change In ContainerInterface

The Problem

In php-fig/container@6c2bc7f (see comments), BC is broken, and parameters now require typehints. On top of that, the min PHP version is also increased. Furthermore, there will likely be other BC-breaking changes on the master branch, which will break this package.

Suggested Solution

Add a stability flag to psr/container dep, e.g. ^1.0@stable. This will allow installation of only released versions. Hopefully, in the future BC-breaking releases the major version wil be increased...

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.