It's "bad" no matter what, because any time you call a getter, you are
looking at the target object in terms of the data it contains, not WHAT IT
CAN DO.

That said, there are two situations (in my opinion) where getters are mostly
acceptable. One is at the object-procedural boundary. SOMEWHERE in the
system SOMETHING has to take data and actually do something with it, such as
writing it to disk, or populating a form. The problem is that this is done
far more often than in just that acceptable situation.

The second would be when dealing with very high-level, CORE abstractions in
a system. This is a much more subjective area, and whether an abstraction is
a core abstraction depends on the system. But again, that basically covers a
handful of abstract types or interfaces, and people tend to overuse getters
for data that is far too trivial.

Basically, in an ideal system you would never call a getter on anything. In
reality, that is impossible, so the goal is to minimize it as much as you
possibly can.


On Sun, Feb 22, 2009 at 12:40 AM, Henry Ho <[email protected]> wrote:

>
> There's one thing I don't quite understand..
>
> How come [obj...@name].getfieldvalue() is considered bad (because it
> is not a behaviour of Object), but getting the value by using a
> singleton (i.e. [obj...@name]service.getfieldvalue([obj...@name]id) )
> is usually considered ok and preferred?
>
> Aren't they essentially, the same thing?  and I believe some argues
> that Singleton is even worse?
>
> Regards,
> Henry Ho
>
>
> On Feb 21, 6:25 pm, Sean Corfield <[email protected]> wrote:
> > On Sat, Feb 21, 2009 at 5:25 PM, Henry Ho <[email protected]> wrote:
> > > Would making the bookmarkManager singleton be.. very weird?
> >
> > Bear in mind the actual data belongs to the *user* not the bookmark
> > manager therefore bookmark manager has no state of its own.
> >
> > bookmarkManager.add(title,link);
> > bookmarkManager.sort();
> >
> > Internally, if would use the OperatingSystem singleton to obtain the
> > user preferences store and interact with that for each operation.
> >
> > Make sense?
> > --
> > Sean A Corfield -- (904) 302-SEAN
> > An Architect's View --http://corfield.org/
> >
> > "If you're not annoying somebody, you're not really alive."
> > -- Margaret Atwood
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to