I didn't watch this thread before, but now I'm sorry I didn't.
 

> > If
> > designs.orthogonal_array doesn't return some kind of array then it is 
> poorly
> > named. Use three different functions, e.g. orthogonal_array() /
> > is_constructible() / size_of_array()
> >
> > This basic design pattern also fixes your caching problem.
>
> Yes, but it duplicates the code horribly. Because orthogonal_array is a 
> long sequence of tests and answers,and you do not want to find this long 
> collection of tests and answers copied and pasted into three different 
> functions, nor to find out that "for some reason" they are not always 
> consistent with each other.
>
>
See below - that is precisely when that code should be abstracted out.
 

> More precisely :
>
> > designs.orthogonal_array doesn't return some kind of array then it is 
> poorly named
>
> No. Because if you want to build orthogonal arrays, you *will* find a 
> function named orthogonal_array. You may not find a function named 
> size_of_maximal_orthogonal_array.
>
>
This is something fixable.  We deal with this in plotting and symbolics all 
the time.  Naming things twice (esp. since orthogonal_array isn't in the 
global namespace, just designs.[tab]) seems very reasonable to me.

designs.orthogonal_array_maximum_size
designs.orthogonal_array_existence

and then take all the code that could be repeated and put it in a 'private' 
(underscore) function.  Again, this is something that happens a lot in 
various other parts of Sage.  

(Also, in this particular case there are very few commands to even find by 
tab-completion, so people in such a specialized research area will likely 
find them.  But of course this won't always obtain as an argument.)

By the way, I love how nobody has a problem with
>
> sage: designs.OrthogonalArray(4,3).exists()
> True
> sage: designs.OrthogonalArray(4,3).matrix()
> BigMatrix
>
>
because these are different methods, so it makes sense.
 

> while on the other hand
>
> sage: designs.orthogonal_array(4,3,existence=True)
> True
> sage: designs.orthogonal_array(4,3)
> BigMatrix
>
>
Usually, in Sage, we have kept to a convention that such keywords do things 
like try other algorithms or verify truth (as indeed in orthogonal_array in 
Sage 6.2, where I though I saw a check keyword of some kind).  Naturally, 
Python can do this, but it is helpful to keep things 

 

> is "clearly bad design". Come on guys, we write Python code ! The point is 
> not only to make our code dead slow, it is ALSO to use the advantages of 
> the language. Stop writing Java and C wrapped in Python ! Do you complain 
> when "wc -l" returns an integer and "wc" returns three integers and a 
> filename ? Do you prefer wc.complete_info() and 
> wc.just_the_number_of_lines() ?
>
>
Shell isn't Python.  In fact, you are losing the point of 
object-orientedness.  Again, I'm sure Sage also does this in some places, 
but over time it would be good to minimize those places.
++++++
Anyway, since all this new stuff is still in beta, is there a possibility 
of refactoring this and making a few methods?  (And ones that also don't 
use "who_asked", a purely internal thing - that should be some internal 
attribute, not a keyword.)  

I really really really really (!) understand that it would be a very 
annoying piece of work to do so.  And I know it is, if not orthogonal, at 
least tangential to the question of cache functions.  But it would be so so 
so good for Sage in the long term.  I know I am no expert software engineer 
and make lots of dumb design choices, and of course much of the combinat 
code is largely not going to be used by me or my students or people I teach 
Sage... but on the other hand if we have the chance to tighten things up, 
it seems reasonable to take the opportunity.

- kcrisman

>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to