27.03.2011 21:14, TreKing ?????:
On Sun, Mar 27, 2011 at 10:58 AM, Kostya Vasilyev <kmans...@gmail.com <mailto:kmans...@gmail.com>> wrote:

        Any Singleton, manager, or utility class can take Context as a
        parameter for the functions it needs it for, making it clear
        to the user of the API that a Context is needed for that
        functionality


    Sure, that's another way. I prefer to not do this, but coding
    style is a personal thing.


Word. I'm just curious to see if there are more practical reasons to use one vs the other. In case I've been doing it wrong all along :-)

One could argue that some singleton/manager/utility needing a Context to do its work is an implementation detail of that class, and therefore should be exposed as little as possible.

One could also argue that this style requires that for a new class of that kind, you either make all methods take a Context parameter right away, which may not be necessary, or add it only to those methods that need it, which may change over time, causing an unnecessary interface change, which in turn can possibly trigger more code changes, because callers now need to provide a context reference where they didn't before.

But I'm not going to make any such arguments, because they border on religious, worshiping The Mighty Gods of True Object Oriented Programming, whoever they are, and I'm just not very interested in that :)

--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to