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?










share|improve this question


























    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?










    share|improve this question
























      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?










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 18 at 20:12









      questionable_code

      1248




      1248
























          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.






          share|improve this answer























          • 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











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          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

























          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.






          share|improve this answer























          • 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















          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.






          share|improve this answer























          • 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













          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.






          share|improve this answer














          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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


















          • 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


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin