reflex/reflex-framework

Code Readability

javierjulio opened this issue · 1 comments

I'm looking into contributing to the project but I think one of the major roadblocks is the readability of the code. I use to write a lot how Reflex is setup, in other words very little whitespace but I've learned since then how valuable whitespace. You can focus and understand bits of code in chunks rather than have say an if statement all in one line of code with brackets. It feels very congested. I think simple improvements can be made to make some of the code feel less intimidating, for example, changing the following:

if(hasStyle(child, "left") && hasStyle(child, "right")) {
    xp = left + width + right;
} else if(hasStyle(child, "left")) {
    xp = left + width;
} else if(hasStyle(child, "right")) {
    xp = width + right;
} else if(hasStyle(child, "horizontalCenter")) {
    xp = width + Math.abs(horizontalCenter);
}

if(!isNaN(xp)) { point.x = Math.max(point.x, xp); }
if(!isNaN(yp)) { point.y = Math.max(point.y, yp); }

to something like:

if (hasStyle(child, "left") && hasStyle(child, "right")) 
{
    xp = left + width + right;
} 
else if(hasStyle(child, "left")) 
{
    xp = left + width;
} 
else if(hasStyle(child, "right")) 
{
    xp = width + right;
} 
else if(hasStyle(child, "horizontalCenter")) 
{
    xp = width + Math.abs(horizontalCenter);
}

if (!isNaN(xp)) 
{
    point.x = Math.max(point.x, xp);
}

if (!isNaN(yp)) 
{
    point.y = Math.max(point.y, yp);
}

I realize this has to do much more with preference but being an open source project I think it will benefit in the long run, especially with more complex areas of the code base. Currently, trying to understand the code involved in the invalidation and measurement packages but its just not whitespace but also the lack of comments that also really hurts the readability of some of the classes.

Not a bug. I'm not making fixes on code formatting concerns, although I'll try to leave more comments in the future. You're welcome to use a code formatter such as the FlexFormatter plugin for Eclipse. http://sourceforge.net/projects/flexformatter/