[aerogear-dev] Android library: Are nulls icky

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[aerogear-dev] Android library: Are nulls icky

Summers Pittman
So I try to avoid nulls wherever possible.  In the case of the
Authenticator (and Pipeline) API's we have methods get(String name).

The obvious thing to do would be to return a null object if the name
isn't a known name.

Would it be better/preferable to return some kind of default
AuthenticationModule (or Pipe) which does nothing instead?

Alternatively we could supply a peek(name) method which tests for the
name and throw an exception if you call get with a bad name.

Just some idle thoughts.

Summers
_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev
Reply | Threaded
Open this post in threaded view
|

Re: [aerogear-dev] Android library: Are nulls icky

Summers Pittman
I've added a gist with some pseudo code to describe what I am talking bout.

https://gist.github.com/1efc515a68e3585817f4

On 10/24/2012 02:12 PM, [hidden email] wrote:

> So I try to avoid nulls wherever possible.  In the case of the
> Authenticator (and Pipeline) API's we have methods get(String name).
>
> The obvious thing to do would be to return a null object if the name
> isn't a known name.
>
> Would it be better/preferable to return some kind of default
> AuthenticationModule (or Pipe) which does nothing instead?
>
> Alternatively we could supply a peek(name) method which tests for the
> name and throw an exception if you call get with a bad name.
>
> Just some idle thoughts.
>
> Summers
> _______________________________________________
> aerogear-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev
Reply | Threaded
Open this post in threaded view
|

Re: [aerogear-dev] Android library: Are nulls icky

Matthias Wessendorf
returning a "null object", which does nothing would be an interesting approach..

That said, I think on iOS (for now) i stay with the current approach returning 'nil' - if a store,pipe,(auth)module could not be found. I guess JS does the same.



On Wed, Oct 24, 2012 at 9:03 PM, <[hidden email]> wrote:
I've added a gist with some pseudo code to describe what I am talking bout.

https://gist.github.com/1efc515a68e3585817f4

On 10/24/2012 02:12 PM, [hidden email] wrote:
> So I try to avoid nulls wherever possible.  In the case of the
> Authenticator (and Pipeline) API's we have methods get(String name).
>
> The obvious thing to do would be to return a null object if the name
> isn't a known name.
>
> Would it be better/preferable to return some kind of default
> AuthenticationModule (or Pipe) which does nothing instead?
>
> Alternatively we could supply a peek(name) method which tests for the
> name and throw an exception if you call get with a bad name.
>
> Just some idle thoughts.
>
> Summers
> _______________________________________________
> aerogear-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf

_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev
Reply | Threaded
Open this post in threaded view
|

Re: [aerogear-dev] Android library: Are nulls icky

Bruno Oliveira
+1 on follow the same approach


-- 
"The measure of a man is what he does with power" - Plato
-
@abstractj
-
Volenti Nihil Difficile

On Thursday, October 25, 2012 at 3:52 AM, Matthias Wessendorf wrote:

returning a "null object", which does nothing would be an interesting approach..

That said, I think on iOS (for now) i stay with the current approach returning 'nil' - if a store,pipe,(auth)module could not be found. I guess JS does the same.



On Wed, Oct 24, 2012 at 9:03 PM, <[hidden email]> wrote:
I've added a gist with some pseudo code to describe what I am talking bout.

https://gist.github.com/1efc515a68e3585817f4

On 10/24/2012 02:12 PM, [hidden email] wrote:
> So I try to avoid nulls wherever possible.  In the case of the
> Authenticator (and Pipeline) API's we have methods get(String name).
>
> The obvious thing to do would be to return a null object if the name
> isn't a known name.
>
> Would it be better/preferable to return some kind of default
> AuthenticationModule (or Pipe) which does nothing instead?
>
> Alternatively we could supply a peek(name) method which tests for the
> name and throw an exception if you call get with a bad name.
>
> Just some idle thoughts.
>
> Summers
> _______________________________________________
> aerogear-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
_______________________________________________
aerogear-dev mailing list


_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev
Reply | Threaded
Open this post in threaded view
|

Re: [aerogear-dev] Android library: Are nulls icky

Kris Borchers
In reply to this post by Matthias Wessendorf
In JS, there is just an array on the Pipeline/Auth/DataManager object instance that the developer just accesses directly to retrieve the pipe/module/store by name or index. If they reference one that doesn't exist, an error is thrown.

On Oct 25, 2012, at 12:52 AM, Matthias Wessendorf <[hidden email]> wrote:

returning a "null object", which does nothing would be an interesting approach..

That said, I think on iOS (for now) i stay with the current approach returning 'nil' - if a store,pipe,(auth)module could not be found. I guess JS does the same.



On Wed, Oct 24, 2012 at 9:03 PM, <[hidden email]> wrote:
I've added a gist with some pseudo code to describe what I am talking bout.

https://gist.github.com/1efc515a68e3585817f4

On 10/24/2012 02:12 PM, [hidden email] wrote:
> So I try to avoid nulls wherever possible.  In the case of the
> Authenticator (and Pipeline) API's we have methods get(String name).
>
> The obvious thing to do would be to return a null object if the name
> isn't a known name.
>
> Would it be better/preferable to return some kind of default
> AuthenticationModule (or Pipe) which does nothing instead?
>
> Alternatively we could supply a peek(name) method which tests for the
> name and throw an exception if you call get with a bad name.
>
> Just some idle thoughts.
>
> Summers
> _______________________________________________
> aerogear-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev
Reply | Threaded
Open this post in threaded view
|

Re: [aerogear-dev] Android library: Are nulls icky

Matthias Wessendorf
going to:

opening the JS console (in Chrome) and executing this script in the console, I don't see an error...



I get 'undefined' - which 'close' to nil/null ;




On Thu, Oct 25, 2012 at 3:04 PM, Kris Borchers <[hidden email]> wrote:
In JS, there is just an array on the Pipeline/Auth/DataManager object instance that the developer just accesses directly to retrieve the pipe/module/store by name or index. If they reference one that doesn't exist, an error is thrown.

On Oct 25, 2012, at 12:52 AM, Matthias Wessendorf <[hidden email]> wrote:

returning a "null object", which does nothing would be an interesting approach..

That said, I think on iOS (for now) i stay with the current approach returning 'nil' - if a store,pipe,(auth)module could not be found. I guess JS does the same.



On Wed, Oct 24, 2012 at 9:03 PM, <[hidden email]> wrote:
I've added a gist with some pseudo code to describe what I am talking bout.

https://gist.github.com/1efc515a68e3585817f4

On 10/24/2012 02:12 PM, [hidden email] wrote:
> So I try to avoid nulls wherever possible.  In the case of the
> Authenticator (and Pipeline) API's we have methods get(String name).
>
> The obvious thing to do would be to return a null object if the name
> isn't a known name.
>
> Would it be better/preferable to return some kind of default
> AuthenticationModule (or Pipe) which does nothing instead?
>
> Alternatively we could supply a peek(name) method which tests for the
> name and throw an exception if you call get with a bad name.
>
> Just some idle thoughts.
>
> Summers
> _______________________________________________
> aerogear-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev




--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf

_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev
Reply | Threaded
Open this post in threaded view
|

Re: [aerogear-dev] Android library: Are nulls icky

Kris Borchers
Sorry, I was thinking one step beyond that and trying to use the undefined pipe. If you did badGuy.read(), you would get an error something like "Object doesn't have the method, read: undefined" or something like that. Actually referencing the pipe is just undefined, which is not the same as null but pretty close.

On Oct 25, 2012, at 8:24 AM, Matthias Wessendorf <[hidden email]> wrote:

going to:

opening the JS console (in Chrome) and executing this script in the console, I don't see an error...



I get 'undefined' - which 'close' to nil/null ;




On Thu, Oct 25, 2012 at 3:04 PM, Kris Borchers <[hidden email]> wrote:
In JS, there is just an array on the Pipeline/Auth/DataManager object instance that the developer just accesses directly to retrieve the pipe/module/store by name or index. If they reference one that doesn't exist, an error is thrown.

On Oct 25, 2012, at 12:52 AM, Matthias Wessendorf <[hidden email]> wrote:

returning a "null object", which does nothing would be an interesting approach..

That said, I think on iOS (for now) i stay with the current approach returning 'nil' - if a store,pipe,(auth)module could not be found. I guess JS does the same.



On Wed, Oct 24, 2012 at 9:03 PM, <[hidden email]> wrote:
I've added a gist with some pseudo code to describe what I am talking bout.

https://gist.github.com/1efc515a68e3585817f4

On 10/24/2012 02:12 PM, [hidden email] wrote:
> So I try to avoid nulls wherever possible.  In the case of the
> Authenticator (and Pipeline) API's we have methods get(String name).
>
> The obvious thing to do would be to return a null object if the name
> isn't a known name.
>
> Would it be better/preferable to return some kind of default
> AuthenticationModule (or Pipe) which does nothing instead?
>
> Alternatively we could supply a peek(name) method which tests for the
> name and throw an exception if you call get with a bad name.
>
> Just some idle thoughts.
>
> Summers
> _______________________________________________
> aerogear-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev




--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-dev