Are the critiques in "All the things I hate about Python" valid?

Rick Johnson rantingrickjohnson at gmail.com
Tue Feb 20 17:01:50 EST 2018


On Tuesday, February 20, 2018 at 2:51:56 PM UTC-6, Chris Angelico wrote:
[...]
> Nope. Even if you need the age many times per second, it's still
> better to store the date of birth, because you eliminate boundary
> conditions and duplicated data.

You failed to provide any examples proving this assertion of
yours. I can't imagine how either would be a problem.

> But that's assuming you're storing the age of *a person*.
> If the age in question is a boundary ("motor insurance
> premiums are increased if the driver is 65 years or
> older"), then it's still sane to store the age.

The boundary problem you outline here is a simple matter of
checking the age annually and increasing the premium if the
person is 65 years or older, and has nothing to do with
whether or not the age is calculated once a year or upon
every request.

    def annual_probe(self, geriatricMarker=65):
        self.age += 1
        if self.age >= geriatricMarker:
            self.increase_premium()

But obviously this "data" should reside in a database, not be
instanced into OO objects.




More information about the Python-list mailing list