Looking for Best Practices ...
This is in a script listener:
// Grab Event
thisEvent = event as IssueLinkCreatedEvent
or
// Grab Event
IssueLinkCreatedEvent thisEvent = event
I like the first style better as it's easier to "scan" the code, but I see the second one used a lot more.
I don't know if the first way is "old / outdated" ... or "new / cutting edge". Could not find anything on this.
I don't know about best/old/new.
But the first case would allot thisEvent to be re-assigned to a different type later if necessary as it's not strongly typed.
But the second will forever be an IssueLinkCreatedEvent and can't hold anything else.
Example:
def test = "abc" as String
test = 1 as Long
assert test instanceof Long
vs
String test = "abc"
test = 1 as Long //this will be coherced into a string, other types may fail
assert test instanceof String
Thank you.
I was not aware of a "strongly" versus "loosely" typed concept.
I have not done a lot of work in strongly typed, fully object oriented languages. I can see how this makes sense with Java's propensity for overloaded methods.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.