[Tutor] cases with single if and an else clause
dn
PyTutor at DancesWithMice.info
Tue Oct 5 19:23:08 EDT 2021
On 06/10/2021 11.48, Alan Gauld via Tutor wrote:
> On 05/10/2021 19:39, Dennis Lee Bieber wrote:
>
>> (even in OOP, once one gets down to coding class methods, one should be
>> back to structured programming)
>
> Kind of, except...
>
> Structured programming says to pass the state values in as
> parameters.
>
> In OOP we tend to rely on using instance attributes to hold
> state and its perfectly OK for methods to access that state
> directly. But that nuance aside, the structure of the methods
> follows SP principles.
Yes, adjusting to that gave me shades of an existential crisis too.
If the object has its own (dict of) self, and there's no need to pass-in
(or receive back) any values which are attributes - isn't this a new
form of 'global danger' and how do I test, keep control ...
It's all down to one's "state" of mind. Hah!
However, the important (and v.helpful) point being made was SP's 'one
way in, one way out' (of a "structure") mantra.
--
Regards,
=dn
More information about the Tutor
mailing list