Discovering best practices when building canvas apps
Setting up data sources, defining business process flows, creating user interfaces; all these tasks are pieces of an application-building process. These pieces come together to accomplish one main goal: to build a solution that solves a specific need.
One of the things you need to consider is the maintainability of your app. Whether fixing bugs or adding new features, using best practices is always a good idea. No matter your technology, well-documented code is easier to maintain.
Even though Power Apps is a low-code platform, you must consider certain things before building applications. Like any other developer team, you need to establish code standards. These standards allow your team to be more productive by setting predefined patterns for variable naming, control usage, and coding methodology.
Variable naming
Proper naming gives your developers instant insight into the scope of your variables. For example, if a variable name prefix starts with lcl
(short for local), it means its value will only be available on the current screen. On the other hand, using gbl
(short for global) means that this variable is accessible across the whole application.
These examples might seem trivial, but if another developer needs to maintain your app or if your app serves as a template for other apps in your organization, setting these patterns from the start can help the application-building process and maintainability.
Control usage
One of the vital elements of an application’s success is performance. If an application is slow to start or takes several seconds to perform a task, it hurts user adoption.
Here are a couple of examples of this:
- A great-looking app that uses many controls to build its user interface but hurts performance each time the screens get rendered.
- Displaying data to the user using a gallery inside a gallery. This approach might be tempting to present master-detail data, but this would be a significant slowdown in your application.
To avoid this, you need to learn the performance points of your platform. In Power Apps, one of the main recommendations for improving responsiveness is to reduce the number of controls.
Coding methodology
This concept describes a set of rules to regulate the development process in a low-code team. Your solution infrastructure can also help you make an informed decision on how to build your application:
- If you have data that rarely changes, you can create collections to avoid round-trips each time data is required. Even more, if you have data that never changes, you can import this as static data inside your app for speedier access.
- Taking advantage of the features available in your data source can significantly improve your application performance. For example, when using Dataverse or a relational database, there is a significant difference when querying data if you use data source views instead of building the actual query in your application logic, especially if it needs complex relationships. Using these views gives you cleaner code while also enhancing performance. This improvement relies on the data source engine as it is the one that executes the data processing instead of the application itself.
These are examples of practices you can coordinate with your team when building apps. For a detailed list of best practices, please refer to https://powerapps.microsoft.com/en-us/blog/powerapps-canvas-app-coding-standards-and-guidelines/