Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use packages to avoid having to add many subdirectories to the path #2

Open
raacampbell opened this issue Jan 4, 2017 · 8 comments
Labels

Comments

@raacampbell
Copy link
Collaborator

raacampbell commented Jan 4, 2017

If we use packages instead of adding lots of subdirectories to the path then the install procedure might be smoother and there will be less chance of namespace clashes.

Whilst the downside is that we will need to refactor code, this doesn't need to be done all at once. i.e. we can slowly move stuff over to package directories.

@raacampbell
Copy link
Collaborator Author

raacampbell commented Jan 4, 2017

Started work on this in commits ffca49d and 3b170c8.

I have created a package called masiv in the project root directory (i.e. not in the code directory) because this is the one that the user is currently supposed to add to the MATLAB path. The functions that were in the fileIO directory are all now in the directory +masiv/+fileio and so are addressable using masiv.fileio.FUNCTION_NAME.

@alexanderbrown
Copy link
Collaborator

How far do you think we should take this? I've started by making a yaml subpackage, and converting all the code. Do we want to rearrange everything in code in to a package? Or just code/resources?

@raacampbell
Copy link
Collaborator Author

Potentially we could put everything into packages. I can only see advantages to doing this. I'm currently working on the pluginManager package. Also, everything in the root private directory will go into masiv.utils, which I've just created locally. Commit coming soon, I'm just checking nothing is broken in plugin manager.

@alexanderbrown
Copy link
Collaborator

cool, sounds good. I'll leave it to you!

@alexanderbrown
Copy link
Collaborator

Can I make a slightly annoying suggestion - to rename the package from +masiv as it can cause a clash with masiv.m that made debugging a bit confusing when I started moving things around.

@raacampbell
Copy link
Collaborator Author

We can if it's a problem. Before we do it, though, let's think it through carefully because there are a lot of files I'll have to change.

I chose +masiv (same name as the program) because that's how ScanImage does it and it makes for a nice logical interface at the command line. So if we do rename stuff, what do we rename it to? One option might be to rename masiv.m to MaSIV.m, but I don't like that particularly.

In what way does the debugging become confusing?

@alexanderbrown
Copy link
Collaborator

Sure, i thought it might be a bit of an unneccessary hump.

The problem was when I tried to create a sub-package at +masiv/+fileio/+yaml. I kept getting messages about the masiv class not having a static function called fileio, which makes no sense. Took me a while to track down that the problem was in trying to layer packages in this way; it fails more gracefully if there is no namespace conflict

@raacampbell
Copy link
Collaborator Author

I see. Should we just leave things as they are for a week or two and see how bad the confusion really is? It might just all make sense once the migration to the packages is complete. If it doesn't we can write a Perl script or summat and do a batch rename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants