View this site in English Ver este site em português

Book Review: The Mythical Man-Month (MM-M)

24 September, 22:05, by zehzinho Tags: ,

During the last month I’ve been reading the quoted-often-but-followed-rarely Mythical Man-Month. What a nice book!

Fred Brooks starts the book talking about the programming art. Why is it fun, after all? He points many reasons and, among them, the joy of always learning. I totally agree with him, and if you don’t like it, please stop working as a programmer.

The book is just great. Despite my own fault of reading it only now, when I’m 26 and after graduating I got shocked by the unpopularity of the book here in Brazil. At my workplace, with 70 programmers I’m almost sure that nobody has read it (including the bosses), insane!

Why is the book special? Man, almost all those things you hear agilists talk about were first written in the MM-M! For example, about documentation:

“As a principal objective, we must attempt to minimize the burden of documentation, the burden neither we nor our predecessors have been able to bear successfully. An approach. The first notion is to use the parts of the program that have to be there anyway…”

It’s impressive how this guy was able to figure out all those problems in the software production field and, still better, propose solutions! It’s impressive how he was able to write a book so clear in 1975, when the field was in its early infancy (I believe it’s still in the infancy).

Obviously, there are one or two chapters which are no longer relevant and some predictions which did not come true, but the book as a whole is invaluable. I’ve read the anniversary edition, and if you have access to it, I would recommend that you first read the last chapter, in which Brooks gives a retrospective of all the “mistakes” made in the first edition.

Finally, out of the almost 300 pages, I’ve got 95 notes and marks on my kindle. An average of 1 note for each 3 pages is quite impressive for a book from 1975, isn’t it? So, if you still wonder if the book is worth your time, have no doubts from now on.

Less, The Path to Better Design by Sandi Metz at GoRuCo 2001

18 September, 22:16, by zehzinho Tags: , , ,

Yesterday I watched @sandimetz talk about OO design. The presentation is simple and rich (hard to achieve, right?) at the same time. I liked her criteria for design judgement. Is it TRUE?

Transparent
Reasonable
Usable
Exemplary

I had also adopted the last criteria when reviewing my own design. Having an exemplary design is exactly what lets you sleep at night, right?

The presentation:

GoRuCo 2011 – Sandi Metz – Less – The Path to Better Design from Gotham Ruby Conference on Vimeo.

The slides are available at heroku:

http://less-goruco.heroku.com

More videos from the Gotham Ruby Conference (#goruco) are also available at vimeo:

http://vimeo.com/goruco

You should take a look.

How to restart a rails or sinatra app on dreamhost

18 September, 22:14, by zehzinho Tags:

Hi guys, if you followed my last post about running sinatra on dreamhost, you may have gotten frustrated when you tried to update your code. Dreamhost just didn’t want to refresh it, right?

Well, in the past it seems that the process was quite exoteric. I’ve read you had to create some tmp/shutdown.txt file or something like that.

Well, looking at the dreamhost wiki about rails deployment, I found out that the process got simpler. All you have to do is:

$ killall -USR1 ruby1.8

If it doesn’t work (perhaps they’ve updated their ruby version), you should take a look at the running processes:

$ ps -e

ok? Enjoy

Deploying (the latest) Sinatra apps on Dreamhost

18 September, 22:13, by zehzinho Tags: ,

Today I decided that would run my Sinatra app on Dreamhost. Until today I had only run the app on localhost, via shotgun. After trying to deploy it on heroku, without success, I remembered I had a shared account at dreamhost and then, why not?

Ok, after some failures (no single tutorial worked) I finally managed to make it run. Assuming you already have a sinatra app working and configured it using bundler, here are the steps that worked for me:

$ mkdir ~/.gems $ mkdir ~/bin $ mkdir ~/lib
$ mkdir ~/src
$ cd ~/src
$ wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.7.tg
$ tar zxvf rubygems-1.8.7.tgz
$ cd rubygems-1.8.7 $ ruby setup.rb --prefix=$HOME

Then, added to my ~/.bash_profile:

export GEM_HOME="$HOME/.gem"
export GEM_PATH="$GEM_HOME"
export RUBYLIB="$HOME/lib:$RUBYLIB"
export PATH="$HOME/bin:$HOME/.gem/bin:$HOME/.gem/ruby/1.8/bin:
$HOME/usr/local/bin:$HOME/usr/bin:$PATH"

and then, back again to bash:

$ source ~/.bash_profile
$ gem install bundler
$ cd path_to_your_app
 Important! Your rack version must be “1.2.1″, so in your Gemfile you should have:
gem "rack", '1.2.1'

Now you can build you gems:

$ bundle install

Finally, your config.ru should also contain the following lines:

Gem.clear_paths
ENV['GEM_HOME'] = '/home/your_user/.gem'
ENV['GEM_PATH'] = '/home/your_user/.gem:/usr/lib/ruby/gems/1.8'
require 'rubygems'
require 'bundler'
Bundler.require
FileUtils.mkdir_p 'log' unless File.exists?('log')
log = File.new("log/sinatra.log", "a")
$stdout.reopen(log)
$stderr.reopen(log) disable :run, :reload
set :environment, :production
set :views, File.dirname(__FILE__) + '/views'
require 'app'
run Sinatra::Application
 And that’s it! I’m running the latest version of Sinatra (which today is 1.2.6) without problems \o/

If you run into problems, the two posts which helped me most were the following two:

Using Bundler for Sinatra Applications On A Shared Host

and

Sinatra on Dreamhost

Kent Beck about onsite costumers

25 August, 02:34, by zehzinho Tags:

Managers will have to decide which is more valuable – having the software working sooner and better or having the output of one or two people. If having the system doesn’t bring more value to the business than having one more person working, perhaps the system shouldn’t be built.

– Kent Beck

Kent Beck about “The Zone”

09 August, 10:28, by zehzinho Tags: ,

“Avoiding mistakes takes discipline, care and a good deal of patience, as Kent alludes to. It may feel like you’re in “the zone” of maximum productivity, and the code is just flowing out of you, but that feeling is usually an illusion. More likely what’s flowing out of you is buggy, unreadable code that will eat up the bulk of your productive time later. Or someone else’s productive time.”

“Can old codgers still code?”, Kent Beck

How Google Tests Software

02 June, 14:01, by zehzinho Tags: ,

Some days ago I found a very interesting series of posts in the google testing blog, from James Whittaker.

The links, plus some excerpts and comments:

In Part I he begins by showing Google’s organizational structure and how testing can fit in there.

In Part II, he describes the main roles for software developers and testers at Google:

“The SWE or Software Engineer is the traditional developer role. (…) SWEs own quality for everything they touch whether they wrote it, fixed it or modified it”

“The SET or Software Engineer in Test is also a developer role except their focus is on testability (…) they are more concerned with increasing quality and test coverage than adding new features or increasing performance.”. James published an entire post only about the life of a SET in part VI, but I also found this about SETs, which is just amazing:

“Who are these rare creatures who keep our code bases healthy and make our development process run so smoothly?”

Concerning the two above roles:

“Much of the actual testing is performed by the SWEs, SETs are there to ensure that features are testable and that the SWEs are actively involved in writing test cases. (…) Clearly SETs primary focus is on the developer.”

“The TE or Test Engineers spend a good deal of their time writing code in the form of automation scripts and code that drives usage scenarios and even mimics a user. (…) TEs are product experts, quality advisers and analyzers of risk.”

About TEs:

“User focused testing is the job of the Google TE (…) When bugs are rare, TEs can turn to their primary task of ensuring that the software runs common user scenarios, is performant and secure, is internationalized and so forth.”. An in-depth explanation of this role is given in Part VII. From there:

“Ultimately, test engineers are paid to protect users and the business from bad design, confusing UX, functional bugs, security and privacy issues and so forth. At Google, TEs are the only people on a team whose full-time job is to look at the product or service holistically for weak points. As such, the life of a Test Engineer is much less prescriptive and formalized than that of an SET. ”

In Part III, James talks about quality:

“While it is true that quality cannot be tested in, it is equally evident that without testing it is impossible to develop anything of quality. How does one decide if what you built is high quality without testing it? (…) Quality is not equal to test; it is achieved by putting development and testing into a blender and mixing them until one is indistinguishable from the other. ”

and more about the process:

Who better to do all that testing than the people doing the actual coding? (…) The reason Google can get by with so few dedicated testers is because developers own quality (…) Having too large a test team is a very strong sign that the code/test mix is out of balance. Adding more testers is not going to solve anything. (… At google…) Manifestations of this blending of development and testing are all over the place from code review notes asking ‘where are your tests?’ to posters in the bathrooms reminding developers about best testing practices, our infamous Testing On The Toilet guides.”

and finally:

“This means that quality is more an act of prevention than it is detection. Quality is a development issue, not a testing issue.”

In Part IV, James talks a little bit about their release process, which follows what he calls the “crawl, walk, run approach”. Very similar to the Lean Startup process:

“One of the key ways Google achieves good results with fewer testers than many companies is that we rarely attempt to ship a large set of features at once. In fact, the exact opposite is often the goal: build the core of a product and release it the moment it is useful to as large a crowd as feasible, then get their feedback and iterate”

In Part V, the kinds of tests are explained:

“Instead of distinguishing between code, integration and system testing, Google uses the language of small, medium and large tests emphasizing scope over form. Small tests cover small amounts of code and so on.”

“For small tests the focus is on typical functional issues such as data corruption, error conditions and off by one errors. The question a small test attempts to answer is does this code do what it is supposed to do?”

‘Medium Tests can be automated or manual and involve two or more features and specifically cover the interaction between those features. The question a medium test attempts to answer is does a set of near neighbor functions interoperate with each other the way they are supposed to?”

“Large Tests cover three or more (usually more) features and represent real user scenarios to the extent possible. (…) The question a large test attempts to answer is does the product operate the way a user would expect?”

about automation:

“the mix between automated and manual testing definitely favors the former for all three sizes of tests. If it can be automated and the problem doesn’t require human cleverness and intuition, then it should be automated. (…) The ongoing effort to automate to within the “last inch of the human mind” is currently the design spec for the next generation of test engineering tools Google is building. ”

but

“it is important to note that Google performs a great deal of manual testing, both scripted and exploratory, but even this testing is done under the watchful eye of automation.”

These are the seven posts James has published so far. There’s also a short Q&A post, in which he talks more about the roles and their career paths.

Yeah I’m Back

03 April, 09:36, by zehzinho

Hi, It’s been quite some time since my last post, right? Five months to be precise.

Well, a lot has changed in my life since then. Now I’m a MSc from the Federal University of Mato Grosso do Sul (UFMS) and have moved from Campo Grande/MS to Florianópolis/SC, aka Floripa:

 

Joaquina Beach

 

 

I'm the one wearing a cap

Well, as you can imagine, many things have happened really fast in my life in the last five months. Now I live alone and have to take care of everything. That’s why I haven’t been posting here. But now, things are quite stable and I’m going to start posting about the things I’m learning, ok?

See ya.

Ps: this short post was encouraged by this post fom zen habits. This guy is awesome.

QCONSP – 2010

18 September, 14:47, by zehzinho Tags:

Hi, last weekend I went to São Paulo to attend the QCON São Paulo Conference (www.qconsp.com), an event of INFOQ. I had lots of expectations about this conference and I can tell you in advance they were all met. Since almost everybody is going to write about the conference in portuguese, I’m writing only the english version of this post.

I’m not going to talk about all talks, but only about the (IMHO) most interesting ones, ok? :)

The first day

The first talk of the event was “Data Architecture at Twitter Scale” by Nick Kallen, from twitter. The presentation was very similiar (if not the same) as this one. As you can notice from the presentation, only a few important topics were discussed and it made glad to see that all of them had simple solutions. Nothing very tricky. It’s sad that only a few privileged people have to face these kind of problems in their daily work. You can see a nice review (in Portuguese) of the talk here.

The second interesting talk was “The State and Future of JavaScript” by Douglas Crockford, the father of JSON and member of the ECMAScript Committee. Mr Crockford presented the history of JS and the some stuff from the new 5th version of the standard and how the standardization process was handled. Many things called my attention, specially the weird facts about floating points. It made me think “gosh, I have to study JS seriously”. I’m really considering buying his book. Mr Crockford has many interesting stuff in his website and many videos spread out on the web. You should really consider spending some time reading or listening to some things he has been saying.

Then, in the afternoon, I attended some talks in the Agile Track. All the presentations were very interesting and I could extract some patterns, “Stick yourself to the Agile Manifesto” was the most recurrent one. It remembered me a quote from Ralph Waldo Emerson:

“As to methods there may be a million then some, but principles are few. The man who grasps principles can successfully select his own methods. The man who tries methods, ignoring principles, is sure to have trouble”.

The second day

The second day really started with the talk “Best Practices for Large-Scale Web Sites — Lessons from eBay” by Randy Shoup. Very interesting to know how big monsters handle 10 bi requests/day.

Then came Mr. Scott Ambler talking about “Scaling Agile: Strategies for Taking an Agile Approach in Complex Situations”. I expected more from this talk, but it had some interesting numbers about the real effects of Agile practices in projects. Mr Ambler has collected data from lots of projects, which is not a common practice in the Agile community. You can find more at his blog.

In the afternoon I decided to attend some ruby (on rails) talks. I didn’t find them very interesting, very probably because I’m not a ruby guy. I was starting to get tired and thinking that that afternoon was lost. But then came the last two talks of the day.

The “first” talk was titled “NoSQL: acertos e erros” (or “NoSQL: hits and mistakes”) by Gleicon Moraes e Alexandre Porcelli. Those two guys were very funny, specially Gleicon, an the content of the presentation was just great. This talk alone made me think the day had been saved.

But then came Mr. Klaus Wuestefeld talking about his proposal for a new Agile methodology: “Learning and Coolness“. I’m not going to write about it, since you can read the important stuff directly from Klaus itself.

Final Considerations

Friends. I'm the first one right to left

QCONSP was not one of those events where you go and see a bunch of talks about specific topics in a class style. The great achievement of many talks were to make me review some concepts and open my mind to new ones. Thank you very much guys. QCONSP surely was a very good time and money investment.

Finally, I’m leaving you with some photos I’ve taken during the event. You can also find photos from many different people here.

[Cake on Steroids] Overcoming the redirect() problem using testAction

15 September, 17:09, by zehzinho Tags: ,

Hi, one problem which is faced by people trying to use the testAction method in their controller’s tests is the occurence of redirects in the actions. There are some solutions on the web for this problem. For example, some people like to call the methods directly from an instance of the controller.

Anyway, for those like me, who find the testAction method useful and  still want to use it, I’m using a simple solution for this problem (perhaps I borrowed something from the web, but I sincerely don’t remember from where). The nice part is that you can check the flash messages defined in the controller, which I think is useful.

The  first step is to define a constant in the WEBROOT/test.php file. I use the following sentence:

define('CAKEPHP_UNIT_TEST_EXECUTION', true);

Then, in my (app_)controller I overwrite the redirect method to check if I’m running tests:

function redirect($url=NULL, $code=NULL) {
    if (defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
      $this->set('TEST_REDIRECTED_URL', $url);
      $flash = $this->Session->read('Message.flash');
      $this->set('TEST_REDIRECTED_FLASH', $flash);
 
      if (isset($flash['message'])) {
        $this->set('TEST_REDIRECTED_MESSAGE', $flash['message']);
      }
    } else {
      parent::redirect($url, $code);
    }
  }

That’s all guys. Now you can go check your flash messages writing tests like this:

 function testMyControllerAction() {      
      $result = $this->testAction('/mycontroller/action',
        array(
           'return' => 'vars'
        )
      );
 
      $this->assertTrue($result['TEST_REDIRECTED_MESSAGE'] ,"The flash message I'm expecting");
    }

Nice? What do you think? I don’t know. Any flaws? I’m waiting for your comments :P