Skip to content

Property System? #3

Open
Open

Description

@subcontact

Hi,

It's a nice and neat looking class system.
Any plans on adding a property system for
Getters & Setters, change events etc?

Activity

  1. DominikGuzei commented on Oct 13, 2012

    @DominikGuzei
    Owner

    Hey there, thanks for the positive feedback!

    I didn't really think about additional functionality yet because we don't require more in our current project. If you have suggestions on how to add a property system with minimal impact on performance and code size – or want to contribute in form of pull requests I will definitely welcome that.

    Of course you can also just present your ideas in a more general form / how the API should look like / in which use cases this would be awesome etc. If some ideas stick to me then it is totally possible that I will use some spare time to implement something ;-)

  2. subcontact commented on Oct 14, 2012

    @subcontact
    Author

    Yep - it's a clear API for classes / Mixins. Reminds me of a framework that I've used for many years - qooxdoo. It's has a 1st class OO and property system but it is not lightweight. Backbone also supports this but I'm not interested in the rest of the MV* stuff.

    The benefit of listing properties that it can auto create get/set methods (which can be overridden if needed) and the key part is to allow an event to be triggered for a property change. That's the easiest way to create lightweight data binding. The catch is to also provide it for Array's which usually means using an Array wrapper implementation.

    I found this project which seems to do everything I need (though the API isn't as nice as your one :)

    http://hay.github.com/stapes/

  3. DominikGuzei commented on Oct 14, 2012

    @DominikGuzei
    Owner

    I see exactly what you mean and we could build a solid system with the standard get/set methods and change events in some hours. My personal problem with this approach is this: It is really error prone in real world projects. It forces you to work with strings (e.g.: get('myAwesomeVariable')) instead of identifiers. That doesn't work nicely with auto-completion in IDEs like Webstorm and gives you a harder time refactoring variable names etc (not to mention the overhead of calling a function to get/set a property).

    The other problem you will run into is the need for a run loop: If you have thousands of events happening at the same time you end up with endless rerenderings (the typical backbone.js problem). Ember.js solves that by introducing a complex and uncomfortable run loop which no one really understands and makes you scream some times while testing.

    You see, this would be easy to implement and seems like the perfect solution – until you run into problems in a real world project. This usually happens relatively late in production where the last thing you need is a system that throws problems at you that don't belong to your application's domain.

    The reason we don't need this overhead / pitfalls in our current project is: we work with Angular.js – this amazing library simple makes an end to all of this by using a technique long known as dirty checking. This is used in game programming since years and is more performant and much more predictable (hence more comfortable) than typical event-driven systems

    If you want that nicely summarized, read on: http://stackoverflow.com/questions/9682092/databinding-in-angularjs

    Hope this gives you an idea why the answer to these problems is not so simple as it seems ;-)

  4. subcontact commented on Oct 14, 2012

    @subcontact
    Author

    Thanks for the detailed response. The angular binding approach is quite interesting, I haven't come across that before.
    My suggestion does add overhead but it definitely works as I've used it in qooxdoo for many years now and it works well (the design pattern). The solution needs an observer pattern (event listeners) and/or mediator pattern (pub/sub) but there is no need for a run/event loop. Those two patterns are good tools for a large application in any sense.

    However all this does make it more complex than simple which may not be one of your design goals :)

    I'll go with Stapes for the time being but congratulations on your library - it's quite nicely done.

    Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions