[XML-SIG] I am confused...

Roman Suzi rnd@onego.ru
Mon, 29 Jan 2001 22:10:09 +0300 (MSK)

On Mon, 29 Jan 2001, Martin v. Loewis wrote:

>> The above code is what I avoid to do.  I want my application to be
>> completely data-driven, so even "/article/author/name" must not appear in
>> the program!
>I'll look into your code separately, but I'd like to make two points
>a) There is often a trade-off between data-driven and fast
>   algorithms. Somebody will probably shoot me for that statement, but
>   you should be willing to accept some performance degrading if you
>   need it very general.

In C - yes, but in Python - I doubt.
Data-driven programs are shorter, contain less errors
and (IMHO) are faster.

>b) In Python, it is often possible to transform a data-driven approach
>   in one with explicitly coded decisions, due to the dynamic nature
>   of the language. If all else fails, you could generate the a program
>   from the data.

This is true. But This add more complexity.

>c) I very much doubt that your *application* really needs to be
>   completely data-driven; in any specific installation, there will be
>   only a small set of queries. So that seems rather like a "nice to
>   have" but a "must have" requirement.

I agree. I have this working now - but am not satisfied, because
do like to make changes in one place instead of hunting
them thruout many places.

My points are (they are drived by laziness ;-)

a) Software solution must be as general, as possible
(I think its a myth that less general solutions are harder,
longer to implement or are much less efficient:
2+2 is not easier than x+y, why hardcode x+x ?;-)

b) One parameter change requires one change in the code
("write everything once")
(if some nontrivial constant repeats in the code in the same role - its
a variable ;-)

c) Count total time of solution: time of programming
+ time of execution. (Not forgetting time of reprogramming!)
(In my case I better wait 3 more seconds than make
hell from supporting my solution)

Now I am turning toward XML & co. because it happen to
be a common data model to store such data I have for
web-site. Anything else is reinventing the wheel.
However, I want to apply the same design principles
(expressed above) while dealing with XML.

>Well, that's three points :-)

I think this branch of discussion is kinda offtopic.

Probably one day I will write a test for programmers
where there will be questions like:

#. What do you prefer more:

if a == "1":
   b = "5"
elif a == "4":
   b = "20"
# ...
   b = "5000"

b = {"1":"5", "4":"20", ..., "1000":"5000"}[a]

b = str(int(a)*5)

  b = str(int(a)*5)
  b = "5000"


For now my answer is (d) but there are cases where (c or d)
are not possible - then it will be (b).


Sincerely yours, Roman Suzi
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd@onego.ru _/
_/ Monday, January 29, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "The tuna doesn't taste the same without the dolphin." _/