You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Sandro Martini <sa...@gmail.com> on 2010/11/22 12:19:28 UTC

BXMLSerializer Flag to turn off script parsing

Hi to all,
what do you think on adding in BXMLSerializer a Flag to turn off script
parsing ?
This could be useful when I want to be sure that developers doesn't put
logic inside BXML files (but put only references to method calls, listeners,
element definitions, etc) but write logic in Java or other JVM language.
If disabled, and the BXMLSerializer find some script inside processed bxml
files, maybe a console warning could be shown or an exception, or other ...

For example, there is a setting like this in JSP, and in my opinion in some
cases could be really useful (mainly from a maintenance point of view).
Take a look here:
http://download.oracle.com/javaee/5/tutorial/doc/bnaoq.html

Open a JIRA ticket for 2.1 ?
Comments ?

Bye,
Sandro

-- 
View this message in context: http://apache-pivot-developers.417237.n3.nabble.com/BXMLSerializer-Flag-to-turn-off-script-parsing-tp1945087p1945087.html
Sent from the Apache Pivot - Developers mailing list archive at Nabble.com.

Re: BXMLSerializer Flag to turn off script parsing

Posted by Sandro Martini <sa...@gmail.com>.
Ok, no problem ... and we are always in time to add later if needed.

Thank you for the moment.

Bye,
Sandro

-- 
View this message in context: http://apache-pivot-developers.417237.n3.nabble.com/BXMLSerializer-Flag-to-turn-off-script-parsing-tp1945087p1947772.html
Sent from the Apache Pivot - Developers mailing list archive at Nabble.com.

Re: BXMLSerializer Flag to turn off script parsing

Posted by Greg Brown <gk...@mac.com>.
>>> OTOH, it is also a good idea to keep event listeners as short as possible
>>> and have them call into domain objects that are exposed by the
>>> application (and these would generally be implemented in compiled code
>>> vs. script). 
> This is the point: this setting could be useful to ensure that in BXML files
> are put only references to existing (in code) methods and nothing other.
> Like enforcing a best practice.

I'm not really a big fan of "enforced" best practices. IMO, best practices are guidelines that you can either choose to adopt, or not. Besides, if we disable scripting in a BXML page, you wouldn't be able to call any methods at all, regardless of where they are defined. So I don't really see the value.


Re: BXMLSerializer Flag to turn off script parsing

Posted by Sandro Martini <sa...@gmail.com>.
>> I think the idea of separating code and markup is different from
separating logic and presentation. The latter (which is common in JSP and
HTML) can produce unreadable and unmanageable code. 
>> However, the former can help create more maintainable code. 
>> For example, if you create a button and add event listeners to it in
>> BXML, the association between the button and the listeners is clearer
>> than if you create the listeners in your initialize() method. 
Yes, I agree

>> OTOH, it is also a good idea to keep event listeners as short as possible
>> and have them call into domain objects that are exposed by the
>> application (and these would generally be implemented in compiled code
>> vs. script). 
This is the point: this setting could be useful to ensure that in BXML files
are put only references to existing (in code) methods and nothing other.
Like enforcing a best practice.

Sandro

-- 
View this message in context: http://apache-pivot-developers.417237.n3.nabble.com/BXMLSerializer-Flag-to-turn-off-script-parsing-tp1945087p1946271.html
Sent from the Apache Pivot - Developers mailing list archive at Nabble.com.

Re: BXMLSerializer Flag to turn off script parsing

Posted by Greg Brown <gk...@mac.com>.
Sorry, I mean "separating data from presentation", not "logic from presentation". Obviously, even the most trivial dynamic interface will need to combine logic and presentation.  :-)

On Nov 22, 2010, at 8:40 AM, Greg Brown wrote:

> I think the idea of separating code and markup is different from separating logic and presentation. The latter (which is common in JSP and HTML) can produce unreadable and unmanageable code. However, the former can help create more maintainable code. For example, if you create a button and add event listeners to it in BXML, the association between the button and the listeners is clearer than if you create the listeners in your initialize() method. OTOH, it is also a good idea to keep event listeners as short as possible and have them call into domain objects that are exposed by the application (and these would generally be implemented in compiled code vs. script).
> 
> On Nov 22, 2010, at 8:26 AM, Sandro Martini wrote:
> 
>> 
>> Hi Greg,
>> you have reason, in BXML probably is less important to have this than in JSP
>> ... over years I've done too much maintenance on old-fashioned JSP.
>> 
>> But in this way we could have a simple settings to ensure that all
>> developers could use BXML only for definition of components and GUI, and be
>> sure to have have all application logic inside code. 
>> For example if a Company set a standard like this we can simplify standard
>> adherence of all Pivot-based code.
>> Of course this will be useful on complex applications, where having most of
>> the code checked at compile time will be great.
>> 
>> Do you think a ticket for this for the 2.1 will be interesting (maybe as a
>> wish, and see later if someone agree that's useful, or maybe drop it later)
>> ?
>> 
>> Comments (even from others) ? ...
>> 
>> Sandro
>> 
>> -- 
>> View this message in context: http://apache-pivot-developers.417237.n3.nabble.com/BXMLSerializer-Flag-to-turn-off-script-parsing-tp1945087p1945656.html
>> Sent from the Apache Pivot - Developers mailing list archive at Nabble.com.
> 


Re: BXMLSerializer Flag to turn off script parsing

Posted by Greg Brown <gk...@mac.com>.
I think the idea of separating code and markup is different from separating logic and presentation. The latter (which is common in JSP and HTML) can produce unreadable and unmanageable code. However, the former can help create more maintainable code. For example, if you create a button and add event listeners to it in BXML, the association between the button and the listeners is clearer than if you create the listeners in your initialize() method. OTOH, it is also a good idea to keep event listeners as short as possible and have them call into domain objects that are exposed by the application (and these would generally be implemented in compiled code vs. script).

On Nov 22, 2010, at 8:26 AM, Sandro Martini wrote:

> 
> Hi Greg,
> you have reason, in BXML probably is less important to have this than in JSP
> ... over years I've done too much maintenance on old-fashioned JSP.
> 
> But in this way we could have a simple settings to ensure that all
> developers could use BXML only for definition of components and GUI, and be
> sure to have have all application logic inside code. 
> For example if a Company set a standard like this we can simplify standard
> adherence of all Pivot-based code.
> Of course this will be useful on complex applications, where having most of
> the code checked at compile time will be great.
> 
> Do you think a ticket for this for the 2.1 will be interesting (maybe as a
> wish, and see later if someone agree that's useful, or maybe drop it later)
> ?
> 
> Comments (even from others) ? ...
> 
> Sandro
> 
> -- 
> View this message in context: http://apache-pivot-developers.417237.n3.nabble.com/BXMLSerializer-Flag-to-turn-off-script-parsing-tp1945087p1945656.html
> Sent from the Apache Pivot - Developers mailing list archive at Nabble.com.


Re: BXMLSerializer Flag to turn off script parsing

Posted by Sandro Martini <sa...@gmail.com>.
Hi Greg,
you have reason, in BXML probably is less important to have this than in JSP
... over years I've done too much maintenance on old-fashioned JSP.

But in this way we could have a simple settings to ensure that all
developers could use BXML only for definition of components and GUI, and be
sure to have have all application logic inside code. 
For example if a Company set a standard like this we can simplify standard
adherence of all Pivot-based code.
Of course this will be useful on complex applications, where having most of
the code checked at compile time will be great.

Do you think a ticket for this for the 2.1 will be interesting (maybe as a
wish, and see later if someone agree that's useful, or maybe drop it later)
?

Comments (even from others) ? ...

Sandro

-- 
View this message in context: http://apache-pivot-developers.417237.n3.nabble.com/BXMLSerializer-Flag-to-turn-off-script-parsing-tp1945087p1945656.html
Sent from the Apache Pivot - Developers mailing list archive at Nabble.com.

Re: BXMLSerializer Flag to turn off script parsing

Posted by Greg Brown <gk...@mac.com>.
> what do you think on adding in BXMLSerializer a Flag to turn off script
> parsing ?
> This could be useful when I want to be sure that developers doesn't put
> logic inside BXML files

Under what circumstances might you want to do this? It is true that script code can make JSPs more difficult to understand, but script in BXML tends to be much cleaner, as it follows stricter guidelines (you can't simply insert code anywhere using <%= ... %> blocks, for example). Even if a developer chooses not to use script in BXML, I'm still not sure I see the value in enforcing that script cannot run.

G