Management Style

"If employees just did what they were told to do, you would continually find defects at the end of the line. We want employees to go beyond what they are told and be creative, building quality into the process." - Mitsuo Kinoshita (Toyota)


I have learned about this for the first time in U.S. Marines c.1995 during Total Quality Management training based on Japanese Kaizen. The young Marine leaders were trained to make independend decisions in case of the interruption of the chain-of-command (death of the superiors) in order to be able to function in chaos of battle, conflicting reports and lack of communication with the outside world.

I modern company it means that the manager is serving as a mentor and instructor that constantly makes the employee responsible for planning, sharing knowledge and executing of the tasks. The manager should faciliate the communications, continous quality improvement, cut the bureaucratic "fat" and inefficiencies (BS). Manager should empower the employees to act and grow, not just do their jobs.

While "running a thight ship" the manager(captain) should strive to achieve a command where each member of the team comes forward with ideas, takes pride and responsibility in the work, grows and learns, transfers knowledge to others and is able to take charge when called upon.

Happy New Year 2009!

Quality improvement (Toyota example)

To understand current situation I have been re-reading a book on Toyota's quality process. I found many thoughts that can apply to programming directly.

"Something is wrong if we do not look around each day, find things that are wrong, unclear, tedious or repetitive, and then rewrite the procedures." - paraphresing Taiichi Ohno (Toyota)


One of the recent changes on our way of software development is to de-emphesize the rush for new features in order to ensure the quality of the delivered product.

When we propose a new product (QA build) we STOP new development until all problems are resolved and the application is trully polished, unit tested and documented. We involve our clients in QA process.

Only when problems are resolved we can provide product for UAT (user acceptance testing) and production deployment.

Only when everyone is absolutely happy with the features they delivered we start PLANNING the new development.

While in planning phase, we listen to the user feedback and fix any problems we missed, code at this point is still the same as UAT.

This is: fix problems first policy.

Once a stable product backed up by a suite of regression tests (Selenium) and delivered to the users, we go into a phase of intense development of new features.

The philosophy here is to continously deliver new, solid features that fully satisfy the client. Quality vs. poor quantity.  Having less features hardly ever breaks the deal, having production problems always does.

Gilead: PersistentRemoteService

Gilead does merge operations when you made a service call using PersistentRemoteService, before with hibernate4gwt it didn't do it on all service calls. So we had this nice error

[WARN] StandardContext[]Exception while dispatching incoming RPC call
java.lang.NullPointerException: null
at net.sf.gilead.core.PersistentBeanManager.mergePojo(PersistentBeanManager.java:423)
at net.sf.gilead.core.PersistentBeanManager.merge(PersistentBeanManager.java:289)
at net.sf.gilead.gwt.GileadRPCHelper.parseInputParameters(GileadRPCHelper.java:89)
at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:147)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)

So if you don't use spring to create your PersistentRemoteServices, then you have to include these 2 lines in the constructor of all your services.

XmlBeanFactory application = ApplicationContextFactory.getXmlBeanFactoryInstance();
setBeanManager((PersistentBeanManager) application.getBean("hibernateBeanManager"));

Spring beans: ApplicationContextFactory

This code snipped shows you how to get a bean from the applicationContext.xml

<bean id="statusDao" parent="baseTransactionProxy">
<property name="target">
<bean class="com.xyz">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</property>
</bean>


package com.xyz;

import org.springframework.beans.factory.xml.XmlBeanFactory;

public class Xyz
{
    public static void main(String[] args)
    {
XmlBeanFactory beans = ApplicationContextFactory.getXmlBeanFactoryInstance();
                   setBeanManager((PersistentBeanManager) application.getBean("hibernateBeanManager"));
        StatusDao statusDao = (StatusDao) beans.getBean("statusDao");

Status status = statusDao.fetch(new Long(1));
System.out.print(status.getEntity());
    }
}

Mac: resetting system and user password

Recently I had to research how to recover my system password on my Mac, I was not thrilled with my findings. With a quick Internet browsing, I discovered that one can reset a Mac system password with the operating system CD, which is provided with any Mac purchase as well as stores like Apple, BestBuy, etc. 
I had the urge to call the Apple support because I did not believe that Apple would have such a naive fix to a significant issue like a system password. More importantly there is no data loss after reseting a system password from the bootable CD. Also you have the ability to reset any user account password.
 While it is great that I was able to regain my access to my system password with out losing any data on my computer, it made me rethink about security on my machine. 
Here is how to reset a system and/or user password:
  • Insert the MacOS CD that matches with your Mac OS version.
  • Shut down your Mac
  • press C key + power button.
  • Click Continue for the welcome menu
  • Select Utilities from the upper menu bar
  • Select Reset Password from the Utilities menu.
  • Select HD, which is your hard drive
  • Enter your new password
  • Click on Reset Defaults
  • Click on save button
  • Select Quit Installation CD from the MacOS Install CD

Java: file writer

public static void main(String[] args)

    {

try

{

    FileHelper.write(new File("csd_temp.txt"), "Hello World!");

} catch (FileNotFoundException e)

{

    e.printStackTrace();

} catch (IOException e)

{

    e.printStackTrace();

}

    }

    public static void write(File file, String text) throws FileNotFoundException, IOException

    {

if (file == null)

    throw new IllegalArgumentException("File should not be null.");

if (!file.exists())

    file.createNewFile();

if (!file.exists())

    throw new FileNotFoundException("File does not exist: " + file);

if (!file.isFile())

    throw new IllegalArgumentException("Should not be a directory: " + file);

if (!file.canWrite())

    throw new IllegalArgumentException("File cannot be written: " + file);

Writer output = new BufferedWriter(new FileWriter(file));

try

{

    output.write(text);

} finally

{

    output.close();

}

    }

GILEAD replaces Hibernate4GWT

Background information:
http://noon.gilead.free.fr/gilead/index.php?page=f-a-q

1) Download ZIP:
http://sourceforge.net/project/showfiles.php?group_id=239931&package_id=291834&release_id=639455

Import jar files into Maven2 repo:




mvn install:install-file -DgroupId=net.sf.gilead -DartifactId=adapter-core -Dversion=1.2.0.29 -Dpackaging=jar -Dfile=*download location*/gilead-1.2.0.29/dist/adapter-core-1.2.0.29.jar

mvn install:install-file -DgroupId=net.sf.gilead -DartifactId=adapter4gwt -Dversion=1.2.0.29 -Dpackaging=jar -Dfile=*download location*/gilead-1.2.0.29/dist/adapter4gwt-1.2.0.29.jar

mvn install:install-file -DgroupId=net.sf.gilead -DartifactId=hibernate-util -Dversion=1.2.0.29 -Dpackaging=jar -Dfile=*download location*/gilead-1.2.0.29/dist/hibernate-util-1.2.0.29.jar

mvn install:install-file -DgroupId=net.sf.beanlib -DartifactId=beanlib -Dversion=3.3.0beta21 -Dpackaging=jar -Dfile=*download location*/gilead-1.2.0.29/adapter-core/lib/beanlib-3.3.0beta21b.jar

mvn install:install-file -DgroupId=net.sf.beanlib -DartifactId=beanlib-hibernate -Dversion=3.3.0beta21 -Dpackaging=jar -Dfile=*download location*/gilead-1.2.0.29/adapter-core/lib/beanlib-hibernate-3.3.0beta21b.jar




2) replace in XYZ.gwt.xml


<inherits name="net.sf.hibernate4gwt.Hibernate4Gwt15" />


with



<inherits name="net.sf.gilead.Adapter4Gwt15" />


3) replace LazyPojo with LightEntity


import net.sf.hibernate4gwt.pojo.java5.LazyPojo;
public class BaseDTO extends LazyPojo

with



import net.sf.gilead.pojo.java5.LightEntity;
public class BaseDTO extends LightEntity

4) replace


import net.sf.hibernate4gwt.core.HibernateBeanManager;
import net.sf.hibernate4gwt.gwt.HibernateRemoteService;
public class SomeClassImpl extends HibernateRemoteService

with

import net.sf.gilead.core.PersistentBeanManager;
import net.sf.gilead.gwt.PersistentRemoteService;
public class SomeClassImpl extends PersistentRemoteService

5) change how you get the beans:

ApplicationContextFactory application = ApplicationContextFactory.getInstance();
setBeanManager((PersistentBeanManager) application.getBean("hibernateBeanManager"));
addressDao = (AddressDao) application.getBean("addressDao");


It also seems like there were some issues with merging arrays that was
fixed in the 1.1.1 version of hibernate4gwt http://hibernate4gwt.sourceforge.net/news.html

We have had some issues with merging objects that contain Lists or
Sets of other objects and getting classcastexception errors. hopefully
going to the new version will fix these issues.

Java compareTo method for TreeSet

  • To use java comparable class, implement Comparable<> in your class
  • Write a compareTo method as below:

public int compareTo(TeamDTO teamDTO)

    {

TreeMap map = new TreeMap();

map.put(getKey(teamDTO), teamDTO.getId());

map.put(getKey(this), this.getId());

if (map.firstKey().toString().equals(getKey(this)))

    return -1;

return 1;

    }

iPhone: Java blog

I found same interesting posts on the following site:

http://java4iphone.com/category/all-news/java/

PS: If the rumors are true there will be Apple-enabled Java on the iPhone!


[0142]Examples of other applications 136 that may be stored in memory 102 include other word processing applications, JAVA-enabled applications, encryption, digital rights management, voice recognition, and voice replication. 

Mac OS X: Black border around active element

For a day, or two, I had a thin border appearing around each active element on my Mac OS X, despite the fact that it was not effecting  anything negatively, it was extremely annoying for two reasons: 

1) it is visually disturbing
2) I was not sure if the system was corrupted, or worse - infiltrated by some spyware

After some research I have learned that I turned ON the feature for visually impaired by executing a shortcut Command-F5.

Quality Testing

Unit testing

This (jUnit) is the first step for creating a quality product. A simple fact of writing a test before code implementation, forces the developer to think about various "what if?" scenarios. Testing a given method, or module, for both positive and negative inputs is essential and it is also a good example of how to use that code. Running all the tests at regular intervals assures good integration and regressions testing.

Selenium UI testing

Selenium provide the ability to regression-test hundreds of features that would be tedious for the human to test and retest. It quickly identifies the points of failure.

Code freeze

Code freeze happens when the QA/UAT is built and following the build. No NEW development happens during the code freeze. ALL developers concentrate
on:
- fixing the issues that were identified in this build,
- documenting the items they just finished,
- updating the QA checklist with new features,
- creating Selenium tests for the items just finished,
- planning and documenting future development,

iPhone: Actions & Outlets

Actions & Outlets may seem difficult, but it makes sense:

Action: a method that will be called once user does something to the widget
Outlet: a widget that will change as a result of some action



Connecting an Action: 
  • Drag from the desired Event (Touch Up Inside) to File's Owner 
  • select action method you wrote


iPhone: TextField to Label

To create action of the text field to populate a label...

- (IBAction) sgDoneEditing:(id) sender
{
UITextField *textField = (UITextField *)sender;
NSString *textFieldValue = textField.text;
NSString *label = [[NSString alloc]  initWithFormat:@"S.G.: %@", textFieldValue];
sgValue.text = label;
[label release];
}


GWT: Ant classpath in build.xml

The variables are set in my_sys_name.properties file:

...

<property file=".\\src\\main\\resources\\${user.name}.properties" />

<path id="class_path">

<pathelement path=".\\src" />

<pathelement path=".\\src\\main\\java" />

<pathelement path=".\\target\\classes\\" />

<pathelement location="${GWT_DEV_JAR}" />


<fileset dir="${GWT_SERVLET_PATH}">

<include name="*.jar" />

fileset>


<fileset dir="${GWT_USER_PATH}">

<include name="*.jar" />

fileset>


<fileset dir="${WAR_EXPLODED}\\WEB-INF\\lib">

<include name="*.jar" />

fileset>

path>

...

Change Mode of the file - UNIX chmod

Make a files executable:
chmod +x *.sh

Linux: MySQL case sensitivity

As a matter of principle when writing SQL for mix-OS systems:
USE LOWER CASE ONLY
Example proper case SQL statement:

CREATE TABLE `address` (                       

           `id` bigint(20) NOT NULL auto_increment,     

           `attn_care_of` varchar(255) default NULL,  

           PRIMARY KEY  (`id`)                          

         ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 

This is especially important when developing on Windows systems where case does not matter. It is possible to configure MySQL to be case sensitive/insensitive, but that is seldom done.