Re: [android-developers] return object or listobject

2014-08-05 Thread Dan
I'm guessing your colleague felt that something where a response of 0 things to operate on is not an error condition it is easier to deal with a 0 entry list, for example: public int getFooTotalValue() { int fooTotal = 0; ListFoo fooList = getFooList(); for (Foo afoo :

[android-developers] return object or listobject

2014-08-04 Thread sweety fx
A method is supposed to return a object when called. Which is better to implement for the method: 1. Is it better to have the method return an object. 2. Or return ListObject where the single object is added to the array list. because, we can check for list.isEmpty() which is better than

Re: [android-developers] return object or listobject

2014-08-04 Thread Steve Gabrilowitz
How would list.isEmpty() be better than object==null? If you never plan on returning more than one object then it makes no sense to use a list. On Aug 4, 2014 11:04 AM, sweety fx fxswe...@gmail.com wrote: A method is supposed to return a object when called. Which is better to implement for

Re: [android-developers] return object or listobject

2014-08-04 Thread sweety fx
My colleague mentioned list is the better way of doing it. So that we don't face null pointer exceptions. since we check for list.isEmpty() But I wasn't sure, thats why I am checking. On Monday, August 4, 2014 3:42:35 PM UTC-4, Steve Gabrilowitz wrote: How would list.isEmpty() be better than

Re: [android-developers] return object or listobject

2014-08-04 Thread TreKing
On Mon, Aug 4, 2014 at 2:51 PM, sweety fx fxswe...@gmail.com wrote: My colleague mentioned list is the better way of doing it. So that we don't face null pointer exceptions. since we check for list.isEmpty() You're replacing one if check for another and making your code confusing. This is not

Re: [android-developers] return object or listobject

2014-08-04 Thread Damien Cooke
It would be my opinion that you return a Object if you do not intend to return any more than one of them. Else it may become confusing reading your code later. Regards Damien On Tue, Aug 5, 2014 at 12:34 AM, sweety fx fxswe...@gmail.com wrote: A method is supposed to return a object when