For me, switching to Groovy was great because it auto generates the code that
isn't important: getters and setters. My code became more clean because they
don't have that extra code bogging them down. For me, it makes since to use
shortcuts as much as I can to cut down my programming.
If one of your main objections is that it looks too much like Scala (which I
didn't know had this type of syntax) then you probably shouldn't be
objecting. The characters `=>` are just as meeningfull as `:`. It could be
written as:
class Bash {
String name
Bash(String: name) {}
}
new Bash("foo")
Now onwards to my reasoning for this in the first place.
Post by Jochen TheodorouNormally current usage would be something like
class Bash {
String name
}
new Bash(name:"foo")
As a person who writes lots of frameworks rather than end developer things,
it isn't super useful for me to have a blank constructor that the end user
can have inputs such as their name into. Many constructors I write look like
this
<https://github.com/czipperz/CLibrary/blob/master/src/io/czipperz/github/cLibrary/game/CView.groovy>
:
CView(CGameFrame displayOn, Rectangle bounds, int depth = 0) {
this.bounds = bounds
this.displayOn = displayOn
this.drawAllObjects = true
this.depth = depth
this.bufferDimension = new Dimension()
this.needDraw = true
}
If we had this framework (assuming the `:` symbol is used since that is what
normal Groovy uses for similar purposes):
CView(CGameFrame: displayOn, Rectangle: bounds, int: depth = 0) {
this.drawAllObjects = true
this.bufferDimension = new Dimension()
this.needDraw = true
}
This is much more useful to a developer that having the end user able to
specify variables and you are supposed to trust them to setup the class with
the right variables.
Here is the reasoning having any of this in the first place, taken from The
Biggest Problem in the Universe: Episode 21
<http://media.biggestproblemintheuniverse.com/wp-content/uploads/2014/10/Maddox_BPU_21.htm>
Post by Jochen Theodorouevery iPhone user is like, (silly voice) "Well, I wouldn't use it anyway.
I wouldn't use that feature anyway." And you know what? You don't have the
option to.
...
No one's saying you have to use it. But they're like "Well, I wouldn't use
it anyway." And they ALWAYS say that until they get the feature, and then
guess what? They're fucking using it.
...
And every single one of these idiots I argued with. I said "Hey man, you
can't install apps." And they were like (silly voice) "Well, we wouldn't
use that anyway! We would just use web apps!" And then of course, the next
model iPhone comes out and Apple's all about apps.
This is a bad analogy but the point is that you shouldn't reject features
that don't hurt anyone or conflict with anything before you use them. Try
writing two classes that are semi advanced with using this feature vs not
using this feature. If the developer can tell easily what this means, which
it should be, then it shouldn't be a problem for anyone to use.
The reason I was saying we could use the syntax:
void print(String textToBeInputtedToTheCBashThatWillBePrintedDirectly:
print) {}
So that when I'm in my IntelliJ and looking at how to invoke a method, I
don't have to stop in the middle of one of the popup windows that show up
with descriptions of the methods and figure out what the variable means,
what to input if I'm trying to make something up on the spot:
void print(String textToBePushedAsTheProperty: prop, String
textToBeInputtedBackIntoTestingCycle: line) {}
This may not be super useful but we might as well included for the same
reason that we might as well include removal batteries in phones. Why not
double the battery life for curtain consumers.
--
View this message in context: http://groovy.329449.n5.nabble.com/Contributing-a-simple-yet-powerful-symbol-tp5723371p5723381.html
Sent from the groovy - dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email