Turth

10. October, 2010

In another blog, I read a comment “I want the ‘truth‘.” Uh huh. The “Truth.” What is “The Truth”? A little thought experiment.

A police officer walks along a house. Suddenly, a shot is fired. Three seconds later, the officer kicks in the door and finds a woman, dead, with a black hole in her chest and a man with a gun in his hands.

Question: Did the man kill the woman?

What is the “truth” here? A whole ago, I read in the Perry Rhodan Sci Fi series: There are four levels of “truth”. One is called the absolute or objective truth. We can never hope to glimpse at it.

Then there is the social truth. It is what a whole society believes true. For example, a society can believe that stealing is bad.

On the next level, we have group truth. Groups define themselves by being different from all other groups. This also means they have their own beliefs about truth. Even if society believes stealing is bad, a group of street workers will have a more detailed view on the topic. In effect, the group shares the same ideal but they have their own beliefs how to solve the issue.

The last level is the personal truth. As a member of a group, a person can believe something that (s)he personally would reject. An example here could be to steal to belong to the local gang – or to risk being their punching ball.

If we return to the thought experiment, what are the various levels of truth here?

The objective truth will know what really has happened and why. What the man thought at any moment. What the woman thought. What happened to her as she died. How the worms in the earth felt as the police officer stomped over the flagstones of the path leading to the door.

There is no way to know these facts – ever. The woman is dead and beyond questioning. The man was in a state of mind that could be described as “temporary lunacy”. Even if he knew what he had thought, he probably won’t be able to tell us – or he might even have serious reasons to lie. The police officer didn’t see the act, only the aftermath. And if you know a way to talk to worms, there are a couple of people in Stockholm waiting for you.

Social truth dictates that the man has killed the woman. Just three facts are enough: Man and woman present, man has gun, woman is dead. Did you notice that the gun was smoking? I didn’t write that. If you remember that scroll up and read the sentence again. No smoking gun. There is no indication that a shot was fired but social truth still says “he has killed her.” Remember next time you read “someone committed a crime.”

On the group level, truth depends on your peer group. Feminists: Surely the man is a monster, serial killer or worse and must be sentenced to death. Machos: That bitch probably teased him till he snapped. Any firearms association: If she had a gun, she could have defended herself. Police: There are too many guns around. Psychologists: Another life lost because of ignorance of the human mind. Cleaning crews: Blood is hell to clean up. Teachers: What will happen to the poor children? Journalist: Is there a story in there or is it just another homicide?

On the personal level, truth depends on your experience. Have you lost someone due to a crime? Then your reaction will be completely different from someone who is just enjoying this thought experiment. If you have lost someone, you will think about the grief and sadness while someone else will think “Hey, this is cool. I’ve never thought of that.”

This will then influence how you remember this text. Memories are always linked to emotions. If I fail to evict some strong emotion in you, you will forget. The brain is trained to keep an eye on the important stuff (which can kill you) and forget about the boring things ASAP.

So what is the truth about the story above? What has happened? As we know, the man is likely not to know or not to tell. Some ideas:

  1. The man has killed the woman
  2. The man just found the already dead woman and the killer is in the backyard where he fired a shot
  3. A sniper has killed the woman and the man just drew his gun to defend himself
  4. The whole scene is part of a movie about a man who is accused to have killed a woman
  5. It could be a computer game
  6. Or a scene from a book
  7. The man is holding a book in his hand which has a gun on the cover
  8. The whole thing is just part of some thought experiment

The “truth” is a lie. We can only hope to get ever closer to something that is out of reach because our brain wasn’t designed to contain it.

 


Hidden JUnit features: @Rules

8. October, 2010

@Rules seem a better solution than @RunWith to do some special work before/after a test. The release notes mention a couple of ideas:

  • Notification on tests
  • Setting up or tearing down resources, especially when they are used in multiple test classes
  • Special checks performed after every test, possibly causing a test to fail.
  • Making information about the test available inside the test

Related articles:


Password managers for Nokia with Symbian/S60

7. October, 2010

Some password managers for my mobile phone:


Wiki-like editors/notebooks

7. October, 2010

A list of wiki-like editors/notebooks/etc:


Logging JDBC with slf4j

7. October, 2010

 

This chart represents several constituent comp...

Image via Wikipedia

 

If you use slf4j in your project and need to log JDBC events, then have a look at log4jdbc. It has all the usual features: Timing statements, showing all arguments, mapping SQL to connections. It can even log stack traces if you need to know where a JDBC call was made. Sample output:

16:32:56.162 [INFO ] jdbc.connection - 1. Connection opened  java.sql.DriverManager.getConnection(DriverManager.java:525)
16:32:56.168 [DEBUG] jdbc.connection - open connections:  1 (1)
16:32:56.169 [DEBUG] jdbc.audit - 1. Connection.new Connection returned   java.sql.DriverManager.getConnection(DriverManager.java:525)
16:32:56.284 [DEBUG] jdbc.audit - 1. PreparedStatement.new PreparedStatement returned   com.avanon.basic.db.XPreparedStatement.prepare(XPreparedStatement.java:84)
16:32:56.292 [DEBUG] jdbc.audit - 1. Connection.prepareStatement(SELECT *
FROM V_RCSA_40_4_CTRL_RATING) returned net.sf.log4jdbc.PreparedStatementSpy@423606  com.avanon.basic.db.XPreparedStatement.prepare(XPreparedStatement.java:84)
16:32:56.162 [INFO ] jdbc.connection - 1. Connection opened  java.sql.DriverManager.getConnection(DriverManager.java:525)
16:32:56.168 [DEBUG] jdbc.connection - open connections:  1 (1)
16:32:56.169 [DEBUG] jdbc.audit - 1. Connection.new Connection returned   java.sql.DriverManager.getConnection(DriverManager.java:525)
16:32:56.284 [DEBUG] jdbc.audit - 1. PreparedStatement.new PreparedStatement returned   com.avanon.basic.db.XPreparedStatement.prepare(XPreparedStatement.java:84)
16:32:56.292 [DEBUG] jdbc.audit - 1. Connection.prepareStatement(SELECT *FROM V_RCSA_40_4_CTRL_RATING) returned net.sf.log4jdbc.PreparedStatementSpy@423606  com.avanon.basic.db.XPreparedStatement.prepare(XPreparedStatement.java:84)
16:32:56.342 [DEBUG] jdbc.audit - 1. PreparedStatement.clearParameters() returned   com.avanon.basic.db.SetParameters.clear(SetParameters.java:144)
16:32:56.343 [DEBUG] jdbc.sqlonly -  com.avanon.basic.db.XPreparedStatement.executeQuery(XPreparedStatement.java:71)
1. SELECT * FROM V_RCSA_40_4_CTRL_RATING
16:32:56.350 [INFO ] jdbc.sqltiming - SELECT * FROM V_RCSA_40_4_CTRL_RATING  {executed in 7 msec}
16:32:56.356 [DEBUG] jdbc.audit - 1. PreparedStatement.executeQuery() returned net.sf.log4jdbc.ResultSetSpy@2c5444  com.avanon.basic.db.XPreparedStatement.executeQuery(XPreparedStatement.java:71)
16:32:56.412 [DEBUG] jdbc.audit - 1. PreparedStatement.close() returned   com.avanon.basic.db.DBUtil.close(DBUtil.java:114)
16:32:56.418 [INFO ] jdbc.connection - 1. Connection closed  com.avanon.basic.db.DBUtil.close(DBUtil.java:129)
16:32:56.418 [DEBUG] jdbc.connection - open connections:  none

The strange “1.” is the connection number.

Alternatively, check out jdbcdslog.


Backup Hudson config to a VCS

6. October, 2010

If you want to backup your Hudson configuration, why not back it up to a version control system (VCS)?

Stephen Connolly has posted a solution in his blog: Keeping Hudson configuration and data in SVN


Error creating array in JavaScript

6. October, 2010

If you see this error in JavaScript (for example in a BIRT report):

org.mozilla.javascript.EvaluatorException: error instantiating (): class java.sql.Array is interface or abstract

then don’t include the package java.sql (as in importPackage(Packages.java.sql);) because if you do, new Array() will find the SQL class first and it will fail.