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
Organizing files into sub-packages #614
Comments
As a new contributor, I agree that organizing the source files into subpackages would make it easier to focus on one issue. |
Thanks @ianonavy and welcome! Glad to have you :) @revel/core any thoughts? |
Seems reasonable, though how would we not break compatibility? Keep the common public interfaces in the root package, and proxy to the subpackages? |
It'd be nice to retain compatibility but I don't think that should be too large of a concern. We haven't yet released v1.0, so it should be assumed things will break. |
Yes, proxying/exposing the needed functionality would be a good solution. I don't think the currently exposed interface would perceivably change. The restructuring would be only internal. Is there something I a may be overlooking? Perhaps the only way to be 100% certain is to give it a go. |
Checkout the revised roadmap and specifically the "Create subpackages" list item. Does everyone agree that this list is reasonable and complete? Are there any other Revel components that should be made into sub-packages? |
Pardon my ignorance, but what is |
@NitroKKX when I say "subpackage" I mean exactly what you are thinking of: a subfolder inside the Revel core package that is then imported by the top level Revel code. It's a way to organize Go code since in Go each folder must be its own package. To start, these subpackages will be internal only. |
@brendensoares, what as for |
@AnonX that's a possible package, but it seems it might be better as a more specific set of util packages instead of some catch all package. What do you think? |
Thanks for the explanation @brendensoares , I hadnt heard it termed subpackages before and just wanted to ensure I understood you properly. Shouldnt |
@NitroKKX Good point about moving the |
@brendensoares, Looks like And I'd like to clarify what naming convention could be applied to |
@AnonX isn't |
OK, I agree. @brendensoares, there is one more naming issue. How can the package Let's make a decision on naming of every subpackage in advance.
|
@brendensoares And could you please clarify the criteria for extracting a component into subpackage. For example, we are going to turn |
Where are we now with this.. I think there are inbuilt packages/modules eg jobs, testrunner ? and a manual for others.. maybe we need |
@pedromorgan see the Roadmap for v0.12 and specifically the "Create sub-packages" checkbox. I would like to create a few more internal packages, but @AnonX brings up some good points that I haven't thought through fully. @AnonX my high level goal is to have a clear separation of concerns. I'd like to do this without affecting the exported interface that Revel devers see. I want it to be a purely internal change. I will admit that sub-packages may not be the correct solution for each of the items listed above and I am ready to find more reasonable solutions if we can think of them. As far as criteria for creating a sub-package, I'd say if a segment of code is independently functional and complex enough (say ~300 lines of code or more) then we should seriously consider its re-organization. The criteria is somewhat subjective though. PS - I am inclined to split v0.12 into 2 releases as it's too large currently. It's more important that we keep consistent momentum than trying to release large improvements. Agreed? |
@AnonX it just struck me that we may not be understanding sub-packages the same way. Not all that I've suggested on the v0.12 Roadmap should be external packages. Internal, independently testable packages are more appropriate than external for most, if not all, of the remaining items. Agreed? |
@brendensoares I'm asking about the criteria just for practical reasons. We have revel.Filters = []revel.Filter{
...
revel.RouterFilter,
revel.SessionFilter,
...
} I, as a user of the framework, expect that every standard filter will have predictable import path. For example: import (
"github.com/revel/revel/routing"
"github.com/revel/revel/session"
) So the filters above can be used as: ...
routing.Filter,
session.Filter,
... If import paths are different I feel like something is wrong with consistency: revel.Filters = []revel.Filter{
revel.PanicFilter,
routing.RouterFilter,
revel.FilterConfiguringFilter,
params.Filter,
}
👍
By external you mean packages in separate repos? If so, yes I agree with you. Now I'm not even sure that creation of a separate |
@AnonX to your last point, the value I see is that it provides a place to put community driven modules and samples and alleviates the clutter in the core library. It does aggravate the package management issue aka version dependency, but that's a good thing; we need to decide a solution for that ASAP. In regards to splitting the release, any good ideas on a release theme to put on the Roadmap? Lastly, I didn't expect a dever to have to import any of the internal sub-packages, but maybe that was an oversight on my part. The Either way, it would be productive if we could chat directly for 30 minutes to outline RFCs for each of the remaining code re-organization efforts aka sub-packages. |
@NitroKKX I've chatted with @AnonX and we decided it's best to keep Here is the outcome of our chat as far as new sub-packages:
|
Makes sense to me. Thanks On Sat, Jan 3, 2015, 11:38 PM Brenden Soares notifications@github.com
|
After trying to combine
So, it seems we'll need a |
Rather than |
There are |
For logs, we could define it as an interface in revel and implement it in a different package. From what I have seen with logging there are many different approaches to take, rather than attempt to have revel do it all why not allow someone to implement an interface to there favorite logging package and assign it in the config. By default revel would use the golang logger, (which would be in its own package) |
@AnonX we can consider the use of dependency injection for challenges like this, but in this case, I don't think we even need the logger. It seems the better solution is to return errors where applicable instead of logging the errors directly. Revel can do what it wants with the errors. Agreed? @notzippy the new logger interface is planned for v0.15. It's a need, but not as important as other items. |
@brendensoares Yes, good idea. But sounds like a lot of work. |
@AnonX I'm almost ready to push the PR for review. I have one last |
@brendensoares I'm looking forward to it. |
I agree with organizing, if possible making independent as possible. But my question is about naming and structure, for example: import (
"github.com/revel/revel/routing"
"github.com/revel/revel/session"
) Instead, it's better have structure/name like this: import (
"github.com/revel/log"
"github.com/revel/routing"
"github.com/revel/session"
"github.com/revel/auth"
"github.com/revel/csrf"
"github.com/revel/db"
"github.com/revel/testing"
// etc...
) |
@revel/core What do you think about organizing the go files in the root directory into sub-packages?
I tried simply moving them into sub-folders, but in order for them to share the
revel
package they have to be in the same folder (this is odd and slightly irritating).We should be able to do this without breaking compatibility and without introducing circular dependencies. Doing this should increase our separation of concerns and hopefully improve code quality through clear lines of division and unit testing.
I also feel that reorganizing into sub-packages will make contribution to Revel more inviting to the Go community and/or new comers.
The text was updated successfully, but these errors were encountered: