|[acceleo] Good practice, implicit variable and constant queries [message #731154]
||Fri, 30 September 2011 06:57
| Marc Missing name
Registered: March 2011
In my templates, I want to set some values to constants (like constant prefixes, paths, ...). Currently, I'm using queries with no argument like
[query public bla() : String = 'toto' /]
Then, I've read that it's a good idea to have a parameter, even when it's not used:
[query public bla(anything: OclAny) : String = 'toto' /]
And this still works. I guess because when I call it with some implicit variable is used.
Now, the Good Practice says it's a bad idea to call queries like that and an explicit context should always be used. So, I ended up adding an explicit context for my calls, even if they are not used. And I find it misleading, as when reading the code, you can think that the bla() query will really use the context to compute its value, which is not the case.
I have 2 questions:
- in this particular case (constant query), is it safe to use bla() instead of x.bla() ?
- is there a cleaner way to handle constant values in templates ?
Powered by FUDForum
. Page generated in 0.05273 seconds