Skip to main content
added 48 characters in body
Source Link
Alex L
  • 5.7k
  • 2
  • 25
  • 68

To those looking at this question for the first time, I'm trying to find a correct OOP model I can use in JS. I initially found a very different solution from what's normally done, and I received lots of help from some of the good guys here :) The links above tell the whole story.

  • I was glad you edited and changed the override method to use bind. I wasn't confortable with that _SuperiorChainer thing. I found it too complicated and very strange to use. With bind, it got much better.
  • Instead of creating 2 methodtwo methods: one for normal classes, and one for view classes (dev_prop and def_view_prop), I overridenoverrode it and reduced it's name. I think it got clear enough and pratical enough.
  • I loved the idea of using def_view_procdef_view_proc instead of parsing the class. Much better.
  • I loved thisthe way of defining a property using descriptors with a smaller syntax. It rememberedreminded me the old Dephi times. I found Delphi properties definition very useful. I pushed descriptor.enumerable to the function tough, and created a defHidden method just in case.
  • I've put function is_function(obj) { return obj instanceof Function }; inside of overridethe overwritten function. It's only used there and as you recommended to me, we should avoid global context functions. If it's needed anywhere else I'll remove it from there and create an utility class or something.
  • I changed the name from inherit_from_toinherit_from_to to extendextend. Small and equalyequally explicit.
  • I loved the much cleaner code, removing showOperatorsshowOperators method and stuff. I'll definitivelydefinitely will use method descriptions more.

So what do you think  ? Any final comments?

To those looking this question first I'm trying to find a correct OOP model I can use in JS. I initially found a very different solution from what's normally done and I received lots of help from some of the good guys here :) The links above tell the whole story.

  • I was glad you edited and changed override method to use bind. I wasn't confortable with that _SuperiorChainer thing. I found it too complicated and very strange to use. With bind it got much better.
  • Instead of creating 2 method one for normal classes and one for view classes (dev_prop and def_view_prop) I overriden it and reduced it's name. I think it got clear enough and pratical enough.
  • I loved the idea of using def_view_proc instead of parsing the class. Much better.
  • I loved this way of defining a property using descriptors with a smaller syntax. It remembered me the old Dephi times. I found Delphi properties definition very useful. I pushed descriptor.enumerable to the function tough, and created a defHidden method just in case.
  • I've put function is_function(obj) { return obj instanceof Function }; inside of override function. It's only used there and as you recommended me we should avoid global context functions. If it's needed anywhere else I'll remove it from there and create an utility class or something.
  • changed the name from inherit_from_to to extend. Small and equaly explicit.
  • I loved the much cleaner code removing showOperators method and stuff. I'll definitively will use method descriptions more.

So what do you think  ? final ?

To those looking at this question for the first time, I'm trying to find a correct OOP model I can use in JS. I initially found a very different solution from what's normally done, and I received lots of help from some of the good guys here :) The links above tell the whole story.

  • I was glad you edited and changed the override method to use bind. I wasn't confortable with that _SuperiorChainer thing. I found it too complicated and very strange to use. With bind, it got much better.
  • Instead of creating two methods: one for normal classes, and one for view classes (dev_prop and def_view_prop), I overrode it and reduced it's name. I think it got clear and pratical enough.
  • I loved the idea of using def_view_proc instead of parsing the class. Much better.
  • I loved the way of defining a property using descriptors with smaller syntax. It reminded me the old Dephi times. I found Delphi properties definition very useful. I pushed descriptor.enumerable to the function tough, and created a defHidden method just in case.
  • I've put function is_function(obj) { return obj instanceof Function }; inside of the overwritten function. It's only used there and as you recommended to me, we should avoid global context functions. If it's needed anywhere else I'll remove it from there and create an utility class or something.
  • I changed the name from inherit_from_to to extend. Small and equally explicit.
  • I loved the much cleaner code, removing showOperators method and stuff. I'll definitely will use method descriptions more.

So what do you think? Any final comments?

added 54 characters in body
Source Link

JSFiddle

  • I was glad you edited and changed override method to use bind. I wasn't confortable with that _SuperiorChainer thing. I found it too complicated and very strange to use. With bind it got much better.
  • Instead of creating 2 method one for normal classes and one for view classes (dev_prop and def_view_prop) I overriden it and reduced it's name. I think it got clear enough and pratical enough.
  • I loved the idea of using def_procdef_view_proc instead of parsing the class. Much better.
  • I loved this way of defining a property using descriptors with a smaller syntax. It remembered me the old Dephi times. I found Delphi properties definition very useful. I pushed descriptor.enumerable to the function tough, and created a defHidden method just in case.
  • I've put function is_function(obj) { return obj instanceof Function }; inside of override function. It's only used there and as you recommended me we should avoid global context functions. If it's needed anywhere else I'll remove it from there and create an utility class or something.
  • changed the name from inherit_from_to to extend. Small and equaly explicit.
  • I loved the much cleaner code removing showOperators method and stuff. I'll definitively will use method descriptions more.

  • I was glad you edited and changed override method to use bind. I wasn't confortable with that _SuperiorChainer thing. I found it too complicated and very strange to use. With bind it got much better.
  • Instead of creating 2 method one for normal classes and one for view classes (dev_prop and def_view_prop) I overriden it and reduced it's name. I think it got clear enough and pratical enough.
  • I loved the idea of using def_proc instead of parsing the class. Much better.
  • I loved this way of defining a property using descriptors with a smaller syntax. It remembered me the old Dephi times. I found Delphi properties definition very useful. I pushed descriptor.enumerable to the function tough, and created a defHidden method just in case.
  • I've put function is_function(obj) { return obj instanceof Function }; inside of override function. It's only used there and as you recommended me we should avoid global context functions. If it's needed anywhere else I'll remove it from there and create an utility class or something.
  • changed the name from inherit_from_to to extend. Small and equaly explicit.
  • I loved the much cleaner code removing showOperators method and stuff. I'll definitively will use method descriptions more.

JSFiddle

  • I was glad you edited and changed override method to use bind. I wasn't confortable with that _SuperiorChainer thing. I found it too complicated and very strange to use. With bind it got much better.
  • Instead of creating 2 method one for normal classes and one for view classes (dev_prop and def_view_prop) I overriden it and reduced it's name. I think it got clear enough and pratical enough.
  • I loved the idea of using def_view_proc instead of parsing the class. Much better.
  • I loved this way of defining a property using descriptors with a smaller syntax. It remembered me the old Dephi times. I found Delphi properties definition very useful. I pushed descriptor.enumerable to the function tough, and created a defHidden method just in case.
  • I've put function is_function(obj) { return obj instanceof Function }; inside of override function. It's only used there and as you recommended me we should avoid global context functions. If it's needed anywhere else I'll remove it from there and create an utility class or something.
  • changed the name from inherit_from_to to extend. Small and equaly explicit.
  • I loved the much cleaner code removing showOperators method and stuff. I'll definitively will use method descriptions more.
added 6 characters in body
Source Link
Loading
added 6 characters in body
Source Link
Loading
Source Link
Loading