[Prev][Next][Index][Thread]

Re: Dylan and OIL(SCP)




Jason Trenouth <jason@harlequin.co.uk> wrote in message
XuFPOKbOffYI4xkbas82Te9Io9QX@4ax.com">news:XuFPOKbOffYI4xkbas82Te9Io9QX@4ax.com...
> On Tue, 30 Nov 1999 14:45:03 -0500 (EST), ingjyehwang@my-deja.com wrote:
>

<snip>


> > For example, in SCP
> > (Expression A)
> > supply_chains.find("My supply chain").plans.find("Actual
> > plan").horizon.start
> > is equivalent to
> > (Expression B)
> > start(
> >    horizon(
> >       find(
> >          plans(
> >             find(supply_chains,
> >                  "My supply chain")
> >          ), "Actual plan")
> >       )
> >     )
>
> This is a slight unfair comparison since the A was written on one line and
B was
> written across several lines:
>
> supply_chains.find("My supply chain").plans.find("Actual
plan").horizon.start
>
> start(horizon(find(plans(find(supply_chains,"My supply chain")),"Actual
plan")))
>
> However, there is an argument for looking at extending the dot function
call
> syntax. Currently the dot syntax is a bit of a wart and doesn't allow for
> multi-arg calls. However a more symmetric and perhaps more Dylany version
of
> multi-arg dot calls might be:
>
> ((supply_chains,"My supply chain").find.plans,"Actual
plan").find.horizon.start
>
> However, it is not often you see such big chains since you regularly need
to
> check the intermediate values for validity.

>From what I've read about best practices in program design I would say that
such a long chain of functions is a bad thing. It basically states that the
function in which the call is located knows way too much about the structure
of items between here and the information it wants. This effectively
increases the coupling between components and makes changes to the
implementation difficult.

I realise for small, script-like bits of code you would generally say "who
cares?" but I wanted an excuse to post to the dylan group :-)

Ultimately my point is that for any reasonably complex bit of code this
should not be an issue. However, before I get any flames I would like to
point out that my opinion here is controversial and I admit that I don't
always follow the principal mentioned here.

Read http://www.c2.com/cgi/wiki?LawOfDemeter for information.

Cheers,
Peter Sumskas.








References: