Hi Julien, Le 22/04/2016 16:45, Julien Delplanque a écrit :
Hello,
I have a question about Trait.
Is it ok, in the design point of view, to use them to force an object to implement an interface?
Why not using a parent abstract class for that, with required method answering #subclassResponsability? Then from your tests in subclasses, you check self shouldnt: [instance toto] raise: SubclassResponsabilty
Like that it would be possible to check (via an #assert: for example) if a class provides the interface required.
I read some things I found on the net about Traits and already used TComparable but I never created one myself and I am not sure to understand this concept entirely.
With Trait you add behavior to a class. TComparable adds behavior to your class, your instance are then comparable.
Thanks in advance!
Julien
-- Dr. Geo http://drgeo.eu