Interested to know what others do about naming conventions for controls.
I'm coming from an Access background for forms creation where control names only have to be unique to their parent form. You tend to reference a control by its parent form, e.g. MyForm.MyControl.
In PowerApps every control name must be unique, but I frequently have the 'same' control on multiple screens (e.g. Control 'CustomerName' may appear in a New Customer screen, Edit Customer screen, Customer Gallery screen and so on).
I've taken to prefixing every Control name with the name of the screen on which it appears and giving every screen a name related to its function/data, e.g. scnNewCustomer.DataCardCustomerName. This results in very long-winded control names, but at least avoids name clashes and confusion when reading formulae.
I'm doing it in a similar way, but I tend to put hte screen name last, and have an abbreviation of the type of control first, so a label on the main screen would be namned lblAccountHdrscrMain, a drop down would be ddAccountList etc. Furthermore I group items a lot, and the group's name will start with grp and then something descriptive, like grpAccountInfo. I haven't done that many apps yet though, so I tend to experiment a bit and change things around.
It certainly does not make for short namnes, but I think it will be easier to maintain in the long run, especially if someone else takes over. If there is something I strongly dislike it's going through undocumented and poorly written code!
One thing I miss (or have missed how to do) is the ability to search and replace names of global variables once they are being used. Examnple: I used Set(nLeftMargin, 4) in an app with lots of fields and rectangles but as things evolved, as they tend to do, I use the same variabel for both left and right margin as well as spacing within fields, so I'd like to change name to reflect this. Now I have used it in too many places so it's not really possible without putting a lot of time into it.
In having worked with Access for almost 25 years and counting ... I can appreciate the need for Naming Conventions ala the original Leszynski/Reddick Naming Conventions back in the day.
"but at least avoids name clashes and confusion when reading formulae. "
At this point in PowerApps relatively short existence ... using ANY sort of consistent naming convention will be ahead of the game.My conventions are still a moving target which each new app I do ... as new elements (objects/controls) are put in use 🙂
Tend to use ScreenControlDescription e.g. a label on the home screen for users would be HsLblUsers
Makes it easier when reading though code to know whats being reffered to & also if you were looking for a label on the home screen you'd just type HsLbl and it would list all 🙂
We're excited to announce our first cross-community 'Can You Solve These?' challenge!
Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.
We are excited for the next Super User season.
FIll out a quick form to claim your community user group member badge today!
Features releasing from October 2020 through March 2021