App Designer. Should I use app functions or external fuctions?

8 views (last 30 days)
I created a "program" based in scripts and functions and I have merged it into an app from App designer to make it more user friendly. However, I noticed that the "same" operations are now much slower and crashing more often than when I was not using the App designer, so I wonder if the app somehow makes it less efficient.
I am using "app" functions written in the app code. I wonder If I should externalize all the functions and create isolated function files so I can call them from the app code. One of the reasons I prefer the internal app functions is because I play with some properties shared between the functions. But I guess I can pass the properties/variables trough the functions arguments.

Accepted Answer

Adam Danz
Adam Danz on 31 Aug 2021
Edited: Adam Danz on 1 Sep 2021
> I noticed that the "same" operations are now much slower and crashing more often than when I was not using the App designer, so I wonder if the app somehow makes it less efficient.
App have a slower startup time than using m-files directly. Rendering in UIFigures is also slower than rendering in regular figures. Other than that, running code from an app isn't noticeably slower than outside of an app in my exerpience. If the code works outside of app designer, it shouldn't crash within app designer. So there may be some errors in your implementation or severe suboptimalities, or perhaps you've found a bug. Sharing error messages, describing user interactions that cause a crash, or providing the files needed to reproduce the crash would be helpful, along with knowing your Matlab release.
> I am using "app" functions written in the app code. I wonder If I should externalize all the functions and create isolated function files so I can call them from the app code.
I answered a similar question yesterday. There are limited circumstances that I would recommend using external m-file functions.
  1. if the function is used by other functions, obviously it should remain external in most cases.
  2. If the function is very long and you'd like to keep the app code short and sweet. In your case, it sounds like the function should be internal to the app so you can share properties more efficiently as you've mentioned.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!