Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Andy Prock
    @aprock
    ah, thanks
    Carl Olsen
    @unstoppablecarl
    Shouldn’t this room be closed?
    Vasyl Boroviak
    @koresar
    Wow. No. People are asking questions here
    Marc Dix
    @mdix
    Hi. I'm having a question concerning stampit 2. I already put it on stackoverflow. Maybe you guys can help? http://stackoverflow.com/questions/33743568/interfaces-with-stampit-2
    Vasyl Boroviak
    @koresar
    I assume you are confused on what Eric calls "interface".
    Not sure why you need the classical interfaces in JS.
    Marc Dix
    @mdix
    So... what does he mean with interface? Because the whole world has a different perception I guess...
    Maybe I read that part again... hehe
    Interfaces define a contract that an implementing module will fulfill.
    I mean...
    How can we be sure that they fulfill if they're not forced to?
    Vasyl Boroviak
    @koresar
    Do you need to make sure?
    Marc Dix
    @mdix
    And I also assume that, if he quotest GoF all the time, he really means the interface everybody talks about, not his own version of 'interface'.
    Vasyl Boroviak
    @koresar
    Here is how I do things. See in the middle stampit-org/stampit#181
    Marc Dix
    @mdix
    Well, from time to time it would help.
    mdix @mdix back in 15 min, daily...
    Vasyl Boroviak
    @koresar
    From my JS practice those interfaces are not necessary. I never do them.
    Although, there can be specific cases for sure.
    Try ducktyping to check if an object implements an interface.
    So, if I need an interface implemented I do something like "ItemsContainer" (see issue above).
    Marc Dix
    @mdix
    Thanks for the suggestions, I'm sure ther're multiple workarounds. I'm just curious why Eric calls it interface, because it's just no interface... whatever it is, maybe a 'loose contract' or something similar.
    Vasyl Boroviak
    @koresar
    Probably.
    Marc Dix
    @mdix
    I can't ducktype it, because if I define them in the 'interface', the methods are there, are of type function - and I'm also not able to call them, because then I might call the implementation (or if I call the interface method, I throw an error).
    Vasyl Boroviak
    @koresar
    Are you coming from Java or C#?
    Looks like you are struggling with the same thoughts as all of us did. ☺
    Marc Dix
    @mdix
    Nah, just like interfaces...
    Hmm... hackety hack, this would work: https://gist.github.com/mdix/610f38f4714d21da3d22
    Vasyl Boroviak
    @koresar
    Check rtype project by Eric. He's trying to achieve the runtime interface checks.
    Marc Dix
    @mdix
    I already know of rtype, but it's not ready yet, I guess...
    Marc Dix
    @mdix
    Maybe it would a good idea to serve some consumable stamps that ppl need from time to time? Like an interface check or what you just posted?
    Vasyl Boroviak
    @koresar
    Yep. We have them. And we plan to implement a bunch as a new module.
    Marc Dix
    @mdix
    Cool, maybe you can consider sth for the interface stuff, even if you don't like to use it, others want to I guess...
    Vasyl Boroviak
    @koresar
    Have you checked my last link? It's the one.
    Marc Dix
    @mdix
    Yea, but I have to consume it like copy & paste which makes it my code, my responsibility... that's just not what I want.
    Vasyl Boroviak
    @koresar
    Right. I see.
    Good point.
    Marc Dix
    @mdix
    Yay, look how easy this is... just compose the InterfaceCheckStamp into the Interface and you have a real interface: https://gist.github.com/mdix/7e1b7358eff5f7ce21eb
    Vasyl Boroviak
    @koresar
    Ha-ha
    Not very performant, but looks great.
    Marc Dix
    @mdix
    Yah, just hacked it down
    Marc Dix
    @mdix
    Are you using tape?
    Ahh got it... wanted to assert for a certain error message when throwing:
    t.throws(interfaceStamp, new RegExp('expected error message'));
    Vasyl Boroviak
    @koresar
    👍
    Marc Dix
    @mdix
    Marc Dix
    @mdix
    This message was deleted
    Marc Dix
    @mdix

    @koresar Not very performant, but looks great.

    10000 runs, three unimplemented methods
    3s 583.978422ms execution time for InterfaceCheck
    3s 21.861021ms execution time for EmptyStamp

    Not too bad, I mean we're building 10000 objects from a stamp & checking 30000 methods for implementation and are only 550ms slower (approx 10 %).

    Check https://github.com/mdix/interface-check-stamp/blob/master/performance.js

    Vasyl Boroviak
    @koresar
    let's go to the #stampit-org/stampit channel
    Jonathan Amsellem
    @MrPing
    :)