-
Notifications
You must be signed in to change notification settings - Fork 11
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
Created app should use groovy gradle styling #398
Comments
FYI... I think the examples you cited are indeed Strings. I don't think Groovy creates GStrings for something like "org.grails:grails-console". I think the compiler knows that is a String. |
Thanks for clarifying @jeffscottbrown implementation "org.springframework.boot:spring-boot-starter-logging" |
It's obviously a personal preference, but for what it's worth, I prefer single quotes as it helps my brain distinguish between String and GString without having to check. Also, again my opinion, single quotes take up less space, which makes the code easier to read. |
@matrei I agree, but knowing now it always compiles to a String changed my perspective because
assert "Test" instanceof String
assert "Test" instanceof GString // <-- Fails |
That's part of the feature, I don't have to actively check if there is a variable in the string when reading/scanning the code.
This is the drawback, but with |
You need double quotes for versions from If we want them to match, double quotes would be the way to go. With the grails-bom expansion, these are rarer, but there will be a few in a normal Grails apps. Some examples from one of my projects:
|
I've spent a lot of time thinking about this and I now advocate for double quotes. My rational is for consistency across the entire file and still accomodate situations that need GStrings. It is also from the perspective of clarity for people that are not fluid in the Groovy language. Previously I adopted the Groovy purist perspective where '' was always used for Strings, but considering the fact Groovy has lost a lot of popularity and has tried in several ways to be more like Java over the past 5 years, I think it is better to preference Java like constructs when the Groovy equivalent does not provide any gains. This is more to eliminate any confusion to someone new to the Groovy language. |
Sounds like the majority favors double quotes |
lol, I still like single quotes, but if Groovy isn't going to have a purist mentality when it compiles double quotes into Strings, why should I? |
Current app looks like Kotlin and adds a bunch of unnecessary characters.
Not sure why this happened, but if we are going to keep this route we should also add semi-colons to every line.
Formatting should be the same as it always has been:
centralize dependency versions in
gradle.properties
so they are not repeated multiple times.The text was updated successfully, but these errors were encountered: