|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
WAS: throwing NullPointerException in codeRegarding null parameter detection...
Do you guys know @Nullable/@NotNull annotations introduced in IDEA a while ago? I guess there should be something similar in Eclipse and the like ... I found them very much useful and they work on return type, fields etc... Cheers, _marc |
|
|
Re: WAS: throwing NullPointerException in codealso found the @Required annotation useful in Spring-based apps
On 7/2/08, marc_polizzi <marc_polizzi@...> wrote: > > Regarding null parameter detection... > > Do you guys know @Nullable/@NotNull annotations introduced in IDEA a > while ago? I guess there should be something similar in Eclipse and > the like ... > > I found them very much useful and they work on return type, fields etc... > > Cheers, > _marc > > > > |
|
|
Re: WAS: throwing NullPointerException in codeThere's an on going JSR for the @Nonnull annotation and other similar
annotations. JSR-305 provides annotations that can assist defect detection tools such as IDEs and static analysis tools like FindBugs. Imagine working with numeric values and having annotations like @Nonnegative, @Signed, @CheckForNegative, @Positive and @CheckForNonpositive in your arsenal. It could come in handy right?.. but like anything if it's overused, it can make your code look more complexed than it really is. Especially if you use it along with other annotation based APIs. Here's more about JSR-305: http://jcp.org/en/jsr/detail?id=305 -Jay On 07 2, 08, at 2:10 PM, marc_polizzi wrote: > Regarding null parameter detection... > > Do you guys know @Nullable/@NotNull annotations introduced in IDEA a > while ago? I guess there should be something similar in Eclipse and > the like ... > > I found them very much useful and they work on return type, fields > etc... > > > Cheers, > _marc > > > > ------------------------------------ > > Yahoo! Groups Links > > > |
|
|
Re: WAS: throwing NullPointerException in codeOn Wed, Jul 2, 2008 at 11:43 PM, Jay Quiambao <jquiambao@...> wrote:
> JSR-305 provides annotations that can assist defect detection > tools such as IDEs and static analysis tools like FindBugs. > > It could come in handy right?.. but > like anything if it's overused, it can make your code look more complexed > than it really is. Especially if you use it along with other annotation > based APIs. Like, say, JSR 303 - bean validation through annotations? Annotations hell, here we come (and I used to be a big fan of them): @Entity @Table(name = "foos") public class Foo { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", nullable = false) @NotNull @Nonnull @Required private Integer id; // ... } Yup. Very readable. - a -- http://alistairisrael.wordpress.com |
|
|
Re: WAS: throwing NullPointerException in codeI'm basically against that JSR ;-)
I do not think that pre-condition/post-condition should be done via the annotations mechanism. Talking back to the @Nullable annotation... I find it very much useful 'coz IntelliJ IDEA can then infer proper usage of such value and tell you when you must check for nullity before using the variable (most useful when dealing with fields). This is done while typing or via report generation for nightjob. In the team, we've got used to and I guess that's one the smartest annotation I've ever met ;-) I'm still waiting for the C++ const; but that is another story ;-) I agree that annotations are awful to read (e.g., Hibernate and the like); a while ago I've asked the dev. of IDEA to do something for that and now all I see is: @{...} public class MyPersistentObject I can go over it to look at the annotations or expand it ... nice ;-) Cheers, _marc --- In pinoyjug@..., "Alistair Israel" <aisrael@...> wrote: > > On Wed, Jul 2, 2008 at 11:43 PM, Jay Quiambao <jquiambao@...> wrote: > > JSR-305 provides annotations that can assist defect detection > > tools such as IDEs and static analysis tools like FindBugs. > > > > It could come in handy right?.. but > > like anything if it's overused, it can make your code look more complexed > > than it really is. Especially if you use it along with other annotation > > based APIs. > > Like, say, JSR 303 - bean validation through annotations? Annotations > hell, here we come (and I used to be a big fan of them): > > @Entity > @Table(name = "foos") > public class Foo { > > @Id > @GeneratedValue(strategy = GenerationType.IDENTITY) > @Column(name = "id", nullable = false) > @NotNull > @Nonnull > @Required > private Integer id; > > // ... > } > > Yup. Very readable. > > - a > -- > http://alistairisrael.wordpress.com > |
| Free Forum Powered by Nabble | Forum Help |