Another good project worth sharing, this is an initiative to provide open source tools for civic purposes, for example there is a tool to help track politicians biography:
Open Life
There is much going on my personal life right now that I am having barely any time to do any of the things I usually like to do. Regardless, this I happened to watch and I thought was something deserved a quick post to share.
I always like when people port back things from coding world to real life, the open source inspired movements and Ideas always make me happy an renew my hope in human kind (purposeful split of the word).
Please watch:
Videos related to learning
Every time I talk with people about learning, education and home schooling I end up pointing a set of links to them, so I decided to make them available here for future references.
The first one is Dan Pink’s video about motivation, it is about work, but the concept apply to children and learning, the other way around is true too, most of the videos can be related to work, agile, pair programming, etc…
The next one is a charismatic talk about how US education is failing:
Then there are Sir Ken Robinsons’ videos, of course, they are mandatory critics to the current education model:
Mister Sugata Mitra has made one of the greatest findings with his hole in the wall experiment about children learning and pair programming:
This is about self-learning, testing and computers:
This are very inspiring videos about courage, change and innovation, about the role of being able to take risks to be happy and go forward:
Another one about motivation on learning and thinking outside of the box:
This is about changing education to reflect how we really do science:
This is about how the children’s mind work like the scientific method:
About the hole of playing and being happy to foster productivity:
And this one is about children’s language learning:
Next a video that advocates that there is no Eureka moment, that knowledge and inventions are collaborative slow going process:
This is about exploring new stuff:
And finally an inspiring video from an educator that cares about children learning:
That is it.
Book review – Clean Code
Intro
Some time ago I read Clean Code, a very good book by Uncle Bob on how to write clean code, or should I say: how to polish written code until it becomes cleaner.
My first read through is something he calls at the beginning of the book a “feel good read” as I didn’t work hard and sweat, so I haven’t yet the full benefit of the book.
But I think with this first read I’ve gotten the general Idea and I have some quibbles about some parts of the book. I feel I should address them.
This is usual for me when I read his writings, some things I agree, a few I disagree and a couple I strongly disagree and once I very strongly disagree and then a I strongly agreed.
The one In this book I strongly disagree and made me start to write this post is about the exceptions, and then I let this post sitting for some time.
But I came across some people following the advice and I felt I should come back and publish this.
As he said in the beginning of Chapter 16, this is not in malice and I do not think myself better than him, my code is as flawed as the next guy as you can see from my contributions to the [Layout Parser] (http://sourceforge.net/projects/layoutparser/).
I have extracted from the book a lot of good advice which I shall incorporate in my own coding practices, there are some that are contrary to my believes and made me, at least, question the truth in them.
Yet there is always benefit in reviews and feedbacks.
Do not mislead
It is very well stated in the book that one should not mislead his reader and the code should do the least surprising thing and that functions should do one thing.
I happen to agree with that and I find the function renderPageWithSetupAndTeardowns
in Chapter 3 given as example and refactored until clean to be still offending those principles.
If I were reading a code that makes a call to that function I would just assume that it decorates the page with setup and teardowns, on a debugging session searching for why the page is not being rendered with them it would be the last place I would look for the test if(isTestPage)
, I would expect this decision would already be made in order to call a function called renderPageWithSetupAndTeardowns.
So it surprises me by doing two things which is rendering the page and deciding if the render will be with or without setups and teardowns.
Javadocs
There are some criticism about javadocs should be written:
- Should not express what function and parameter’s names already convey.
- Should not contain mark-up.
But javadoc is not code and the audience for javadocs is not programmers maintaining the code, javadocs are for the API clients and thus it should not rely on the code.
With modern editors you can simply collapse the javadoc comments, if they are too bulky for your taste, and just ignore them.
So the content of javadoc should be as complete and useful as it could be without being constrained by rules intended by code readability. They are two different concerns.
Checked exceptions
Here is where I think the book is deadly wrong and it is even doing a disservice to the craft, he even declares the debate over, personally I think no one is ever capable of declaring a debate over.
Anyone that is regular to any forum can attest to that…
Let’s look at his arguments:
The price of checked exceptions is an Open/ Closed Principle violation. If you throw a checked exception from a method in your code and he catch is three levels above, you must declare that exception in the signature of each method between you and the catch. This means that a change at a low level of the software can force signature changes on many higher levels.
Note that if a given function throws an exception, and this exception will be meaningfully handled three levels above the open/closed principle is already compromised.
Regardless the fact it is declared or not, there is a distant class dealing with it. If it come to pass that the exception is changed the handler class will have to be changed too.
On top of that if an exception was allowed to merrily float up, that means it went up likely three abstraction layers and we have a high abstraction layer dealing with low abstraction guts.
Which brings us to the next argument against indiscriminate use of unchecked exceptions: they favour leakage of abstraction.
Through checked exceptions, java forces you deal with the possible problems that may arrive, letting the abstraction bubble to burst must be an active decision.
On the other hand, with unchecked exceptions you may not even be aware the abstraction is leaking until it happens and that may mean production time.
Which brings us to yet another argument against unchecked exceptions: they violate the principle of least surprise.
What a piece of code does is not merely a question of what the happy path does, the way the code fail is equally relevant. When I come across a signature which says:
File open(String path) throws FileNotFoundException;
It is telling straight away everything that can happen. I can mock the object and make the mock throw the exception and then I can write code to deal with it, and if I decide to let the exception go up I can wrap it up in a meaningful exception according to my abstraction, say: UnableToLocateCustomerException
.
On the other hand if it is all unchecked and the client of my code has the interface:
Location locateCustomer(Customer customer);
He will have quite a surprise to see a FileNotFoundException
to blow his nose, it is completely unexpected, as the Spanish inquisition, he does not care and should not care if my code uses files, data bases or smoke signal to store its data.
Declaring the throws clause in every method in the away the exception travels is not the dirty part of the code.
Letting it go up the abstraction and handle it where the exception is less meaningful and there is less chance of doing something useful with it, this is the dirt.
Making them unchecked merely hides the dirt under the rug and makes it harder to test and allow the dirt to grow mould until you find about because you are sick.
Scrambled Eggs
Back when we lived in Brazil, we did not use the television other than as an output device for the video-games and the DVD/blue-ray players. I got rid of tv channels around 12 years ago, for there is not much television add to our lives and there is so much that it takes from us.
It is far too easy to spend many hours, not having fun, not learning, not resting, just burning through time with absolutely no benefit, being spoon-fed with needs we don’t really have and having our brain slowly turned off.
Cable channels are even worse than open channels for they charge you for the disservice.
Now that we moved in to Montreal, we have the need to learn french, and so we figured that it would be good to have the television to rise the language immersion. So we now watch tv, mostly Baby TV, as we thought it would maximize learning for our son and for ourselves.
I would give it, there are some good sketches with some educational value, but I am starting to figure it is targeted more as baby’s time sink than as proper educational.
In particular, there is a sketch that, in my opinion, actively does harm for it helps even that early in the baby’s life to inculcate this wicked culture of the only one right answer and fear of being wrong.
The sketch is named Eggbirds and it is about a flock of painted eggs with feet and beaks, they walk in formation following a boss, differentiated by having hair, as he is the boss, he is “special”, he goes a little further in the front but sometimes he stops and let the flock pass by as he inspect the others.
There is a bland one that is the “intern”, he is an unpainted smaller egg lagging behind the group, walking alone. At some point they find hanged cloths and the boss decide it is time to play, he announces which will be the play from a podium, and he order someone to be the puppet in the play, which of course is thrust upon the intern egg by the others.
The intern then hides behind the clothes and reveal himself slightly painted or with some part of a costume, at which point the others try to guess what is his intended costume, they guess something that always is perfectly plausible and acceptable given the bits shown, the boss looks and patronizingly refuses the answer.
Then the intern hides again and add a little bit more to the custom, show himself again, someone gives another good answer, and this time the boss straight laugh at his/hers face humiliating him/her for not having it “right”.
For the last time the intern hides, and somebody hazard a guess just after he comes back and he is identical to the guess, the boss audits the answer to see that it is EXACTLY the same and then approves it.
All along the sketch reinforces the bad stereotypes that the group must follow and be controlled by the boss, unable to decide on theirs own what to do, with him having the only right answer to the problems, micromanaging people and auditing every single act and trampling those that do not conform to the expected norms and solutions, destroying the very source of creativity and rewarding sameness.
It is even factually wrong for birds flying in formation do that through an emergent pattern with no single bird controlling it and the head of the flock changes over time, as the front birds get tired they fall back and others become the front.
Much more likely to a team where each member is independent and has skills to add to the group and does when the skill is required by the situation than the command and control view imposed.

Slowdown
This September 10th there is a movement that is going to slowdown the internet for one day, as a conscience awakening, so that it does not slowdown for good.
What is it about? Cable operators are trying to be allowed to provide different connection quality based on the source of what you are visiting, if the owner of the site or service has contract with them, they will service it at better speed, if it does not it gets crappy transmission.
If you want to know more and even help, here you can get more pointers.
Just to point the pragmatic absurdity of this, if someone puts up a new service to run, in order to not get crippled it would have to sign contract with every internet provider in order for its users not be slowed down on theirs access.
So a website in Turkey would have to contact the American providers and pay each of them in order that the American visitors do not get crappy speed for accessing them, users that are already paying theirs operators for such speed.
Maps and Abstraction
The entire history of software engineering is that of the rise in levels of abstraction.
— Grady Booch, The Limits of Software
That I was always a supporter of the idea that in object-oriented languages there is almost no place for switches
is no surprise to those that know me.
A switch statement almost always can be replaced by a map of values, a map of commands or a state pattern making a cleaner code and more versatile, it is the object-oriented way of doing it.
I was even challenged on a class that I taught Java to software developers changing in to Java on this one, people said that there is occasions that it simply cannot be done, but none could come up with an example which I could not turn either into one of those three.
Some people will complain about those not being as optimal as switch, but then again Donald Knuth warned:
“Premature optimization is the root of all evil.”
First and foremost software developers should be concerned, when writing code with two things:
- Is it correct?
- Is it easily read and understand?
We write software for computers to run, but also for other human beings to read, for the human beings are the ones that maintain and add to the code, a computer language is not restricted to be a set of instructions to the computer, it is also the language that convey the meaning of the software to people who read it.
Code easy to understand is easier to optimize while a mess of optimization end up rewritten, or worse cut out. If the ones maintaining it can’t understand the code and it’s purpose.
That is not to say I never write switches, everyone has a lazy moment, yet it makes me feel that I have live butterflies in the stomach and usually I end up reworking the code to get rid of the pesky switches.
Lately I started to get the same from maps, every time I see a map I got that feeling that there is an abstraction that failed to be seem. After all, a map in its own nature denotes relationship among the entities mapped.
And the relationship asks for an entity to be born. A good example of that I extracted from a Java discussion list in LinkedIn, the guy asked a way to order a map by its values instead of keys and as some know usually what people ask is not what they need.
His problems were that he needed to sort cars by distance and he had a map from cars to distances that kept being updated. Here the source of his problem was that entity asking to be born, it was the key to solve the problem, once I modelled it for him as a Radar Blip and created a blip comparator that sorted the entries of a simple collection of blips by distance his problem was solved. (source code)
Gardening
Today I worked a bit on the garden, that is not something I used to do much, but now we finished the move to Montreal and we’ve got a place with one so that our son can enjoy a bit of the Great Outdoors(TM), indoors.
And I was wondering how much gardening really resembles programming, the book by Steve Freeman and Nat Pryce: Growing Object-Oriented Software, Guided by Tests is spot on with it’s name.
At the beginning, nobody knows what they really want out of the garden, people kind of agree that they need a bunch of green stuff in it. So some beds are raised and seeds are sown, patches of grass are placed and some plants are pasted from other gardens.
But programming as gardening is not about just growing stuff. If you do, you end up with lots of weeds(hacks), dead branches and leafs and a bush of thorns that requires a good stretch of imagination to be called roses.
Unfortunately that is the state in which most software produced and my garden can be found, to have a garden you must do lots of trimming and cleaning(re-factoring) you have take out the dead branches and the sick plants you have to remove the hacks and cover the soil so that do not grow back.
At each trimming iteration the garden becomes less ugly until it may start becoming beautiful. If you stop trimming or take too long to trim it again it becomes a tangle again.
A good program is just like that, the best are very like bonsai, small, well trimmed and it’s growth directed according to its natural inclinations.

Life Long Learning for all of us
I have moments in my life when I can literally feel my thinking expanding – I can almost hear my old thoughts being torn up and discarded and replaced by new thoughts or a new way of seeing. I experienced this having lunch with Connor today.
We have just started an absolutely brilliant course, on Coursera, by a Professor from Tel-Aviv University on ‘The Emergence of the Modern Middle East‘. We were watching this while we ate lunch this afternoon.
I have previously considered myself moderately well-informed on the history of the area, the way in which Western powers just divided the lands up into countries with no thought to the people living there, the completely artificial imposition and creation of the State of Israel supported by the U.S. to block the perceived threat to their interests in the Middle East from the Soviet Union etc.
I now realize…
View original post 790 more words
Feedback Loop
So I was reading this blog by Bob Marshall and at first I got angry, and then I realized I have being doing too much of angry, as I read I realized that not only he was not wrong, but also he was dead on right.
He did express exactly what I want.
I do not want the word back, I want what it meant to be, regardless of the name given. Going about making noise does not solve anything, if there is not a direction and a metaphor to work by.
So, really taking “agile” back must be done in “agile” way, lets do agile in anger(1) instead of doing it with anger, who says this is limited only to writing software?
Starting by feedback, what went right? What went wrong? How can we improve it?
And the first thing I think went wrong are the names, extreme programming scared people, most never went on to understand or learn anything related.
Agile is misleading and an attractive word for corporate drones in love with titles. It is too easily interpreted as fast, it also has an inherent aggressiveness, in the sense of hormone pumped up sport player “going for the kill” in a game, that appeal for those kinds of alpha male management types that love so much to be in control of everything.
My suggestion is to use Organic Development, organisms adapt and react to changes of context, organisms fail fast, organisms learn and improve through feed back loop, evolving and doing better for the context over the time.
I think Organic Development offer quite an extense source of metaphors to be used and to explain what we call agile.
(1) I just learned this expression, found it cool.