Package folders in class folders
up vote
1
down vote
favorite
In MATLAB, a class folder is represented by foo/@bar/
and a package folder is represented by foo/+bar
. In my hierarchy, I have classes that define methods in separate files, so the @bar/
convention is necessary for their containing folders. However, I also have methods that get somewhat complex in their implementation, and would like to have them packaged into... well, packages using the +bar/
convention, like so:
foo/@classfolder/MyClass.m
foo/@classfolder/method1.m
foo/@classfolder/method2.m
foo/@classfolder/+othermethodstuff/method2helper.m
foo/@classfolder/+othermethodstuff/mexmethod_formethod2helper.m
foo/@classfolder/+othermethodstuff/mexfiles/
I want to do this because methods in my actual code that are represented here by method2.m
rely on some heavy computations from MEX files that I would prefer to reside in their own folder, with the package system used by MATLAB keeping it clear when I am calling those methods (and from where).
Is this possible? If not, is my only other option dropping the @
class folder convention and sticking everything into package (+
) folders?
matlab oop
add a comment |
up vote
1
down vote
favorite
In MATLAB, a class folder is represented by foo/@bar/
and a package folder is represented by foo/+bar
. In my hierarchy, I have classes that define methods in separate files, so the @bar/
convention is necessary for their containing folders. However, I also have methods that get somewhat complex in their implementation, and would like to have them packaged into... well, packages using the +bar/
convention, like so:
foo/@classfolder/MyClass.m
foo/@classfolder/method1.m
foo/@classfolder/method2.m
foo/@classfolder/+othermethodstuff/method2helper.m
foo/@classfolder/+othermethodstuff/mexmethod_formethod2helper.m
foo/@classfolder/+othermethodstuff/mexfiles/
I want to do this because methods in my actual code that are represented here by method2.m
rely on some heavy computations from MEX files that I would prefer to reside in their own folder, with the package system used by MATLAB keeping it clear when I am calling those methods (and from where).
Is this possible? If not, is my only other option dropping the @
class folder convention and sticking everything into package (+
) folders?
matlab oop
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In MATLAB, a class folder is represented by foo/@bar/
and a package folder is represented by foo/+bar
. In my hierarchy, I have classes that define methods in separate files, so the @bar/
convention is necessary for their containing folders. However, I also have methods that get somewhat complex in their implementation, and would like to have them packaged into... well, packages using the +bar/
convention, like so:
foo/@classfolder/MyClass.m
foo/@classfolder/method1.m
foo/@classfolder/method2.m
foo/@classfolder/+othermethodstuff/method2helper.m
foo/@classfolder/+othermethodstuff/mexmethod_formethod2helper.m
foo/@classfolder/+othermethodstuff/mexfiles/
I want to do this because methods in my actual code that are represented here by method2.m
rely on some heavy computations from MEX files that I would prefer to reside in their own folder, with the package system used by MATLAB keeping it clear when I am calling those methods (and from where).
Is this possible? If not, is my only other option dropping the @
class folder convention and sticking everything into package (+
) folders?
matlab oop
In MATLAB, a class folder is represented by foo/@bar/
and a package folder is represented by foo/+bar
. In my hierarchy, I have classes that define methods in separate files, so the @bar/
convention is necessary for their containing folders. However, I also have methods that get somewhat complex in their implementation, and would like to have them packaged into... well, packages using the +bar/
convention, like so:
foo/@classfolder/MyClass.m
foo/@classfolder/method1.m
foo/@classfolder/method2.m
foo/@classfolder/+othermethodstuff/method2helper.m
foo/@classfolder/+othermethodstuff/mexmethod_formethod2helper.m
foo/@classfolder/+othermethodstuff/mexfiles/
I want to do this because methods in my actual code that are represented here by method2.m
rely on some heavy computations from MEX files that I would prefer to reside in their own folder, with the package system used by MATLAB keeping it clear when I am calling those methods (and from where).
Is this possible? If not, is my only other option dropping the @
class folder convention and sticking everything into package (+
) folders?
matlab oop
matlab oop
asked Nov 18 at 20:12
questionable_code
1248
1248
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
You should put those private implementation files in a subdirectory private
. That is the traditional location for them. If you want to create some obvious hierarchy to organize code, I recommend long file names.
For example:
foo/@classfolder/MyClass.m
foo/@classfolder/method1.m
foo/@classfolder/method2.m
foo/@classfolder/private/physicssimulation_function1.m
foo/@classfolder/private/physicssimulation_function2.m
foo/@classfolder/private/physicssimulation_mexfile.mex
foo/@classfolder/private/uihelper_functionA.m
foo/@classfolder/private/uihelper_functionB.m
M-files and MEX-files in the private directory can be called from any function in the @classfolder
directory, as if they were on the path (i.e. you don’t use private
when calling them). But they are private to that directory, and not visible from outside.
The above recommendation assumes multiple class methods use the same private functionality. If only one method uses physicssimulation
, then all of its functions should be inside that method’s M-file. It’s the better way of keeping code together.
This seems like a decent way to do this, IMO. I suppose I was hoping for a little too much in the way of organization, when I should have just worried about where to put the MEX code in an accessible location.
– questionable_code
Nov 19 at 17:14
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
You should put those private implementation files in a subdirectory private
. That is the traditional location for them. If you want to create some obvious hierarchy to organize code, I recommend long file names.
For example:
foo/@classfolder/MyClass.m
foo/@classfolder/method1.m
foo/@classfolder/method2.m
foo/@classfolder/private/physicssimulation_function1.m
foo/@classfolder/private/physicssimulation_function2.m
foo/@classfolder/private/physicssimulation_mexfile.mex
foo/@classfolder/private/uihelper_functionA.m
foo/@classfolder/private/uihelper_functionB.m
M-files and MEX-files in the private directory can be called from any function in the @classfolder
directory, as if they were on the path (i.e. you don’t use private
when calling them). But they are private to that directory, and not visible from outside.
The above recommendation assumes multiple class methods use the same private functionality. If only one method uses physicssimulation
, then all of its functions should be inside that method’s M-file. It’s the better way of keeping code together.
This seems like a decent way to do this, IMO. I suppose I was hoping for a little too much in the way of organization, when I should have just worried about where to put the MEX code in an accessible location.
– questionable_code
Nov 19 at 17:14
add a comment |
up vote
4
down vote
accepted
You should put those private implementation files in a subdirectory private
. That is the traditional location for them. If you want to create some obvious hierarchy to organize code, I recommend long file names.
For example:
foo/@classfolder/MyClass.m
foo/@classfolder/method1.m
foo/@classfolder/method2.m
foo/@classfolder/private/physicssimulation_function1.m
foo/@classfolder/private/physicssimulation_function2.m
foo/@classfolder/private/physicssimulation_mexfile.mex
foo/@classfolder/private/uihelper_functionA.m
foo/@classfolder/private/uihelper_functionB.m
M-files and MEX-files in the private directory can be called from any function in the @classfolder
directory, as if they were on the path (i.e. you don’t use private
when calling them). But they are private to that directory, and not visible from outside.
The above recommendation assumes multiple class methods use the same private functionality. If only one method uses physicssimulation
, then all of its functions should be inside that method’s M-file. It’s the better way of keeping code together.
This seems like a decent way to do this, IMO. I suppose I was hoping for a little too much in the way of organization, when I should have just worried about where to put the MEX code in an accessible location.
– questionable_code
Nov 19 at 17:14
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
You should put those private implementation files in a subdirectory private
. That is the traditional location for them. If you want to create some obvious hierarchy to organize code, I recommend long file names.
For example:
foo/@classfolder/MyClass.m
foo/@classfolder/method1.m
foo/@classfolder/method2.m
foo/@classfolder/private/physicssimulation_function1.m
foo/@classfolder/private/physicssimulation_function2.m
foo/@classfolder/private/physicssimulation_mexfile.mex
foo/@classfolder/private/uihelper_functionA.m
foo/@classfolder/private/uihelper_functionB.m
M-files and MEX-files in the private directory can be called from any function in the @classfolder
directory, as if they were on the path (i.e. you don’t use private
when calling them). But they are private to that directory, and not visible from outside.
The above recommendation assumes multiple class methods use the same private functionality. If only one method uses physicssimulation
, then all of its functions should be inside that method’s M-file. It’s the better way of keeping code together.
You should put those private implementation files in a subdirectory private
. That is the traditional location for them. If you want to create some obvious hierarchy to organize code, I recommend long file names.
For example:
foo/@classfolder/MyClass.m
foo/@classfolder/method1.m
foo/@classfolder/method2.m
foo/@classfolder/private/physicssimulation_function1.m
foo/@classfolder/private/physicssimulation_function2.m
foo/@classfolder/private/physicssimulation_mexfile.mex
foo/@classfolder/private/uihelper_functionA.m
foo/@classfolder/private/uihelper_functionB.m
M-files and MEX-files in the private directory can be called from any function in the @classfolder
directory, as if they were on the path (i.e. you don’t use private
when calling them). But they are private to that directory, and not visible from outside.
The above recommendation assumes multiple class methods use the same private functionality. If only one method uses physicssimulation
, then all of its functions should be inside that method’s M-file. It’s the better way of keeping code together.
edited Nov 18 at 21:13
answered Nov 18 at 20:42
Cris Luengo
17k51847
17k51847
This seems like a decent way to do this, IMO. I suppose I was hoping for a little too much in the way of organization, when I should have just worried about where to put the MEX code in an accessible location.
– questionable_code
Nov 19 at 17:14
add a comment |
This seems like a decent way to do this, IMO. I suppose I was hoping for a little too much in the way of organization, when I should have just worried about where to put the MEX code in an accessible location.
– questionable_code
Nov 19 at 17:14
This seems like a decent way to do this, IMO. I suppose I was hoping for a little too much in the way of organization, when I should have just worried about where to put the MEX code in an accessible location.
– questionable_code
Nov 19 at 17:14
This seems like a decent way to do this, IMO. I suppose I was hoping for a little too much in the way of organization, when I should have just worried about where to put the MEX code in an accessible location.
– questionable_code
Nov 19 at 17:14
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53364992%2fpackage-folders-in-class-folders%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown