[ALOY-399] Improve generated variable names

GitHub Issuen/a
ResolutionWon't Fix
Resolution Date2013-03-11T15:41:34.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 06
ReporterTony Lukasavage
AssigneeTony Lukasavage


As it stands, all automatically generated variable names in Alloy get a standard prefix and then a counter as more variables are generated. In other words, the list will always look like this: * __alloyId1 * __alloyId2 * __alloyId3 * __alloyId4 * __alloyId5 * and so on... While this serves its purpose correctly, it makes it difficult in some cases to understand what is going on if a developer decides to inspect the generated code. They can figure it out, but it would be nicer if they could understand it a little more at a glance. To help with this, when the deploy type is either *development* or *test*, I'd like to make the name a little more meaningful. Perhaps adding a part to the variable name that indicates what API it pertains to, or anything to really make it more applicable. In *production* we'll just squeeze these names down to something small and unique, but a more verbose name in *development* and *test* will prove useful. Fortunately the auto generation of variable names has been abstracted out to a single function called *generateUniqueId()* in https://github.com/appcelerator/alloy/blob/master/Alloy/commands/compile/compilerUtils.js. We can add additional parameters to this function relatively easily and make this improvement gradually, starting with the most used or most cryptic generated code.


  1. Tony Lukasavage 2013-03-11 Now that source mapping has been implemented (ALOY-532 and ALOY-537) this is not really necessary. Will re-open if for some reason this becomes beneficial.

JSON Source