Hi,
In my opinion, returning an empty object is far better. It will reduce
unnecessary null checks and will stop the code from going on different
paths. And code quality wise also I think returning empty is cleaner.
For example:
*List list = getList();*
*for (Item item : list) {// Do logic.*
*// This will not execute if the list is empty.*
*}*
Is much cleaner than
*List list = getList();*
*if (list == null) {*
*// Handle the logic.*
*// Now this is a different code path.*
*}*
Thanks!
*Jayanga Kaushalya*
Software Engineer
Mobile: +94777860160
WSO2 Inc. | http://wso2.com
lean.enterprise.middleware
On Tue, Jul 12, 2016 at 10:05 AM, Sabra Ossen <[email protected]> wrote:
> Hi Chamila,
>
> I checked from findbugs and it didn't return an error. Is returning an
> empty object a practice followed in WSO2?
>
> On Tue, Jul 12, 2016 at 9:25 AM, Chamila Wijayarathna <
> [email protected]> wrote:
>
>> Hi Sabra,
>>
>> AFAIK when we return a null from a method, find bugs show it as an error
>> (please check this) and to fix this we use empty objects. So I think the
>> returning null is not something we should do.
>>
>> Thank You!
>>
>
>
>
> --
> *Sabra Ossen*
> *Software Engineer*
> Email: [email protected]
> Mobile: +94 767 837356
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev