On Thu, Mar 12, 2015 at 9:15 PM, Alex Harui <aha...@adobe.com> wrote:

> I’ve been plugging away trying to convert the FlexJS framework to use
> Object.defineProperty.


This removes IE8 from the equation.  You probably know that already.


> I’m looking to get other’s thoughts on how to indent, comment and
> otherwise format or style the actual code.  Here’s what I mean:
>
> The old code looked like this:
>
> /**
>  * @expose
>  * @return {number} The offset to write to or read from.
>  */
> org_apache_flex_utils_BinaryData.prototype.get_position = function() {
>   return this.position_;
> };
>
>
> /**
>  * @expose
>  * @param {number} value The offset to write to or read from.
>  */
> org_apache_flex_utils_BinaryData.prototype.set_position = function(value) {
>   this.position_ = value;
> };
>
>
>
> I think the equivalent with Object.defineProperties is this:
>
> Object.defineProperties(org_apache_flex_utils_BinaryData.prototype, {
>     'position': {
>         get: function() {
>             return this.position_;
>         },
>         set: function(value) {
>             this.position_ = value;
>         }
>     }
>         });
>
> As you can see, it looks like we are building out object structures with
> functions as values.  One of the things I don’t like is it causes the code
> to be indented pretty far in.  And when you start placing in comments,
> they are also indented and it really starts to look cluttered.
>

I prefer more indentation, especially these cases.  Makes it more readable,
in my opinion.

Thanks,
Om


>
>
> I’m also wondering whether comments even matter for the Google Closure
> Compiler.  No code will directly access the get or set properties of these
> subobjects.
>
> Finally, I’ve been reading that @expose is deprecated in GCC.  I’m
> wondering how we are supposed to prevent property renaming, if at all.
>
>
> Thoughts?
>
> Thanks,
> -Alex
>
>
>

Reply via email to