Gist a github feature for sharing language specific formatted code


Finally after months and months I’ve found a neat, clear, formatted and even version controlled way of sharing code snippets.

Gist allows you to have language specific formatted code and embed it in any HMTL page or in a free blog like this one.

Here below is an example!

Hope this post helps people out there encouraging them to move all the embedded code that for years we’ve been raw pasting in our blogs, tidy them up and re-add in a cleaner, clearer way!

REST Payload API Versioning


In the last few days my focus has been on NoSQL DB(s) and REST services.

Points I’m more interested into are:

  • Payload API versioning
  • Platform independent Payload serialization and / or compression

I found on stackoverflow a very interesting debate on the versioning aspect.

Although exposing the API version in the URI gives great readability and control, I’m still a supporter of the media type field in the header.

I’ve initialized a github project so to realize a few PoC about the subjects I’m studying.

Examples make use of Jersey and Grizzly2 as container for tests. Everything is glued up with Spring 3.0 and built with Maven.

The code includes examples around:

  • Plain Json
  • Compressed (gzip) Json
  • Protocol buffer

You can dowload the code from github with the following command:

git clone https://github.com/nemo83/webservices.git

Any feedback is welcome.

Grep4j @ Google Dublin Group


Last 26th of February, I and my colleague Marco have been talking about Grep4J (https://code.google.com/p/grep4j/) at Google Dublin Group (GDG).

Here is a link to the event:

https://plus.google.com/events/c6a2kkfddro4080th31v61d833c

Review process for Test-Driven Development Teams – TDR


In my enterprise we recently introduced Test-Driven Development (TDD) as a programming technique for delivering robust and reliable software.

The lifecycle of tasks is the following:

  • To Do
  • In Progress
  • For Review
  • Verified
  • Done

Task lifecycle

The “To Do” and “In Progress” phases are self-explanatory. When a task goes in “For Review” the developer choose, with a round-robin approach, one of the team mates, and together they review the code in order to ensure quality (eg. check the code is clear, correct design and design patterns, high code coverage). Last but not the least it comes the “Verified” phase, during which the developer ensure that new features behave as expected in System Test.

There have been serveral attempts to make the “For Review” phase appealing, interesting and efficient. After some meeting and discussions we came up with the following check-list.

  • Functionality
  • Overall Design
  • Efficiency
  • Development Prctices
  • Test
  • Error Handling
  • Log

Even if we, in my humble opinion, perfectly described what should happen in a review phase, when we put it in practice, results were not so exciting as we were expecting.

What you really want to achieve in a code(peer)-review, is to ensure that the code is clear, well designed and correctly tested (in a TDD fashion!). What we were doing was to make the developer lead the review process and tell what the code was doing. Under these circumstances a reviewer would make zero or nearly no effort in understanding what the code was actually doing. Finally the “code coverage check” simply turned into a “check sonar code coverage %”. This could guarantee in really few circumstances that the quality and clarity criteria were met.

Since the TDD approach expects tests to be written before the actual code, why reviews should not be structured in the same way?

Few days after I finished to read the “Clean Code” book, I decided to play a game with a colleague for testing how well I learnt principles uncle bob explained in his book.

I asked him to guess, just reading from a bunch of test classes, what my code would have done. The result was surprising. With only a few variables and methods renaming, my colleague was able to correctly guess what my code was trying to do.

The review process honestly started very slowly because I, the developer, was giving as less hints as possible and was letting my colleague to progress alone as much as he could. Once sorted the initial naming incongruences, the review itself turned into a vivid and exciting conversation.

We agreed that

  •  the code was clear because he could guess with a little effort and nearly no suggestions what the code was trying to do.
  •  the code was well designed because class hierachies and patterns I used were thoughtful
  •  I correctly followed the TDD approach because I guaranteed a very high code coverage

What I learnt that day is that in order to understand whether or not you wrote clean and well tested code is to simulate somebody to work on your code in a day you’re off. If he/she’s able to do that without ringing you.. well.. you did a good job!

Thoughts on the review process

  1. Reviews have to be interesting. If the review process turns into something boring, it will not give results you expect. This can be achieved challenging your reviewer!
  2. In a review process the reviewer is the one who has to talk the most, if it is the developer, well, you have a smell there!

How to create a shortcut to copy a password to clipboard (so to be ready to be pasted)


Have you ever dreamed to have one or multiple password ready to be used just making use of a shortcut?

Well if you make use of ubuntu (even in a VM) here is the solution for you!

Install xclip

xclip is an Ubuntu app for dealing with stuff in the “clipboard”. I order to install it, please execute:

sudo apt-get install xclip

Once xclip has been installed you have to create a file that contains the password.

Eg.

echo "the_password" > /home/[username]/.my_unix_password
Creating a shortcut

There is a Keyboard menu in Ubuntu.

  • On the 12.04 the menu is at: Applications > System Tools > System Settings > Keyboard

Steps are:

  1. Select the Shortcuts panel
  2. Select Custom Shortcuts subpanel
  3. Click the +
  4. Enter the name of the shortcut (eg Copy Linux Password to Clipboard)
  5. in the command field enter: “xclip -i /home/[username]/.my_unix_password -selection clipboard”
  6. Click Apply
  7. Right click on Disabled. It should change into New Accelerator
  8. Now press the combination of keys you want to use to copy your password to clipboard (eg. CTRL+ALT+P)
  9. Finally close the keyboard menu

Now open a text editor and press your magic key combination…. now try to paste!

Et voila!

Be Agile, don’t be frAgile


The last thing you want when you work in an agile environment, is to apply agile’s concepts wrongly or don’t apply them at all.
Agile methodologies require the whole organization to act in an agile way where cooperation and continuous feedbacks are the keys of the success.

Although it’s easier to give birth to an agile team at the very beginning of a project, is also true that there is hope to become agile for a team that is still working in archaic and old methodologies.

The journey is long but you will get there, eventually. The most important thing to become an excellent team, is to chase the main road and never pull out trying to get shortcuts that will, somehow, do the job.

For this reason, when the friend and colleague @castigliego came to me with the illuminating idea of collecting stories about “Fragile Software Development” and bad agile experiences, we decided to create the hashtag #fr_agile in twitter.

We would like to make #fr_agile a channel where people tell their experiences about bad application of agile concepts or misunderstanding of agile’s principles and, possibly, the way they got out of there.

This sharing activity might become an incredible source of ideas and knowledge so that readers might be able to identify a smell in their team and be able to get rid of it before it could possibly make some victims.

As in a perfect agile fashion, even in this case communicating and sharing are the keys.

Quick HSQLDB How To


HSQLDB is a 100% pure Java SQL database. I often make use of it when I’m working on proof of concepts or tests.

You can download it at http://sourceforge.net/projects/hsqldb/files/hsqldb/.

In order to run it, it’s required to have a JVM installed and the JAVA_HOME environmental variable pointing to it.

I recommend to create a folder in your home directory (or wherever else) where storing all the files required for your dbs.

In order to start a db instance, simply execute:

java -cp ../hsqldb.jar org.hsqldb.server.Server --database.0 file:mydb --dbname.0 db_name

Where:

  • ../hsqldb.jar is the path to the hsqldb library
  • mydb is the prefix of the file names that will be create
  • db_name is the name of the schema we will have to use when connecting

A very nice utility application that is shipped with the hsqldb binary is the DatabaseManagerSwing. It’s a simple one but it’s enough to navigate and query your freshly created db. Syntax for starting it is:

java -cp ../hsqldb.jar org.hsqldb.util.DatabaseManagerSwing

DatabaseManagerSwing remembers last connections you’ve created and helps to save plenty of time when you need to switch from a db to another.

This quick, nearly useless, tutorial will come in help with one of the next post I’m going to create.

-Sieze

Keyboard and mouse stop working in Virtualbox guest


 
If you ever experience your mouse and or keyboard not working in your Virtualbox guest OS and the only way to make them work again is rebooting, try to install the following packages:
 
sudo apt-get install scim-bridge-client-qt scim-bridge-client-gtk
-Sieze

How to mount a windows shared drive with a name containing spaces


If you are trying to mount a Windows shared folder that has its name containing spaces you can easily mount it sticking 40 instead the space character:

For example, if the box is at the address 192.168.0.15 and the name of the shared folder is "Name with spaces" you can add the following line into your /etc/fstab

//192.168.0.15/Name40with40spaces /mnt/name-with-spaces bla bla bla

-Sieze

Execute a command via SSH and terminate the connection without waiting for the command to finish


A few days ago I was trying to update the script used to build the application on which I’m working. Together with the build I also wanted to integrate the script so to release the app on test boxes and restart the JBoss instance.

While the stop was working as a piece of cake, the restart of the server was keeping my ssh connection alive, and causing the release script to not finish.

After a bit of googling that the ssh syntax you’ll have to use if you want to send a command via ssh, redirect std out/err, and close the ssh connection:

ssh username@host “nohup command_to_execute > /dev/null 2>&1 > /../log_folder/log_file &”

Hope this will help someone of you out there :-)

 

-Sieze

Yet another Java blog

mysoftwarequality

Just another WordPress.com site

Jess & the City

Cynical ramblings of a 30ish-year-old Latin girl living in Dublin

Follow

Get every new post delivered to your Inbox.

Join 40 other followers

%d bloggers like this: