27 May 2015 by dryobates
This night we've get back from PyWaw Summit. Talks were really inspiring.
One of the first talks was given by Katherine Scott. Within 30 minutes she has shown how simple robotics can be done in Python with the help of ROS  At the same time I have realized how much time would it take to do this from scratch.
Next talk was given by Ignacy Sokołowski on SRP . SOLID (which SRP is first rule) are well known and used rules but it still frightens some developers. I had the same problem as Ignacy when I was introducing SOLID on Coding Dojo in my company. What I've seen on programmers face was fear. I called it "object fear". Many programmers fear to create objects, define classes even though they do this implicit. They feel uncomfortable with class that has only one public method ("That's Java!"). For all those that afraid it, instead of using this:
class A(object): def method_a(self): pass class B(object): def __init__(self, obj_class): self._obj = obj_class def method_b(self): self._obj.method_a() a = A() b = B(a) b.method_b()
def method_a(): pass class B(object): def __init__(self, method_a): self._method_a = method_a def method_b(self): self._method_a() a = method_a b = B(a) b.method_b()
or even this (quite similar to Brandon Rhodes' Hoist Your I/O):
def method_a(): pass def method_b(method_a): method_a() a = method_a method_b(a)
You'll get bare function (which is object in Python anyway) and still have SRP. SRP is not about classes. It's about separation of responsibility. Although I prefer Object Oriented manner as it's easier to extend in future (in my opinion, functional programmers would say opposite ;)) the key point is the same.
And better then thinking how to structure your code to be easy to extend just try Test Driven Development ;) When you'll do a lot of TDD you'll come to SOLID anyway. Knowledge of SOLID can just save you some irritation when you realize that have to rewrite to many tests when requirements will change.
Although idea shown by Ignacy wasn't new to me I really enjoyed his talk. I can only imagine how much work had to be done to put so many code smells in such small example and still problem would be so visible. On Coding Dojo in my company I didn't managed to show it in one example...
Łukasz Langa advertised his talk "asyncio is the reason to switch to Python 3 now". He knew what he was talking about. The very first thing I have done when I get back to office was to set up our product's buildbot to test against Python 3. Asynchronous programming is difficult task. With asyncio  it looks to be much simpler and looks better ("Beautiful is better than ugly"). Especially in Python 3.5 :) (If case you missed that: Python 3.5 Beta is already available )
Hoist Your I/O
When I was listening Brandon Rhodes' talk I was laughing to myself. Exactly one week before I was trying to convince my co-workers that we should separate our code and extract I/O and configuration from logic part. That we shouldn't use mock.patch in TDD and reserve it only for adding tests to existing code. And then I see Brandon that shows the same idea just... better. I wish I had seen this talk before. Although I'm not as skilled speaker as Brandon is (he's talks were hypnotizing) I could learn different approach to selling idea. And of course I could use much better code example (I have used production code at coding dojo - don't repeat my mistake :/ )
Last talk on PyWaw Summit was given by Honza Král who has shown so different use cases for Elasticsearch that convinced us to give it a try again. 
Was that conference worth driving few hours forth and back, burn the midnight oil and get totally wet home? It surely was. I'll come to the next!
|||Python 3.5 https://www.python.org/downloads/release/python-350b1/|