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

avoid static imports in Java sample code #140

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

rjayasinghe
Copy link
Contributor

in case this code is copied to an IDE the imports are missing and you have a bit of a challenge to find the right import for the static imports (VS Code Java extension does not support it at all at the moment).

Alternatively we could also use the new 'focus' feature for code blocks and include the static import statements as 'unfocused' but have them included in the clipboard after clicking the copy button.

in case this code is copied to an IDE the imports are
missing and you have a bit of a challenge to find the
right import for the static imports (VS Code Java extension
does not support it at all at the moment).

Alternatively we could also use the new 'focus' feature
for code blocks and include the static import statements as
'unfocused' but have them included in the clipboard after clicking
the copy button.
@rjayasinghe rjayasinghe requested a review from mofterdinger May 9, 2023 12:39
@agoerler
Copy link
Contributor

I think the static imports improve readability but should be mentioned somewhere

@Autowired
@Qualifier(CatalogService_.CDS_NAME)
private CqnService catalogService;
@Autowired
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid tabs as they are rendered with 8 (!) spaces

@rjayasinghe
Copy link
Contributor Author

I think the static imports improve readability but should be mentioned somewhere

Some of the statically imported symbols are ambiguous when being imported to an IDE. Even worse, VS Code has no way to resolve the imports with a code action.

So, either we avoid static imports (first commit) or have the imports as part of the code block (but blur them) in order to guide the readers eye.

@renejeglinsky
Copy link
Contributor

Can this be merged? I had the feeling it's not final, that's why I'm asking.

@rjayasinghe
Copy link
Contributor Author

Let's at least update with the base branch. @agoerler merge or talk? ;)

@agoerler
Copy link
Contributor

@agoerler merge or talk? ;)

talk :-)

@renejeglinsky
Copy link
Contributor

We could do sth similar to what we've done in the getting started in a Nutshell. There we have the small snippets that is needed and in addition a detail box that can be expanded if you want the full code example incl. imports.

image

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

Successfully merging this pull request may close these issues.

3 participants