Re: Exposing contained types.. Especially LISTS



On Dec 27, 11:14 am, "Daniel T." <danie...@xxxxxxxxxxxxx> wrote:
Veloz<michaelve...@xxxxxxxxx> wrote:
Thanks for continuing with this thread, I am learning from our
discussion..:-)

No problem.

That said, what is A good for? If all A does is iterate through the list
it contains, then it adds no value. In order for A to have value, it
must provide something that the simple list can't provide. It must have
an invariant.

I'm not totally sure what you mean by "invariant" here..

There must be some relationship among its parts that it ensures is
always true.

but:

In our case, A is the Test Product class and what it provides, above
and beyond containing list of Feature Groups, is the knowledge of how
to provide a total price, given access to the Feature Groups and some
additional data we have not talked about. So I guess that's what "A is
good for"... Also, it knows how to provide a de-duped list of features
from across the Feature Groups it contains.

That last bit is important! A TestProduct can't let just anybody
add/remove/modify FeatureGroups from its list, because if it does, then
it can't ensure that there are no duplications of Features across
FeatureGroups.

Once you give A some value (expressed as an invariant,) then it is easy
to see that you can't let just anybody add/remove/change items in the
list (i.e., you can't expose the list) because that would make it
impossible for A to ensure its invariant.

Hmm. Interesting. As it currently stands, A doesn't much care who adds/
deletes features from the feature groups, or who adds/deletes feature
groups from the Test Product (A)...

Wait, this is different than what you said above. So, for example (in
Python):

#assume 'features' is a list of Features in a FeatureGroup
featureGroupA.features.append( myFeature )
featureGroupB.features.append( myFeature )
#assume 'featureGroups' is a list of FeatureGroups in a TestProduct
myTestProduct.featureGroups.append( featureGroupA )
myTestProduct.featureGroups.append( featureGroupB )

Does the above cause a problem or not?

at the point of being asked to
calc the cost, it iterates over whatever feature groups are currently
contained in it and asks them for their price as of that point in
time. To this, it adds some other amounts the come from elsewhere.

So from this perspective, A doesn't need to "protect" the list of the
Feature Groups or the content of the Feature Groups. ... Makes me
wonder how strong the association between A and B really is. If A
doesn't care what's in the B (the list of Feautre Groups) then....
then ... then what??

Then A is just a data-bucket. You are working in what Robert Martin
called "the representational paradigm"

Objects present an /abstract behavioral/ interface that hides the
underlying representation... On the other hand, representations
present /concrete static/ interfaces that are devoid of significant
behavior.

-- Martin, Robert. "Designing Object-Oriented C++ Applications Using the
Booch Method", 1995

Interesting.... I guess TestProduct is not "invariant" with respect to
the "list of Feature Groups", then.

Test Product's two main responsibilities (providing a de-dupped list
of features, and producing a "grand total cost") could each be coded
as methods (even static ones) that takes a list of Feature Groups as a
parameter. If someone alters this list a few moments later, these
same methods could be called again to produce an "updated" list of de-
duped features and a new grand total.


The reason I have Test Product holding a reference to the list of
Feature Groups is because of the whole/part thing.. It would seem odd
to just have these lists of Feature Groups floating out there in my
application and then have some code pass them as parameters to
something like
TestProductHelper.GetDeDupedFeatureList(FeatureGroupList) and
TestProductHelper.GetGrandTotal(FeatureGroupList,AdditionalCosts).

I dunno.. maybe it wouldn't be so odd.... Test Product has only
"behavior" from what I just said. It doesn't really have "identity" in
the way we normally think about it.. The identity comes from the
list of Feature Groups (indirectly)

But then again, from the user expects to assign names to test products
sometimes.. So now I would need to somehow associate a name property
with each list of Feature Groups...feels like I'm creeping back to an
object that *has* a list, plus some other attributes.. I feel like
I'm going in circles here LOL

M

.



Relevant Pages

  • Re: ACCESS LIST BOX SCROLL LOCK
    ... Some of us don't like "standard" Windows control UI/Appearance, ... >> change in feature from the current version. ... >> This feature would be useful for applications where larger lists of ... >> compare similar items before proceeding with their final selection. ...
    (microsoft.public.access.forms)
  • Re: From release notes for FC5T3 (web)
    ... things like shift select or whatever functionality that makes it easier to select multiple checkboxes at the same time in the interface would be a good compromise if this is not possible already but I have noted that this particular feature hasnt been requested in bugzilla yet AFAIK. ... I used battle on public lists over MS vs. Linux and battles were similar on outcome. ... The installer would still not handle easier installation or a more complete installation of what is available from the install media. ...
    (Fedora)
  • Re: How do I exclude a word from always capitalized words?
    ... Spelling and Grammar and check your autocorrect lists as well ... My suspicion is that this capitalization feature ... always be capitalized' feature in the Microsoft Help or on their web site. ...
    (microsoft.public.word.docmanagement)
  • Re: General question about Python design goals
    ... Why is it a feature if I cannot count ... Tuples and lists really are intended to serve two fundamentally different ... that other languages also make this distinction (more clearly than Python.) ... of a tuple is as a heterogenous sequence. ...
    (comp.lang.python)
  • Re: Exposing contained types.. Especially LISTS
    ... differ from the pricing for features in a different Feature Group. ... The Test Product, in turn, ... calculates the total price by asking each Feature Group for its ... I'm showing the Feature Groups as kind of a "permanent part" of each ...
    (comp.object)