[Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

boB Stepp robertvstepp at gmail.com
Thu Jan 28 23:54:51 EST 2016


On Thu, Jan 28, 2016 at 2:03 PM, Danny Yoo <dyoo at hashcollision.org> wrote:

> Just to emphasize what I think is an essential point: the basic
> approach we're doing is here parameterization: to take something that
> used to be hardcoded, and turn it into a parameter that allows us to
> substitute with something else.

Thank you for the correct term for the idea I have been gradually
trying to understand better and implement.  Work has been slow the
past couple of weeks, so I have been trying to rework the last large
project I wrote within the past year to make it capable of evaluating
a broader range of treatment plans.  Even though I wrote this less
than a year ago, I am now seeing so many ways I can improve the
readability, compactness and efficiency with what I have learned
since.  Even though this was a strictly procedural program, I have
found that many of my functions can be rewritten to handle more than
what I originally intended.  This parameterization you speak of has
allowed me to eliminate several similar functions by generalizing
certain things that behave similarly.  And I am sure that I am missing
other opportunities for doing this!

> ...When we program, we find
> that domain of values expanded to a richer set, and not just to
> inactive values like strings or dictionaries or images, but now we can
> pass entire collections of behavior as a parameter.  That's one of the
> lessons of OOP: values are not just inert data: they can define
> dynamic behavior.

I am only now beginning to speculate on these new possibilities that
this paradigm may enable.  How *mere* bits can be assembled into ever
more complex, but coherent structures that can do so much continues to
astound me.  Old hat for you experts, but exciting new ground for me!

> (Aside: this is somewhat why I think the topic of inheritance and
> inheritance hierarchies are entirely the wrong things to focus on when
> we're teaching OOP.  Those topics are often used as a shortcut
> mechanism to do code sharing, and although that's convenient, my
> opinion is that it misses the forest for the trees.  What I think
> OOP's heart is beating is in the ability to parameterize behavior.)

In response to your aside, do you have a favorite text that teaches
OOP the way you feel it should be taught?  And is there a Python-based
version?


-- 
boB


More information about the Tutor mailing list