[Microbit-Python] Accessor API design on the micro:bit

Dave Hylands dhylands at gmail.com
Sun Nov 1 15:45:33 EST 2015


Hi,

My name is Dave Hylands. I'm one of the contributers to the MicroPython
project, and I'm still learning what is and isn't pythonic. I have zero
experience teaching kids, so take anything I say here with a grain of salt.
I'm a professional software developer who works mostly in C and C++ and got
interested in MicroPython for some of my robotics projects.

I joined this mailing list a few days ago, somewhere in the middle of this
thread.

I think that looking at a single object, like the accelerator, you can come
up with an ideal way of interfacing with it.

Then you can look at other objects like a pin and its ideal way of
interfacing might be slightly different (because with a pin you can do more
than just read it, you can set it, you can change attributes about it like
pull-up & pull-down, etc).

When you come up with an ideal interface for each object/peripheral, as a
programmer, I actually find this awkward. It means I'm forced to read the
documentation to figure out how to use it.

As a programmer, I prefer to see consistency across interfaces. So, just
pulling this out as an example, for a pin, I might want pin0.value = True
and read using x = pin0.value. If this were done for other objects, then I
would have expected that the accelerometer would be accessed using
accel.x.value (for consistency). I could imagine that some accelerometers
might have additional attributes beyond just their value.

Anwways - I'll shut up now - just thought I'd add a small interjection.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20151101/1cfcd1ec/attachment.html>


More information about the Microbit mailing list