tnhu / jsface

Small, fast, elegant, powerful, and cross platform JavaScript OOP library. Support main(), singleton, super call, private, mixins, plugins, AOP and more.
MIT License
301 stars 46 forks source link

Static methods are inherited across all instances #25

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi there,

I love the library so far. Any reason why static methods are inherited at the instance level? It seems better for performance & encapsulation, if class/static methods only belong to the class. Would love to understand the philosophy behind this implementation.

Best, Yi-Hsiao

Relevant lines of code: https://github.com/tnhu/jsface/blob/master/jsface.js#L138 https://github.com/tnhu/jsface/blob/master/jsface.js#L153

tnhu commented 9 years ago

Hi Yi-Hsiao,

Thanks for commenting! The reason is to simulate Java static methods in which static methods are accessible on both class and instance levels. It was a design decision being made since I started jsface (side note: I have Java background).

I later realized I never use static properties (methods and variables) on instance level :). Agreed that it could be better to make static them accessible on class level only.

If nobody's against it, I'll make a change.

onlyurei commented 9 years ago

Thanks for the explanation. I suggest that you bump the version major number if this change does happen so as not to break current use cases.

tnhu commented 9 years ago

Fix in 2.4.0. Thanks everyone!