-
Notifications
You must be signed in to change notification settings - Fork 2
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
Organize imports with common layout #2
Comments
This IDEA import layout table contains entries for all packages in use throughout all current `bisq-*` repositories. See the linked issue for details and rationale. This commit also adds a `copy-import-layout.sh` script for convenience when copying changes to this file to all `bisq-*` repositories that already contain an .idea/codeStyles directory. Note that this script assumes one is using `mr` and the `.mrconfig` file in the root of this repository to manage bisq-network GitHub org repositories under a single root.
- Remove dependency on bisq-common from build.gradle - Use camel case spelling of 'WeChat' consistently - Organize imports with common layout (bisq-network/style#2)
- Use camel case spelling of 'WeChat' consistently - Organize imports with common layout (bisq-network/style#2)
I believe the link to the I will note that this custom ordering seems complex, compared to the Google Java style guide: This rule does make it somewhat harder to contribute using non-IDEA editors, since one needs to refer to the It was also unclear to me:
|
Also drops static imports as it is unclear how to order them. Attempts to comply with bisq-network/style#2.
We keep a master
.idea/codeStyles/
directory in the root of the https://github.com/bisq-network/dao repository. This directory contains aProject.xml
with anIMPORT_LAYOUT_TABLE
to be used across allbisq-*
Java projects. We keep this file up to date and copy it to allbisq-*
repositories whenever changes to the import layout are necessary.There is nothing you need to do to set this up. If you're using IDEA to work on
bisq-*
projects, everything should "just work", because the project you're working on already has a copy of these settings in its own.idea/codeStyles
directory.If you introduce a new import to a
bisq-*
repository that is not yet listed in the common import layout table, it will get sorted at the bottom of the import list, preceded by several blank lines. This is your clue that you need to add an entry to the import table. You can do this locally in your project, i.e. directly in its.codeStyles/Project.xml
, or you can do it at the rootbisq-network/dao
repository level and copy it everywhere. All that matters is that the change gets committed and that imports get laid out correctly.The order of imports in the layout table is not alphanumeric. It is based on how high or low level the package is in the overall layering of all packages.
bisq.*
packages are always sorted at toporg.bitcoinj
This approach to ordering imports is all about providing maximum at-a-glance information to the reader of the source. By simply looking at the name of a class and its imports, a reader should be able to get a good sense of what that class does, what it "touches", what it is responsible for, etc. Indeed, taking an intentional approach to import organization and using this metadata as a code comprehension tool can help provide early warnings about when a class is starting to do too much, get tangled up with other packages and layers, etc.
Recommendation: disable the default "import folding" setting in IDEA. Keep imports "in your face" and use them to your advantage to keep types, packages and layers clean.
See:
The text was updated successfully, but these errors were encountered: