Pomodoro Technique

A decade ago Joel Spolsky wrote an article titled Where do these people get their (unoriginal) ideas. What he has written is common sense and most of us who worked for a few years in a corporate environment would agree with (I’m talking based on my IT background). Although the context of his article is different, the underlying theme is higher productivity, precisely the theme of this post. Joel says –

Here’s the trouble. We all know that knowledge workers work best by getting into “flow”, also known as being “in the zone”, where they are fully concentrated on their work and fully tuned out of their environment. They lose track of time and produce great stuff through absolute concentration. This is when they get all of their productive work done. Writers, programmers, scientists, and even basketball players will tell you about being in the zone.

He continues …

The other trouble is that it’s so easy to get knocked out of the zone. Noise, phone calls, going out for lunch, having to drive 5 minutes to Starbucks for coffee, and interruptions by coworkers — ESPECIALLY interruptions by coworkers — all knock you out of the zone. …

As Joel rightly points out in the article getting into that “zone” is not that easy. And once you are in, there are quite a few distractions in a typical corporate environment. Great, if you are lucky and gifted to be get into the zone without much effort. If you are like rest of us, you would be all ears for techniques that improve your productivity.

So an year or so ago, I stumbled on this technique called Pomodoro. At the outset it’s a simple tracking and feedback process where the unit of work is the pomodoro, a time slot of 25 minutes. The basic principle is to keep you focused enough for specific period of time (in this case: 25 minutes). Here is a free e-book [PDF] if you are interested to know more.

This technique helped me quite well in accomplishing some of the tasks I have either been not focusing enough or procrastinating for various reasons.

This InfoQ article posed some interesting questions with some counter-arguments from Mario Fusco. Mario compares IT professionals with the professionals from other fields and says –

So, why should our work be so different from the former ones? Why do we always think that our work is so special and unique to need a wide set of specific methodologies? Are we professionals or unexperienced kids playing with something bigger then them? I think that, like any other serious professional, I can stay concentrated on what I am doing for hours. I honestly don’t need a pomodoro to keep myself focused for just 25 minutes. And if somebody can stay focused for no more than 25 minutes I am afraid that he should really rethink the way he works.

To respond to that, I’m not so sure whether there is an apples-to-apples comparison between the professions and type of work performed. The basic goal is to be productive. Regardless which profession you are in, you find your own tools and techniques to accomplish that goal. I would treat this technique or something else as a chance to improve. Certainly with corporate emails, phone calls, and other interruptions it’s certainly not easy to concentrate for a good chunk of time and being productive (I’m not even mentioning about Blogs/RSS readers, Twitter, etc.). As I already mentioned, if you think you are already productive and can concentrate quite well (without any new techniques), great, pat on your back.

On the drawbacks-front he says –

Said that, in my opinion there are also other important drawbacks in the pomodoro technique. What should I reply to my customer who is calling me, possibly from the other side of the ocean? That I am in the middle of my pomodoro and I can’t break it? …

I don’t think the technique is that restrictive. Obviously if that call is important you would take it and discard that Pomodoro, attend the urgent task, and get back to Pomodoro when you are ready. Let’s not complicate it more than what it is, this is just a way to being more productive cutting down on the distractions. I don’t see this as a hindrance to the team work or on your efficiency to deal with more urgent matters.

Have you used Pomodoro technique, how do you like it?

Share and Enjoy:
  • del.icio.us
  • DZone
  • Digg
  • StumbleUpon
  • Technorati
  • Reddit
  • Facebook
  • Twitter
  • Google Bookmarks
  • FriendFeed
  • Tumblr
  • HackerNews

Tags: ,

2009 Roundup: Blog, Books and Twitter

It’s that time of the year to review the progress, and to set the goals for the future. Firstly, I would like to thank all who have (directly or indirectly) helped me learn so much during the past year. It was a fun ride in many ways. In this post I would like to review about three items — this blog, books that I read, and about my Twitter experience.

Blog

I have this blog up for a couple of years but it’s in 2009 I’ve started taking it more seriously. My goal with the blog is straight and simple — share what I learn, and in turn benefit from the collective wisdom of my readers, friends and fellow bloggers. Towards that effect, 2009 is a satisfactory year.

Here are the top posts of the year –

Books

Regardless of the vast number of resources that are available online, a book is still my preferred choice. A good book helps in learning something new (or reinforce the concepts) in a systematic and a structured manner. A well-written book may not answer all the questions but helps in generating enough enthusiasm for further exploration.

Here is the list of books that I read in 2009. I could have done bit better on this front, but given all the constraints in place this may not be so bad –

  • Groovy in Action: Groovy has become one of my favorite scripting languages. [My review]
  • Career 2.0: As the name indicates, a career-oriented book from Pragmatic Bookshelf. [My review]
  • Grails in Action: An excellent book on Grails. [My review]
  • Hello World: A cool book for Python beginners. [My review]
  • The Passionate Programmer: The title says it all, a great read. [My review]
  • RESTful Web Services Cookbook: Not released yet, scheduled for the first quarter of 2010. I had great fun reading and reviewing this book. Watch out for it, has got delicious recipes for all REST enthusiasts. [O'reilly link and Safari online]

There are a few more books that I haven’t finished reading yet. I will be writing about them soon.

Twitter

I’ve resisted so long to sign-up on Twitter. Primary reason for that resistance was I was not sure how that 140-character thing would be transformed into something meaningful. That resistance broke down just over an year ago. 1700 tweets later, I’m here to report how much I learnt via Twitter for the last one year or so.

I use my Twitter account primarily to tweet about software, architecture, programming languages and the stuff related. Feel free to follow me there, if you are into it.

There are quite a few geeks out there, Twitter gives a great chance to peek into their thought process. It’s also a great place to share the links and articles you are reading. I’m also glad that I gained some great friends and met some of my ex-colleagues with whom I lost touch a little while ago.

It is extremely easy to waste the time and not find any use of Twitter based on how you use it. For me, all that matters is to follow the folks who are willing to share their knowledge, and strictly stick to the passion — technical topics. You don’t see any tweets about what I ate for my lunch, etc. Not that anything wrong with it, I just don’t find much value in providing that kind of information.

Conclusion

2009 is an year that I’m reasonably satisfied with some of the milestones that I’ve set out for myself. However, I know there are many more miles to go …

Share and Enjoy:
  • del.icio.us
  • DZone
  • Digg
  • StumbleUpon
  • Technorati
  • Reddit
  • Facebook
  • Twitter
  • Google Bookmarks
  • FriendFeed
  • Tumblr
  • HackerNews

Tags: ,

WebDriver (Selenium 2.0): First Impressions

I’ve been using Selenium and Watij for a while now (more Watij than Selenium). I’ve written about my prior experiences here and here. Watij — there is no significant development happening there for the last year or two. While Selenium Remote Control was nice, its IE support (especially IE 7) was not that great when I last evaluated (it may have improved since then).

I guess on Twitter, I first heard about WebDriver, and accolades about its approach and its API design. So decided to give it a try. Best part is Selenium and WebDriver projects are joining forces with a merger in Selenium 2.0. Per my understanding, the plan is to provide both Selenium and WebDriver APIs under Selenium 2.0 umbrella. At the time of writing this post Selenium 2.0a1 (Alpha-release) was out.

So here are my first impressions:

  • Approach: At the outset WebDriver is similar to Selenium (Remote Control) and Watij — developer-focused and API-driven. But the best part, for me at least, WebDriver doesn’t take the approach of running as a Javascript application within the browser (like Selenium), rather it takes JNA approach interacting with the browser. That approach rules out same origin issue (a headache with Javascript approach).  Also this doesn’t require native libraries installed and registered on the client (e.g: DLLs need to installed on the client for Watij).
  • API: API is intuitive. For example, following code snippet finds the element (text box, in this case) by name and simulate the typing by the sendKeys() method.
    driver.findElement(By.name("full_name")).sendKeys("Joe Schmo");
    

    Similarly,

    driver.findElement(By.name("Details")).click();
    

    finds the element (button, in this case) and clicks the button.

  • Multiple drivers: Unlike Watij, which only supports IE at this time, WebDriver supports — IE, Firefox, Chrome, and it also has a HtmlUnit version to run headless.
  • Window/Frame handling: This is yet another area where WebDriver excels with a caveat (that I’ll get into in a moment). When an operation like a button-click or a hyperlink-click opens a new pop-up browser, WebDriver provides an excellent way to get a handle to the new browser. Following call returns a set of all the window Ids.
    driver.getWindowHandles()
    

    You can iterate over the Set to find which one is your new window and switch to that window for all future operations.

    driver.switchTo().window(windowName)
    

    Windows’ handling is quite solid compared to handling of the Frames. In most of the situations it worked except when there are iFrames which load dynamically the behavior is not that consistent.

  • Wait behavior: When a particular operation (like a button-click) is underway WebDriver waits for the operation to finish before it executes the next step of the test case. Although this sounds trivial, I’ve had issues with this while using other tools. In those cases I had to use Thread.sleep() to wait between the page load and the execution of the subsequent step.
  • Alert Dialog: Couldn’t find a way yet to handle alert dialogs. I have to dig a bit more into the API and forums to see if they are supported at this time.
  • Mouse Events: I’d like to see more mouse events — double click, hover over an element, page scrolling, right click, etc.

Are you using WebDriver? What are your thoughts?

driver.findElement(By.name("q"));
Share and Enjoy:
  • del.icio.us
  • DZone
  • Digg
  • StumbleUpon
  • Technorati
  • Reddit
  • Facebook
  • Twitter
  • Google Bookmarks
  • FriendFeed
  • Tumblr
  • HackerNews

Tags: , ,

Book Review: The Passionate Programmer

The Book

Title: The Passionate Programmer

Author: Chad Fowler

Publisher: The Pragmatic Bookshelf

Review

This is the second edition of the book that was titled as ‘My Job Went to India (And All I Got Was This Lousy Book): 52 Ways to Save Your Job‘ in the inaugural edition. As the author admitted in the first few pages of the book, that title gave some impressions that the book is only about how to merely save the job.

The title for the second edition is more apt considering the intent of the author. If you read Andy Hunt’s books on Career Development, this book by Chad Fowler falls into the similar genre.

The key emphasis of the book is –

Think of your career as if it is the life cycle of a product that you are creating. That product is made up of you and your skills.

From My Notes

There are a lot of useful tips and sound advice in the book, just want to touch on a few of them –

How to choose a technology stack to work with and how to choose a business domain is discussed. I completely agree with the author’s view on how many of us end up doing whatever comes our way. In the author’s own words — “Our career is one big series of undirected coincidences“.

Fowler says that both ends of the technology adoption curve might prove to be lucrative. I see where he is coming from, although I haven’t seen many people intentionally taking up gigs to work on old/outgoing technology. Even the ones who take up such jobs, they are doing so because they can do only that.

These kind of folks they may call themselves specialists, but Fowler says that too many of us seem to believe that specializing in something simply means not knowing about other things. A very good case is made in the book why you want to be a generalist and at the same time being a specialist!

Fowler (being a musician in his past life) says it may be a good thing for being the worst guy in every band you are in — which translates to work and hang around with people who are smarter than you. Great advice, I can attest to that from my own experiences, especially from the early phases of my career.

Simply being good at programming alone is not good enough. You ought to make sure that you understand the business domain well enough. Without understanding the business domain is it even possible to do justice to the job — either making or saving money for the business.

One of the suggestions was to practice coding and read the open source code to learn new tricks of the trade. Great advice, but open source community is not immune from bad code, so choose your projects wisely!

There are some execution tips — productivity boost from do-it-now mentality, push yourself to accomplish something every day, working towards a team goal (your managers’ successes are your successes), don’t panic. Another important aspect is to question yourself are you adding enough value to justify your worth. Author suggests that there will be many opportunities that you can spot if you ask such questions.

Fowler explains why marketing one’s skills is important — If you kick ass and no one is there to see, did you really kick ass? Who cares? No one. Perceptions do matter and it’s not a wrong thing to manage perceptions. Build your brand (this concept is also explained well in Career 2.0 book by Jared Richardson. Richardson explains quite well the importance of writing and public speaking activities as a part of brand building).

Organization

The book is organized into short chapters under five broad categories / sections — Choosing your Market, Investing in your Product, Executing, Marketing, Maintaining your Edge. Each chapter ends with an ‘Act on It’ section. Author suggests a few items in this part of the chapter on how you can act based on the content discussed. Although they are nice, the real “act on it” is on the readers, coming up with the action items that is more specifically tailored for them.

You may actually finish reading this book in a few hours, perhaps in one sitting. I’d rather suggest taking your time, and go with a cycle similar to:

read_a_chapter –> introspect –> prepare_a_plan [act_on_it, of course]

Conclusion

As Chad Fowler suggests, this book isn’t about struggling to maintain the level of mediocrity required not to get fired. It’s about being awesome. It’s about winning. I remember Uncle Bob saying — you employer is not your mom. True. You have to make your choices and treat your job as a career, and develop the skills needed to keep you up-to-date. If you are currently looking for some inspiration or not so passionate about your career, then this book is for you.

Share and Enjoy:
  • del.icio.us
  • DZone
  • Digg
  • StumbleUpon
  • Technorati
  • Reddit
  • Facebook
  • Twitter
  • Google Bookmarks
  • FriendFeed
  • Tumblr
  • HackerNews

Tags: ,

REST: DELETE operation and tunneling

I was looking at some presentation slides on REST vs SOAP and one of the major drawbacks listed for REST approach is — lack of ability to use a message body for DELETE operations. I was not sure when I read that, why that would be a drawback.  (Discussion on the listed drawbacks will be a separate post by itself for another day).

A DELETE operation might look something like the following, where 123 is the ID of the customer:

DELETE /customers/123
Host: example.com

I was thinking about some use cases where a server might need more information for deletion. Thinking along the lines I tweeted this primarily to contest the presenter’s belief that it is such a huge drawback that you use that as a strike against REST-based approach.

Subbu Allamaraju responded. He says that the the question is a valid one.  Subbu said that:

That is a good question. Think of any case where client has to explain why the resource needs to be DELETEd. This is not uncommon.

Assuming that’s a valid concern I was thinking of ways to do that in a RESTy manner. Only way that I could think of at that point was whether we could use POST and perform DELETE. That sounded to me like tunneling. Tunneling is hiding operations from HTTP. There is no way to know whether the operation is — safe, idempotent, both safe and idempotent, neither safe nor idempotent.

As we continue discussing this on Twitter I’ve asked how different this scenario would be from tunneling via GET, something like the following:

GET /customer?method=delete&id=123
Host: example.com

The above GET is a clear example of tunneling. Similarly, SOAP-way of POST is another good example of tunneling.

POST /CustomerService HTTP/1.1
Host: example.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
 xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
 soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
    <soap:Body xmlns:m="http://example.com/customer">
        <m:deleteCustomer>
            <m:id>123</m:id>
        </m:deleteCustomer>
    </soap:Body>
</soap:Envelope>

Approach

An approach that sounded reasonable: use POST with a distinct URI when in doubt. That way you would avoid tunneling by making it a distinct resource.

POST /customers/123/deleteme
Host: example.com
Content-type: xxx

[send reasoning to the server why the resource is being deleted in the body]

This provides some visibility into the operation, via a URI that conveys the intention.

One downside of this approach is caches will not see the resource being deleted. In spite of that, this approach seems reasonable when you have a specific need to address the use case in question.

Thanks to Subbu for suggesting this approach. Provide your comments if you know of any other approaches.

P.S: Just one more reason why I like Twitter! Feel free to follow me there.

Share and Enjoy:
  • del.icio.us
  • DZone
  • Digg
  • StumbleUpon
  • Technorati
  • Reddit
  • Facebook
  • Twitter
  • Google Bookmarks
  • FriendFeed
  • Tumblr
  • HackerNews

Tags:

Java’s HTTP Handler and Cache Validation Issues

Background

A little while ago I’ve mentioned that I was working on client-side HTTP caching (using Ehcache) for REST clients. After a little hiatus, I’m back to complete the unfinished business, precisely dealing with cache validation support (using ETag, Last-Modified, If-None-Match, If-Modified-Since headers). I’ve also explained the approach I was taking to implement the solution, using Java’s ResponseCache mechanism.

However, I think I’ve hit a dead end implementing the solution using that approach. I will try to explain it here and hope that smarter people out there provide their thoughts.

Overview

Let’s start with a simple straightforward scenario. Quick control flow of the Java protocol handler approach:

  1. A client application gets an instance of sun.net.www.protocol.http.HttpUrlConnection, which extends java.net.HttpUrlConnection, via url.openConnection(). This hanlder instantiates a registered instance of java.net.ResponseCache, if there is one available.
  2. When a request is sent to the server via HttpUrlConnection, protocol handler first checks whether the representation is present in the cache by calling the get() method of the ResponseCache. If it is in the cache send it to the client, else send the request to the origin server.
  3. If the request is sent to the origin server, and if the response is any of 200, 301, or other “cache-able” statuses, the handler then calls the put() method of the ResponseCache to potentially cache the representation.
  4. ResponseCache would store the element in the cache. It uses Expires, Date, Cache-Control headers to determine time to live and set it on the element. Let’s ignore expiration model for this post as the focus is on validation.

Note: You have to write your own concrete implementation for ResponseCache to store and retrieve elements from the cache. Java doesn’t provide an out-of-the-box implementation for it, but it provides a framework for doing so.

Validating Cached Element

Now let’s look at a scenario that does cache validation. First, what is validation? There are two headers a server may send for validating the resource: a timestamp (Last-Modified) indicating when the resource was last changed, and an entity tag value (ETag). Server may choose to send only one of these headers, as both of them try to achieve the same purpose.

Responding to a request for resource X, a server sends along one or both these headers to the client along with X’s representation. On any subsequent request for resource X — the client may honor these response headers, and sends two of its own headers: If-Modified-Since (with the value of the Last-Modified header) and If-None-Match (with the value of ETag header). Former requests the server to send the representation only if the resource is modified since the Last-Modified time it has got, and the latter asks to send the representation only on the change of ETag value that it supplied.

If there is a change in the resource, a server sends an updated representation, with new values for ETag and/or Last-Modified headers. This scenario works fine with no issues as you get a 200 response back, and the protocol handler handles this just fine (similar to the straightforward scenario mentioned above). The issue that I’m going to mention is with the case in which the server determines that there is no change with the resource, and sends back a status 304, NOT MODIFIED, with no body in the content.

See the following sequence of events that end up with a status code 304 from the server (click on the image to enlarge):

Conditional GET

Issues with Java’s HTTP Handler

  • A client or client-side cache should first check whether a cached representation is available before sending a conditional GET of this sort. (There is no point sending Not-Modified-Since and/or If-None-Match headers if it doesn’t have a representation to fall back on). Java’s cache handler framework using HttpUrlConnection does not provide an option to do so.Let’s see the relevant source code of sun.net.www.protocol.http.HttpUrlConnection, lines 399-410:
    // Set modified since if necessary
    long modTime = getIfModifiedSince();
    if (modTime != 0) {
        Date date = new Date(modTime);
        //use the preferred date format according to RFC 2068(HTTP1.1),
        // RFC 822 and RFC 1123
        SimpleDateFormat fo = new SimpleDateFormat(
            "EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
        fo.setTimeZone(TimeZone.getTimeZone("GMT"));
        requests.setIfNotSet("If-Modified-Since", fo
            .format(date));
    }
    

    The above block of code adds If-Modified-Since header but makes no checks whatsoever whether the representation is available in the cache.

  • I don’t see a reference to If-None-Match header in the source. So if the client sends that header, it will be sent to the origin server without an availability check
  • In case, if there is no representation in the cache, the cache must have an ability to remove the validation headers from the request before sending the request to the origin server. I don’t see this framework supporting such a behavior.

Thoughts??

// Set modified since if necessary
0400:                    long modTime = getIfModifiedSince();
0401:                    if (modTime != 0) {
0402:                        Date date = new Date(modTime);
0403:                        //use the preferred date format according to RFC 2068(HTTP1.1),
0404:                        // RFC 822 and RFC 1123
0405:                        SimpleDateFormat fo = new SimpleDateFormat(
0406:                                "EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
0407:                        fo.setTimeZone(TimeZone.getTimeZone("GMT"));
0408:                        requests.setIfNotSet("If-Modified-Since", fo
0409:                                .format(date));
0410:                    }

Share and Enjoy:
  • del.icio.us
  • DZone
  • Digg
  • StumbleUpon
  • Technorati
  • Reddit
  • Facebook
  • Twitter
  • Google Bookmarks
  • FriendFeed
  • Tumblr
  • HackerNews

Tags: , ,