Constructors don’t get better with age!

The main goal of the article is to make you remember 2 things:

  1. Constructors aren’t like cheese i.e. they don’t get better with age
  2. An “ad litteram” iterative approach on writing constructors is BAD

How bad you wonder? Well… this bad:

new Admin(code,
 name,
 propId,
 locale,
 description,
 serviceNo,
 emailAddress1,
 emailAddress2,
 rfiEmailAddress,
 generalReports,
 vatNumber,
 partnerId,
 junk,
 dateJoining,
 appSessionId,
 legalType,
 legalTypeOther,
 contractRelationshipId,
 keyAccountTypeId,
 crmId,
 virtualTerminal,
 acquirerCountryConfirmed,
 acquirerUsesRegistration,
 sanction,
 timestamp,
 passwordExpiryDays,
 concurrentLogins,
 nonUseSuspensionDays,
 contractVersionId,
 calculateVAT,
 version);

Usually when you add a new filed Continue reading

My first open source project: Selenium on Steroids

The projects targets QA automation engineers that want a clean and simple way to create Selenium tests allowing them to focus more on designing the tests rather than dealing with technical difficulties. Using a simple property file and Maven profiles the instantiation of a WebDriver objects with different kind of settings reduces to just setting some predefined properties. The project enhances the functionality of the WebDriver API by offering additional methods for common tasks, having as a long run target to implement most of the Selenium IDE functions. SoS also offers different utility methods to interact with simple files, properties files, Excel documents, XML documents, Databases, post XML calls over HTTP, etc. Basically everything you need for your data driven testing scenarios.

Features

Using Google Guice in Web Applications

Introduction

As promised in the previous article I’ll continue presenting Google Guice also for web applications. In order to do this you’ll need to get the servlet extension – part of the standard distribution, along with other extensions like JMX, JNDI, Persist, Struts or Spring. Using Guice, the web.xml will be reduced at minimum – just make the Guice container start. The rest of the configurations will be easily done in Java in the same type-safe manner presented in the previous article.

The servlets will benefit from:

Code Review Guidelines – Part 2

Please read Part 1 first.

Automating the Code Review process

You can split the Code Review process into 2 parts: the Low Level part (styling, code duplicate, naming conventions, etc) and the High Level part (architecture, design, business).

Starting from a Coding Standards document, you can easily automate the Low level part of the Code Review process. The automation tools for Code Review will eliminate most of the styling issues, naming conventions, cyclomatic complexity, duplicate code, code coverage, etc. They can’t though detect major design issues, architectural flaws or project specific functionality and this is where the reviewer skills are the most important. I’ll present below the most used tools for Continue reading

Code review guidelines – Part 1

Last updated on 27th of January.

Please also read Code Review Guidelines Part 2.

What is a Code Review?

Code review is systematic examination (often known as peer review) of computer source code. It is intended to find and fix mistakes overlooked in the initial development phase, improving both the overall quality of Continue reading

Having JAXB1 and JAXB2 in the same classpath

If you just add JAXB1 and JAXB2 jars into the same classpath you may end up with the following exception:

You are trying to run JAXB 2.0 runtime but you have old JAXB 1.0 
runtime earlier in the classpath.
Please remove the JAXB 1.0 runtime for 2.0 runtime to work correctly.

The ideal solution would be to migrate everything to JAXB2 and remove the JAXB1 dependencies, but if you have certain constrains around this (and there usually are a lot) like: time, legacy systems, too much effort to retest everythig, etc there is an easy solution to have the old code run smooth and in the same time write the new code using the latest version of JAXB.

Here are the steps you need to follow:

  • Download jax1-impl-XXX.jar, where XXX is something like 2.x.x (this can be found in the JAXB2 distribution)
  • Remove your old jaxb-impl.jar (version 1) from the classpath
  • Add the new jaxb1-impl-XXX.jar into the classpath

All done!

Some SQL injection in Android – how to use GROUP BY and CASE when you are not allowed to do so

I suppose you’re all familiar with the “academic” examples of SQL injection when you put a AND 1=1 at the end of the SQL query and magically you get access to all kind of nasty things. I’ll show you how to use the same trick to do a SQL injection in Android, but for a good thing :)

I had the following situation: I’ve wanted to select group all the calls from the call log either by the caller name if the number was in the agenda or by number if the number was not in the agenda. To do this you need a content resolver, a URI and a projection to tell Android which columns you want to select. A typical call will look as follows:

getContentResolver().query(CallLog.Calls.CONTENT_URI, 
new String[] { projection}, selection, new String[] 
{selectionArgs}, sortOrder)

As you notice there is no way of telling android how to group the rows. But we Continue reading