I was kindly invited by my friend Carlos Eduardo (e-Genial) to give 2 webinars to the brazilian Ruby/Rails community in the next months (in Portuguese). So, add to your calendar:

  • 19/Jul/2008: Merb: web development with Ruby without Rails
  • 13/Sep/2008: BDD with RSpec

Both webinars will be held at 3:00PM (brazilian time) via Treina Tom, a great e-learning/e-conference tool developed by Carlos. More details can be found at the event website. Hope to see you there!

A recent post on InfoQ made me think about how I use mocks during development. I used to be a classicist tester and thought mocks were only useful to fake external services (usually slow or hard to setup). After learning more about interaction-based testing and BDD, I now see some good advantages of using mocks during development:

Outside-In Development

Behaviour-Driven Development is more than a variation of TDD. I like Dan North’s explanation of BDD as an “outside-in” approach to development. We start at the Story level, defining the acceptance criteria as scenarios which create an agreement between the team and the customer on the meaning of DONE. From the outside view, we start digging into the domain model, designing the objects and services needed to implement the story. I find mocks really useful in such scenario, because I can define the interface of the objects that still doesn’t exist, while focusing on the current layer of functionality. As a side effect, my tests become more isolated and when they fail I usually have a good indication of where the problem is located, requiring less debugging.

In this sense, I think the really important scenario for using mocks from Colin Mackay’s article is the last one: “when the real object does not yet exist”. I still mock someone else’s objects in the boundaries of the system, to assert that my code interacts properly with external libraries. But I see much more value in mocking my own objects, designing interactions and isolating behaviour. Which leads to my next point…

CRC with tests

CRC cards was one of the techniques that thought me what good Object-Oriented design looks like. It focus on designing behaviour-rich objects, defining its Responsibilities and Collaborators. In general, while state-based testing is great for defining Responsibilities, mocks give me the ability to precisely describe the Collaborators in my tests. Since I’m all in for using tests as executable documentation, mocks turned out to be a great technique to express my intent. Leading to my last point…

Mocking methods vs. mocking objects

My last point is not exactly an advantage of using mocks, but an example of how a framework can influence how you approach development. Coming from the Java world, I was used to encapsulate behaviour behind well defined interfaces. Now that I spend most of my time developing in Ruby, I not only have the ability of creating a mock/stub object, but also of mocking just one or two methods in a real object. These are usually called Partial Mocks.

Partial mocks allow me to express intent more precisely: instead of having to create a mock from an interface/class and record expectations in a proxy, I can specify the interactions in the real collaborators. It also makes the separation between state-based and interaction-based tests more loose, because I can selectively choose which methods will be mocked and which will be real. Finally, I can use tools such as Synthesis to verify that the interactions I’m mocking in one test are actually being verified in the collaborator’s test.

I know some people don’t feel comfortable using mocks and some even find it complex, but I think there’s great value on using it in the appropriate context. Instead of complaining about different framework’s idiosyncrasies and complexities, I think people should focus on its benefits as a design technique.

April 16th, 2008Running Java 6 on a Mac

Following the recent trends on Planet TW, George and I decided to share our homage to those who, like us, miss (or don’t) running Java 6 on a Mac :-)

 

Running Java 6 on a Mac

 

If you ever got your Mac screen dimming or your Screen Saver running in the middle of a presentation, here’s a quick tip: give you Mac some Caffeine. Before discovering this I used to play around with Energy Settings but always forgot to change it to ‘Custom’ and, let’s face it, switching this functionality on and off in one click is always better than two! Enjoy! :-)

 

It’s been a while since I read the 2nd Edition of “XP Explained” and I really enjoyed the emphasis on separating practices from values and principles. If you try to map the original 12 XP Practices to the new primary and corollary practices, you will notice that it’s not a one-to-one map. And that’s great! Practices are good when you are at the Shu level of learning, but they should be tailored to specific situations, and understanding the underlying principles and values is what will help you do that.

Besides Pair Programming and Test-Driven Development, most of the original XP practices are distilled in more than one practice in the second book. Refactoring and Simple Design are better exposed as Incremental Design, while the Planning Game can be recognized in a list of practices such as: Stories, Weekly Cycle, Quarterly Cycle, and even Slack. Although Coding Standards are not explicitly cited as a practice, you can see its importance when reading about Shared Code and Single Code Base. But you will miss one practice in particular from the first book: the System Metaphor.

The System Metaphor was probably the less adopted practice and usually one of the hardest to explain. If you’re able to express and design your system in a shared metaphor such as “Payroll is like an Assembly Line”, you will see the benefits of this practice shining through: communication with domain experts will be easier and the gap between domain model and implementation will become much shorter. But as it turns out, it is not easy to find a useful metaphor for every system.

If you miss this practice from XP and is looking for the underlying principles behind it, I strongly recommend reading Domain Driven Design, by Eric Evans. Striving to find an Ubiquitous Language to bridge the communication gap between developers and domain experts, and isolating complexity in a rich domain model are goals worth fighting for. In Eric’s words:

 

System Metaphors are not useful on all projects. Large-scale structure in general is not essential. In the 12 practices of Extreme Programming, the role of a System Metaphor could be fulfilled by a Ubiquitous Language. Projects should augment that language with System Metaphors or other large-scale structures when they find one that fits well. 

 

Other patterns for large-scale structure are discussed in the book, as well as a lot of other precious material. So if you still haven’t done it, go read the book!

 

April 7th, 2008Git tip for Brazilians

While working with Git on my current project, my pair and I noticed a source of waste when synchronizing with the master repository: in Portuguese “Puxe” means pull, which sounds exactly like push, but with the opposite meaning. Push in Portuguese is “Empurre”. Because of that, it always take me a few seconds before figuring out which command to execute. Since we are all for eliminating waste, here’s the visual solution in our pairing station… :-)

 

Git push or pull?

 

March 16th, 2008Impressions from QCon 2008

Working for ThoughtWorks is a very rewarding experience. After finishing my first project and delivering a Rails app in 1 month, last Friday I had the opportunity to attend QCon London. Overall it was a really nice day and my feeling at the end of the day was that I should have been there on Wednesday and Thursday :-)

I started the day attending the “Architectures You’ve Always Wondered About” track. The first talk was really good and Randy Shoup talked about the architectural principles behind eBay. I had already read about eBay’s transactionless style for achieving availability and scalability through data partitioning, but it was interesting to hear about the way they approach deployment for new code and features. There are no changes that cannot be undone. They have automated deployment tools that manage the dependencies between different components (a la package management systems such as apt) that allows rollout ant rollbacks (a la Rails’ migrations) of different pieces of code. Interesting stuff!

The second talk on that track was supposed to be about Twitter’s architecture, but for some reason it was cancelled and replaced by an interesting presentation about BBC’s new media publishing system. Nothing really ground breaking in terms of technology, but it was interesting to hear about their current process of migrating a huge physical media storage (with guys in motorbikes taking tapes from site to site) to digital format, and how it changes their editorial process… somehow the image of the guy in a motorbike reminded me of the Pigeon’s high bandwidth transfer protocol :-)

After lunch, I switched to the “Programming Languages of Tomorrow” track. I first listened to Joe Armstrong’s talk about Erlang (and the case for concurrent systems on a multi-core soon-to-arrive future). He is a very entertaining speaker and I think that he successfully delivered his message to the general audience.

Next came Ted Neward with an introduction to Scala for the lazy Java developer. Although I didn’t consider myself the audience for this talk based on the title, I was interested to see and learn a little more about Scala. He covered the basics of the language and I enjoyed watching real code instead of slides, but I was hoping to hear more about Scala’s concurrency features… maybe lazy programmers are still not worried enough about concurrency :-)

The track finished with an Open Space style session, where participants discussed about which factors are driving the increasing interest and resurgence of different languages. For me this was the most interesting discussion of the day and it strengthened the case for polyglot programmers. One of the topics was that it usually takes years for someone to become an expert at something and that it’s harder to leave that knowledge behind to learn something new. I think that it all comes down to whether you want to be a specialist or a generalist and I’ve already stated my position of trying to be both. Another interesting aspect of the discussion was Martin’s point that the evolution happens in cycles and that after a period of stabilization, it’s time (again) for broadening the options and looking for new ideas that will lead us to the next big thing. In these times it’s important to look for new learning opportunities instead of narrowing your knowledge. I think it’s time for me to use the generalist hat for a while… :-)

Finally, the closing panel gave me a good summary of the things I saw and the things I missed. Some of the highlights that I hope will be available at InfoQ soon were Kent Beck’s session and keynote, Martin’s and Jim Webber’s keynote, and Ola’s and Venkat’s sessions on blending dynamic languages and extending the Java platform.

I was really impressed with the quality of the conference, from tracks, to sessions, and speakers. QCon is one of the best technical conferences I’ve participated and I recommend it for anyone interested in enterprise software development. I’m looking forward to attending again next year.

 

For those of you who didn’t know, after going to XP 2007 last year and speaking with Emmanuel Gaillot, I decided to start a Coding Dojo in São Paulo, Brazil. We’ve been running weekly sessions since last July and after I moved to London, Mariana, Hugo, Fabricio, and others are making sure that the Dojo continues. It has been very fun and educational to organize and run the Dojo, so we decided to share our experiences with the community. We are proposing a 30 minutes Experience Report to be presented at Agile 2008. I wanted to submit this proposal earlier to allow more time for feedback and reviews, but the bureaucracy of moving to another country and the excitement of working with very talented people has kept me busy. But the deadline for submitting session proposals to Agile 2008 is tomorrow, and I didn’t want to lose the opportunity of attending and sharing our experiences. We would appreciate any feedback to improve our session. The link to the proposal is here. Thanks!

 

For a while I’ve been planning to write on this subject. The question of whether going broad or going deep into a subject area has always been present in my life. In this post I will scratch some of my current thoughts on the subject. Feedback and other opinions are welcome!

Some Background

My parents always told me that I couldn’t be good at everything. But they’ve always been very supportive on everything I decided to do. Being a great musician, magician, and programmer was not an easy task, but that never stopped me from trying. But then I read something funny that became a good argument for a while…  

The Specialist Paradox

An specialist is someone who knows more and more about less and less, ultimately knowing everything….. about nothing!

That even made me review my resumé to remove any reference to the word “specialist” and include the word “generalist”. :-)  

Swinging the pendulum

But I forgot that you can always change the argument to take the other extreme and come up with a “Generalist Paradox”. And then I watched Kent Beck’s keynote speech last year at XP 2007 about Ease at Work. We are always trying to be the best, but then we realize how bad we are and start thinking we are the worst. A great lesson that I took from his words is that while swinging that pendulum back and forth, we never stop to think that neither of those extremes are good. Being at ease is trying to find how to stay in the middle. In our discussion, the extremes of the pendulum would be the common view that generalists are best at defining the problem or goal and specialists are best at solving the problem or “executing the plan”:

Generalist or Specialist?

While researching about this subject, I learned that you have similar concepts in Biology (highlights are mine):

A generalist species is able to thrive in a wide variety of environmental conditions and can make use of a variety of different resources (for example, a heterotroph with a varied diet). Specialist species can only thrive in a narrow range of environmental conditions and/or have a limited diet. Organisms do not fit neatly into either group, however. Some species are highly specialized, others less so, while some can tolerate many different environments. In other words, there is a continuum from highly specialized to broadly generalist species.

We can leverage that same idea, letting go the “Us vs. Them” argument and starting to think about generalist and specialist as complementary skills. David Armano has already suggested changing the “or” to “and”, but I would dare taking it one step further…  

It’s all about context

Specialty is contextual. Anyone in my family would consider myself a specialist in programming and software development. But they don’t have a clue that Computer Science is a broad area with so many fields. Some interest me more than others, so I could say I’m a generalist at that level. But since my interest in software development and Agile Methods is greater than other fields, one could say I’m a specialist, although I wouldn’t consider myself an expert at anything :-) I can see the XP principle of Self-Similarity applied here. I think that the above picture is just a simplification of reality. There are some dots underneath the surface that you can only connect if you specialize a little bit. And I would say that the same fractal structure would appear as you go deeper and deeper into your endless search for knowledge. Sometimes you will have to go back and look broader for a while, but that’s not wasted effort. That’s why I now see value in being both a generalist and a specialist in different contexts.

From now on, I will be writing in English. I’ve been planning to do this for a while, but the “New Year” is always a good time for a personal retrospective and some planning for the future (although I think shortening the feedback loop to less than one-year would be beneficial). Besides the usual reasons for writing in another language (training, reaching a wider audience), I think that anyone seriously working with software development should be able to at least read English. I might still publish translated versions of some of my posts, but don’t count too much on that.

Speaking of changes, it’s finally time to annouce the good news:

I’m a ThoughtWorker

Some of you may already know, but since I’ve started interviewing back in 2006, more than one year has passed and many things happened. The one big thing that was holding me back was my Master’s, but since I’ve finished it back in June, things started moving. After a lot of paperwork going back and forth between Brazil and the UK, I’ve finally managed to get my Work Permit and entry clearance approved. My passport couldn’t have arrived in a better time than one week before Christmas. It was the gift I’ve been wishing throughout the year.

I want to say I’m very excited to work for ThoughtWorks! For those of you who were close during all this time, I want to say a big THANK YOU. My family and friends have been very supportive. But now is time to pack my stuff and give a step forwards. I’m starting in the second week of February and am looking forward to report the news. Wish me luck!


© 2007 Danilo Sato | iKon Wordpress Theme by Windows Vista Administration | Powered by Wordpress