One design pattern that I see in many places in sympy is that other
objects are not very encasulated. Let me give an example:
Take printers. My initial expectation is that each object itself
would be responsible for knowing how to print itself in various
formats. I would handle this using an informal protocol like this:
class Foo(Basic):
def _print_str_(self):
return self.__str__()
def _print_latex_(self):
# return the latex rep
But, in sympy, the printer class has all of these methods for all the
classes that need to be printed. Why is it done this way?
The difficulty is that if I implement a new subclass of basic, I also
have to add methods to the various printer classes. This seems a bit
silly as 1) it really breaks encasulation 2) it spreads the code for
an object all over the code base
This is related to the work I am doing with sympy in the following
way. I have a dagger class (Hermitian conjugate). It would be nice
if all sympy classes could simply declare a _dagger_ method that
returns the actual dagger of self. But, this design seems to go
against the design patterns in sympy.
So, why doesn't sympy use more informal protocols to enforce
encasulation rather than spreading the logic for an object all over
the place?
Cheers,
Brian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy" 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/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---