Using +package folders with appdesigner apps
5 次查看(过去 30 天)
显示 更早的评论
Hi all
I am trying to partition methods from an appdesigner App into different files, in turn, by folder. To me, it makes sense to segment into packages using the "+" notation, within the Class folder for the app, denoted by @AnalysisApp.
i.e.
@AnalysisApp
-- + get
-- + generate
-- + do
etc, with each method within the +get, +generate, etc folders accessible using the dot notation, i.e. "get.data(args)". However, this doesn't seem to work as each method is not defined as being a method of the AnalysisApp class. When I explicitly define a static private method in the top level .mlapp code, this still doesn't seem to work.
I have also tried making the package folders class folders, and defining a subclass to inherit from the top level AnalysisApp class, which in turn inherits from the matlab base appdesigner class, as defined in the AnalysisApp.mlapp file, but this doesn't work either.
For now, i have settled with non-private and non-package subfolders, so simply:
-- get
-- generate,
etc as subfolders to @AnalysisApp.
That seems to work, but obviously I can't use the dot notation, so organising my code is not as straightforward and I may end up with shadowed files, for example if i wish to have a get.DataItem and generate.Dataitem; the whole reason i wished to use the package notation! Additionally, I now get an error talking about "Method Directories"; "Method directories not allowed in MATLAB path: ...\@AnalysisApp". I'm guessing I am not allowed to have directories containing methods as subfolders of an appdesigner app class?
Help! And thanks in advance :)
1 个评论
J. Alex Lee
2020-3-6
编辑:J. Alex Lee
2020-3-6
I wouldn't try to use "." in the way you are, especially "get.PROPERTY" is the syntax to define a get method.
Can you make "DataItem" into a class, endowed with its own methods, so you can instead do things like
app.DataItemInstance = DataItem(); % create a DataItem instance
app.DataItemInstance.getdata % would replace your desired "get.DataItem"
app.DataItemInstance.generate % would replace your desired "generate.DataItem"
with
classdef DataItem
properties
end
methods
function this = DataItem()
end
function generate(this,varargin)
end
function getdata(this,varargin)
end
end
end
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Construct and Work with Object Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!