0

Palm's Enyo framework uses a DSL-ish "Kind" system to create objects based on prototypes. Unfortunately, this results in, what I believe to be, untidier code.

Does anyone have any experience using/hacking Enyo with native-javascript prototypes / constructors?

enyo.kind
  name:  'SimpleTimer'
  kind: "RowGroup"
  caption: "Simple Timer"
  published:
    timerDuration: 30

vs…

class SimpleTimer extends RowGroup
  caption: "SimpleTimer"
  published:
    timerDuration: 30

Hoping to know if anyone else has accomplished/attempted this.

arbales
  • 5,466
  • 4
  • 33
  • 40

3 Answers3

1

Not Enyo, but somewhat related, you might want to look into Jo if you want this style of coding. Here's a Coffeescript wrapper for it I saw yesterday:

http://k33g.github.com/2011/08/14/JO-COFFEESCRIPT.html

Jo works in webOS with PhoneGap, supports 1.x-3.x as well as other platforms. Cheers.

davebalmer
  • 11
  • 2
1

I was trying to accomplish the same thing you are, using a different method of compiled Javascript (Haxe JS)

I was able to get this to work ... extending kinds like base classes, but I had to wrap the framework in my own files to get it to work. I don't wish that on anyone else, but feel free to take a peek at what I have working:

http://www.joshuagranick.com/blog/2011/08/08/enyo-with-code-completion-yes/

Have a great day!

-1

You can alternatively use a more functional, rather than object-oriented, style. Maybe something like:

simpleTimer = (timerDuration) ->
  new RowGroup  caption: 'Simple Timer', timerDuration: timerDuration

And then instead of creating a timer by doing

new SimpleTimer timerDuration:99

you can do

simpleTimer 99
Eamonn O'Brien-Strain
  • 3,352
  • 1
  • 23
  • 33
  • I realize I didn't address your question, instead I addressed the broader issue of whether you wanted object-oriented code, and the "untidiness" issue you mentioned. I find that using Coffeescript is a natural match for a functional style of code. I think that in many contexts my functional code example could be used in place of either of the two object-oriented alternatives in the question, and it is much shorter and IMHO less "untidy". – Eamonn O'Brien-Strain Jan 23 '13 at 05:09