yohang / Finite

A Simple PHP Finite State Machine
http://yohan.giarel.li/Finite
MIT License
1.31k stars 188 forks source link

Interfaces and public method #21

Closed liuggio closed 8 years ago

liuggio commented 10 years ago

namespace Finite\Transition\Transition implements TransitionInterface

but the Transition class has more public methods than the interface, public method are API, and they should respect the interface, this is very important for future BCs.

The task is for all the Classes that doesn't respect the interface, move the functions to protected before the stable version.

yohang commented 10 years ago

Hi,

I agree, but the only additional method in the Transition is addInitialState, and i don't think it has to go in the Interface, nor make it protected, as it won't be useful anymore.

As methods inside that takes a Transition inside Finite are Typehinted TransitionInterface, there is no reasons to introduce future BC by exposing additional, not used in Finite, methods.

liuggio commented 10 years ago

Sorry I don't get if the method is public IS an Api for other classes, if is an API has to be in the interface.

If I want to swap to another Transition the new class has to respect the interface (and not other classesI) and then if someone uses that method, the app will be broken.

sagikazarmark commented 9 years ago

I would like to mention some other thing here which is also related to an interface:

The StateMachineInterface contains a getDispatcher method which IMO should not be there. The StateMachine implementations does not necessarily have an event dispatcher, or not necessarily symfony's one. It is an implementation detail implemented in StateMachine object, but has nothing to do with the interface, at least introduces an (IMO) unnecessary coupling.