reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mariia Mykhailova <mamyk...@microsoft.com>
Subject RE: Is it a good idea for toString() to return null?
Date Tue, 05 Jan 2016 17:34:14 GMT
Any opinions?
Personally I feel we shouldn't return a special value for an otherwise good class which for
whatever reason failed to serialize, so we should either fall back to old conversion style
or throw an exception

-Mariia

-----Original Message-----
From: Mariia Mykhailova [mailto:mamykhai@microsoft.com] 
Sent: Thursday, December 31, 2015 9:51 AM
To: dev@reef.apache.org
Subject: RE: Is it a good idea for toString() to return null?

I don't think we can change method signature for toString() methods.
Should we return some special value instead? Something like "Failed to serialize"? Or should
we fall back to old-fashioned field-by-field conversion to string?

 Some of these methods (probably all) were introduced in https://github.com/apache/reef/pull/171/
, that's when using jackson instead of field-by-field was suggested.

-Mariia

-----Original Message-----
From: Markus Weimer [mailto:markus@weimo.de]
Sent: Wednesday, December 30, 2015 10:27 PM
To: dev@reef.apache.org
Subject: Re: Is it a good idea for toString() to return null?

> I've found a bunch of classes in
> org.apache.reef.runtime.hdinsight.client.yarnrest with toString() 
> methods which can return null. [...] Is it a good idea?

No, returning `null` is never a good idea. We generally use `Optional<T>` on the java
side to indicate when a method might return nothing.

I believe I wrote that code, and in great hurry when we prepared for the classes at the machine
learning summer school. Sorry about that!

Markus

Mime
View raw message