Home arrow Blog

Michael's blog is now available on the Click here to order on Amazon.com

Paired Programming…automating human tasks.

I miss pairing (or the practice of paired programming). Those who have never tried paired programming commonly look at the practice as a waste of resources. Two people doing the work of one…or so it seems. However, there are so many things that pairing brings to the table. One of those is that when you pair program, things you would have to do anyways just happen. They get automated automatically (pun kind of intended). So let’s take a look at paired programming as a way to automate things you are going to do anyways (or prevent from happening).

  • Automating of issue solving.

    As technologists, we face scenarios on a regular basis where we have to work through something that we haven’t done before, haven’t done in a while or just aren’t sure what the best way to do it is. When this occurs, our productivity can come to a crawl as we research the solution. With two developers, the likely hood that: a) one of the devs knows the answer or b) they can research the answer quicker cuts down on the time spent churning on a single issue.

  • Knowledge transfer automation.

    This is related to the item above. When you work side by side with someone, you learn together. If one person knows something, they teach the other and vice versa. By rotating pairs, this transfer of knowledge happens automatically across your team. This limits the creation of SMEs and prevents bottle necks that occur when only one person knows a particular technology or part of the system.

  • Automatic distraction repellant.

    When was the last time you were working in your cube and someone walked up just to talk? Unfortunately, (although no one will admit it) this happens way to often in the business world. This painful disruption of thought as well as the time taken away from development is a huge drain on productivity. However, when two or more people are already working together, people become less likely to interrupt. Those casual “Hey, did you catch the game last night?” conversations seem to just go away. People, by nature, are less likely to interrupt a pair of developers working than just a single developer. Just another place where there is power in numbers.

So how about it? On paper this makes sense. Those who have tried it seem to agree. However, why is it that this practice seems about as likely to go mainstream as cutting overtime (which many studies have proven actually makes developers less productive…a topic for a different day)? What are your experiences with paired programming? What’s good, what’s bad? Share your thoughts in the comments!

Prototype’s Element.insert

So today I was working on a small item that I figured would be pretty straight forward…until I went to Prototype’s documentation. I want to say that overall, I really like Prototype’s doc site. Overall, it is laid out well and 95% of the time has exactly what I need. Unfortunately, this is one time where it didn’t. I wanted to implement a simple select box with two arrow buttons next to it (up and down). The goal was to allow users to order the options in the select box. Below is the code I was using for moving an element up (down was similar):

function upOption() {
  if(!clicked) {
    clicked = true;
    options = $('selectId').childElements();

    for(var i = 0; i < options.length;) {
      element = options[i];
      if(element.selected && (i - 1) >= 0 ) {
        options[i].remove();
        options.splice(i, 1);
        Element.insert(options[i - 1], {before: element});
      }

      i++;
    }
    clicked = false;
  }
};

Where I got stuck was on the Element.insert. The documentation (as found here) states that “Inserts content before, after, at the top of, or at the bottom of element, as specified by the position property of the second argument. If the second argument is the content itself, insert will append it to element.”. What does that mean?!?!

I’ll tell you what it means. Element.insert takes two parameters, the element to insert the new content ajacent to and one of the following:

  • The content to be inserted
  • A Hash with a single key that dictates where to put the content with the content as the value

The example above is an example of the option with the hash. What this does is it takes options[i - 1] and places element into the DOM as the first sibling above options[i - 1]. What each option does is as follows:

  • before: Places the element as the first sibling before the identified element in the DOM
  • after: Places the element as the first sibling after the identified element in the DOM
  • top: Places the element as the first child under the identified element in the DOM
  • bottom: Places the element as the last child under the identified element in the DOM

If we use the example Element.insert($('myList'), {XXX: new Element('p')});, the new p element would show up in the corresponding place:

<div id="container">
     before
     <ul id=”myList”>
          top
          <li>element 1</li>
          <li>element 2</li>
          <li>element 3</li>
          bottom
     </ul>
     after
</div>

So there you have it. Please feel free to point out any optimizations I could do in my method. One I already know about but was unable to get working was removing the line element = options[i]; and just use the element returned from the remove() function. Unfortunately, I was unable to get that to work (as tested in IE7). As always, I look forward to the comments!

Thanks to Joseph Hirn and Partial Mocks

I just came from a brown bag session given by Joseph Hirn on unit testing. He did an excellent job covering unit testing concepts as well as some great tools/tricks. One that he pointed out that I think I will dive into on this site is the concept of Partial Mocks.

Partial Mocks are concept provided by EasyMock’s Class Extension package. They allow for the mocking of a method over an entire class. A tutorial coming soon.

Once again, I’d like to say great job to Joe and thanks for the free advertising ;)

A sound backup strategy. Is that so hard?

Ok, I’m confused. This is 2009, correct? The web is 19 years old. Why do companies go into production at this point in time without ANY form of tested data backup plan? I’ve seen two reports since the first of the year of companies folding due to the complete loss of all user data.

The first was the blogging platform Journalspace in January (they have since been picked up by a new owner…hopefully they have heard of off site backups). Journalspace was using RAID as their backup. The thought was that if one drive fails, we have a copy on drive two, so all will be good. Fine in theory…if the only failure that occurs is a hardware one. In Journalspace’s case, the data was wiped via software. If you delete a file on purpose from drive one, it will be deleted as well from drive two. A backup strategy, RAID is not.

Now we have the social bookmarking site Ma.gnolia. Today they announced that their attempts to recover from a database server crash have been unsuccessful and all data has been lost. In this case, instead of not having a backup strategy at all, they just had one that didn’t work. I would now consider them poster children for testing your backup strategies.

Am I missing something? As a user of services like these, these should serve as examples of why you shouldn’t trust your service providers and do your own backups. Backup your WordPress or Blogger blogs. Backup your del.icio.us and digg links. What methods do you use to backup data that service providers store for you? Let us know in the comments!

A great saying for how to live…

I am a lucky guy. I’ll be the first to admit it. Regardless of the situation I’m in, no matter how bad it seems, things tend to fall my way. My mother says:

“Michael can fall in a pile of sh!t and come out smelling like a rose”

And it’s true. However, I came across a saying today (an old co-worker of mine had it in his gmail profile) that really fits why I believe that things tend to fall my way. After some research, I believe it was said by John Wooden (a famous college basketball coach):

“Things turn out best for the people who make the best out of how things turn out”

I’m a big believer in that you make your own luck in life. If you set things up well, they will fall your way. This really has nothing directly to do with technology, but as more of a life principal.

When things don’t go your way, do you tend to blame yourself or look at external sources? You are the one variable you can always control. When you can control the outcome of situations by controlling yourself, you suddenly become a lucky person.

Share your thoughts in the comments!

New Tutorial on EasyMock’s MockControls

Most people who have used EasyMock before are familiar with the types of mock objects. There is the basic mock object, created with EasyMock.createMock(MyInterface.class);. There is the strict mock that validates both the method calls and the order they occur. Finally there is the nice mock which returns a basic default (false, 0 or null) if an unexpected method call occurs. However, most developers I have come across don’t use mock controls much. Today we change that! My new tutorial will introduce you to the concepts of mock controls and show you an example of where your unit testing without them may not be as safe as you think. You can check out the new tutorial here: http://www.michaelminella.com/testing/mock-controls-with-easymock.html

Thanks And A New Year

I wanted to take a minute during the hustle and bustle of the holidays to say thanks to everyone in cyberspace. Although I have been a web developer for over seven years, this is the first year that I actually took the time to put something out on the net that I could call my own. It is my goal to provide tidbits and knowledge to those who happen by my site that should make their development a bit more smooth. From the feedback I have received I think I am on track. But I need to thank you for both following and supporting what I have put together here. Your feedback is both invaluable for my growth as a content developer and as support for the time and effort that goes into putting together a site like this. Thank you.

With that being said, it’s also time to start looking forward to next year. This past year I launched the site, developed tutorials on JUnit, TestNG, EasyMock, jmockit, Prototype and script.aculo.us. What are some areas that you want to learn more about? Should I go more in depth into some of the above topics? Are there topics in the web/java space that you would like to see me cover? I have created a survey to gather some input. Let me know what you think by taking it here:
View Survey.



Thanks again for all your encouragement and ideas. I’m really looking forward to an exciting 2009!

Personal Development Environments

We all know that source control, effective build scripts and continuous integration (CI) are all vital to a successful project at work. However, what about personal projects? You know the ones…that website you built for Uncle Bob’s starting business or the application you developed when you were playing with Groovy. Most of these projects begin as nothing more than a right click in our favorite IDE, creating a new project and starting to code. However, I am curious if anyone has a more robust system for their personal (or not yet public) development. If for no other reason, what if one of your projects sparks something that becomes bigger than what was envisioned at the outset and you want to make that your new business. Migrating to source control can be difficult at best and that would only be the beginning of issues.

So I ask you, readers, what do you use for your development environment? Do you use source control? If so, do you host it or is it hosted by someone? Build scripts, yes or no? CI? Let us know in the comments!

No Fluff Just Stuff…Day Three

No Fluff Just StuffAnother year, another No Fluff Just Stuff is in the books. As I have said previously, this is my third year going and just as previous years, NFJS did not disappoint. I went into today with no idea what I was going to go to except for Ken Sipe’s Hacking - The Dark Arts talk. I ended up picking Coaching and Leading Agile Projects by David Hussman, and two by Andrew Glover: Tactical Continuous Integration with Hudson and Easy BDD with Groovy. All were top notch.

The first talk, Coaching and Leading Agile Projects by David Hussman was about Agile coaching. I went to a number of David’s talks last year and enjoyed them immensely and this one was no different. He has a depth of knowledge in the Agile management space that is second to none and his laid back demeanor leaves for a relaxed and open talk. If you are interested in Agile at all, I strongly recommend attending his talks.

Next I went to Andrew Glover’s Tactical Continuous Integration with Hudson. My current project just recently implemented CruiseControl and I used CC on my last project, however knowing that CC has some limitations and frankly is pretty crude overall, I was curious. Hudson is what CC was meant to be after seeing Andrew’s talk. From build pipelines to trending, it has it all. I was very impressed. Unfortunately, since it’s alot newer that CC, not all plugins are fully featured yet. In my case, we use Rational CearCase UCM and the plugin for that doesn’t have everything we need yet. So no switching…yet.

The expert panel discussion was held after lunch a good Mexican lunch. It started out with Jay doing some word associations with to get the conversation going which felt like it went too long IMHO. Once the floor opened up, there actually was a very good discussion on what will happen when software will be held to the same standards as things like cars and medicine. For example, if a car blue screened everytime you honked the horn and changed the radio while on the express way, there would be a ton of accidents, people would sue and things would change. However, we accept similarly obscure faults of software without much second thought. Once lawyers get involved and software is held to a higher standard things will change (or so the panel seemed to agree).

The afternoon for me continued with Andrew’s talk on Behavior Driven Development in Groovy. Once again, I enjoyed Andrew’s talk immensely. I will be honest, I probably won’t switch to using easyb anytime soon (it felt too much like just well documented JUnit tests instead of anything really new IMHO). Essentially easyb is a DSL for test driven development that combines a formal documentation syntax with testing code. I will say I came away well informed and entertained.

Finally I attended Ken Sipe’s Hacking - The Dark Arts talk. For what it was, it was a good talk. Ken did an excellent job covering cross site scripting (XSS) and SQL injection. However, I personally would like to see this stretched into a track instead of a single talk. Not much outside of what can already be found on OWASP and using WebGoat was covered. This would be a really good track if in talk a he covered vulnerabilities and exploits and in talk b he covered security in the enterprise with topics like security audits, etc. Since most people would get fired for just starting to hack their system, I think covering how to introduce these topics into an enterprise would be a valuable topic.

Overall, this year’s NFJS was an excellent experience. I have a deck that I will be putting out in the coming weeks that I used to sell NFJS to my managers. I firmly believe that there isn’t another conference where you can spend so little and come back with so much you can use literally on the Monday after. Let me know your thoughts in the comments!

Update:You can read my reviews of the conference and the sessions I attended here: day 1 and day 2.

No Fluff Just Stuff…Day Two

No Fluff Just StuffWell I just got home from a second day at No Fluff Just Stuff (NFJS). Today wasn’t quite as exciting as yesterday, however I still had at least one great session. I went to four sessions total today (I didn’t go to any of the Birds of a Feather sessions this year). The four talks I went to today were Project Smells by Nathaniel Schutta, Exploring Terracotta by Alex Miller, Spring and JMS, Message Driven POJOs by Mark Richards and Ken Sipe’s Architecture and Scaling.

Project Smells is a talk about project culture. In it, Nathaniel talks about how things get manifested and how culture effects project success. I really liked Nathaniel as a speaker. He was entertaining and the talk overall was a good talk. Unfortunately he had to follow Neil Ford’s keynote last night and there were a ton of common themes between the two talks. At one point he actually pointed out that he had made the deck before Neil’s talk.

Alex Miller’s talk Exploring Terracotta was next on my docket. I have to say this talk was disappointing. Terracotta is Alex’s bread and butter. It’s what keeps a roof over his head, yet I felt like there were a lot of gaps or things he either didn’t have experience with or didn’t have the answer for on this topic. Don’t get me wrong, I don’t expect a speaker to know everything about the topic they are speaking on (after all, anyone is an expert until proven otherwise), however there was just too much missing given that this guy is one of the main guys working on the project itself. If you have no clue on what Terracotta is, this is a good talk. If you want to go to the talk with specific questions hoping to be answered, expect a 50/50 shot of success.

The afternoon for me began with Spring and JMS by Mark Richards. This is the first time I heard him speak and I have to admit, he did quite well, especially with Scott Davis as one of the audience members. His talk was informative and he had great examples. I went into this talk familiar with Spring and JMS. I was hoping to find out that something I hadn’t been able to figure out was possible. To my dismay, Mark only confirmed my findings (that you can’t do a true message driven POJO that returns something as well. It can only read from a queue). Overall this was an excellent talk and I recommend it for anyone interested in JMS and Spring.

Finally I went to Ken Sipe’s Architecture and Scaling talk. I had heard Ken speak last year about JMX and came away informed but not excited. After this talk, I felt neither. I can sum up the talk in the following sentence: “To architect a scalable solution, avoid I/O.”. That was the basis of the talk. I’m not going to pull out a soap box and debate that finding here, all I will say is that except for a bit more on the statistics gathering for proof of scalability, that previous sentence sums the rest of the talk.

Other quick notes about day 2:

  • The flash drives were in. They are blue wristband flash drives (picture the rubber Livestrong wristbands with a flash drive attached to it). I’d probably be more likely to use it regularly if it was a key chain instead of a wristband. They seemed to have issues with the duplication process for them. I got one that couldn’t be read at all and one that some of the files were corrupt. I guess I’ll download the files and copy them onto the drive myself
  • Food had a bit of a hiccup today. The main course for lunch was lasagna today. They ran out of meat lasagna prematurely. :( Oh well. I’m not a huge cheese person, but the vegetarian lasagna wasn’t that bad.
  • The Birds of a Feather sessions this year were Languages on the JVM, Architecture and Agility.

You can read more about the speakers and the No Fluff Just Stuff at http://www.nofluffjuststuff.com

Update:You can read my reviews of the conference and the sessions I attended here: day 1, day 3.

Tweets

    Twitter Button from twitbuttons.com