How to move mfiles from a "sandbox" to a package folder?

1 view (last 30 days)
Background:
  • thirty files in an ordinary folder, most of which define user classes.
  • a test suite that covers most of the code
  • I use Notepad++ when medit fails me
  • I failed to find any instructions on how to do this task efficiently.
Objective:
  • Move the files to a package folder
How I did it:
  • run sad=dir('*.m') and created a list of the the files to be included
  • made a function sandbox2package, which read the old files, inserts the package name where it is needed, and writes to the new package folder.
  • sandbox2package worked fairly well with the source code, which went into the package. The result after editing was "57 hits in 24 files". There was some missed replacements, e.g. in feval( keyword, arguments ). Cannot be avoided. And "false" replacement where class names clashed with field names of structures.
  • sandbox2package did a poor job with the test suite. However, I didn't realize how poor until I had started running the test suite. When the test suite finally passed the where "99 hits in 1 file".
Discussion:
I feel this post would fit as an answer to What frustrates you about MATLAB?. This time the tool "Find in Files" frustrates me. It ought to be the tool for this job. However,
  • it doesn't support regular expressions; a space more or less may spoil a search
  • it doesn't recognizes multi-line-comments
  • it cannot filter out comments
  • it doesn't support Replace
  • etc.
  • All of which are standard features.
  • Do Find&Replace&Confirm in a loop over all files might have been more efficient.
Conclusions:
  • When undertaking a task like this, a test suite is really valuable
Questions:
There must be a better way!
  • How would you move a group of files to a package folder?
  • Put the files in a package folder from the start is not the answer I want.
  • insert import package_name.* in "all" methods? Intuitively, that is not good.
  • use import package_name.class_name in a more clever way

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!