Hi everybody,

On Fri, Sep 30, 2016 at 09:04:32AM +0300, Shai Berger wrote:
> Hi Sven,
> 
> On Thursday 29 September 2016 22:09:27 Sven R. Kunze wrote:
> > 
> > Am Donnerstag, 29. September 2016 20:26:54 UTC+2 schrieb Aymeric Augustin:
> > 
> > > Generally speaking, properties are expected to be cheap and methods can be
> > > expensive. In my opinion, for lack of a better guideline, we should stick
> > > to this one. `is_valid()` falls into the expensive category, and for this
> > > reason it should remain a method.
> > 
> > Oh, I've never heard of this guideline. I just thought that properties
> > should be used to reduce visual noise (such as parentheses and "get_" or
> > "set_" prefixes.) or to replace a static attribute with a dynamic one.
> > Cheap vs. expensive never played a role so far (at least where I worked).
> 
> I'm completely with Aymeric on this one. The parentheses are not just noise, 
> they're a strong hint about the price of computation expected, and also about 
> the expectation of exceptions popping up. Properties hiding complex code are 
> downright misleading in my book, and "is_valid()", which may call user code, 
> certainly qualifies as complex.

I also agree with Aymeric and Shai on this, which is why I want to
bring up the elephant in the room: Form.errors. This is a property
which triggers full validation of the form on first access. What are
the chances of replacing Form.errors with a method?

Or maybe making it raise an error if it's accessed before the form has
been validated by calling an explicit method?

Cheers,

Michal

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/20160930094345.GY6601%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Digital signature

Reply via email to