Barraca do Paulo

Hi, my name is Paulo, I am portuguese, and I am currently working as a freelance Software Engineer in Luxembourg. This is my personal blog, where I express my views in various subjects. You can contact me using barracadopaulo@gmail.com. Welcome!

7/6/09

Whatever Works

The movie Whatever Works has been recently released. I haven't seen it yet but I definitely want to. I am looking forward to see the result of mixing Woody Allen and Larry David. Sounds promising...

6/30/09

Real World Java EE Patterns

This is an interesting book. I already got my copy and I am enjoying it quite a lot.

6/29/09

JavaFX and Open Office

During JavaOne Larry Ellison has been very supportive of JavaFX. That was a tremendous sign and gave early adopters the necessary confidence to go forward with their projects. The fact that Larry has mentioned the porting of Open Office into JavaFX was also a major strike. It shows that JavaFX will be more and more suitable for enterprise applications, and even though it still has a long way ahead, I strongly believe it will become a major player in the near future.

6/23/09

To bind or not to bind

Assume that you have a table which is partitioned by a column X. Even though not solid as gravity, most of the times the rule is that your SQL should hard-code any values affecting X instead of using bind variables.
Therefore

select * from Table where X = 1

should be used instead of

select * from Table where X = :var

This way the database engine is able to calculate a better execution plan when compared to using bind variables.

6/14/09

SQL Tuning- how and who

SQL Tuning is an indispensable step during application development. But who should do it?
The developer knows the functionality around the application and around the queries, and therefore knows how to re-write a query making it more performant but keeping the same result. The developer knows well SQL and will be able to fully use a range of tuning tools which will make the query faster. But most of the times the developer will look at his query as the center of the world. He will make it as fast as he can, ignoring any side effect on any other processes or queries running on the same database. The developer will be happy to tune his query even if it brings the database on its knees. He will proudly advertise the result of his work not caring about the fact that his gain cause higher losses on other processes.
The DBA has a more wider view on the database and can look to the query from a different perspective. He is capable of measuring the consequences of the tuning on the database and decide how far the process can go. He has a better knowledge of the database and can better improve the query. In the other hand, he normally knows little about the functionality or the business priorities, and therefore he will judge the tuning simply from the technical perspective. Maybe the query must take a big part of resources because it implements a business functionality which is by far a priority.
So the conclusion is that SQL tuning is a process where developers and DBAs must work closely in order to maximize performance, taking is consideration the business priorities, and measuring the impact of the process on the system as whole.

6/13/09

UNION versus UNION ALL

Whenever possible use UNION ALL instead of UNION. An UNION forces a sorting of both tables in order to identify duplicates. With big volumes this can introduce a considerable overhead on the query. Therefore if your tables do not contain duplicates, or if you do not care about having duplicates in the final result, then use UNION ALL.

One more "go live"...

And another "go live" took place, sixteen hours of work straight. This one was quite ok.

6/9/09

Happy Birthday, Mr. Unix!

I forgot that Mr. Unix is now 40 years old. Long live Unix!

I miss Prolog....

From all languages I have used during my academic and professional life, Prolog was always one of my favorites. Unfortunately I cannot use it on my day-by-day and therefore I feel Prolog-sick every now and then. I keep telling myself that one of these days I will take a couple of days and dedicate them to play a bit with Prolog. Maybe soon. I miss some backtracking...

Java Gotcha 5- Overriding flavors

Keep in mind that with Java 5 it is possible that the overriding method has a different return type than the overridden method. The only rule is that the return type of the overriding method is a subtype of the return type of the overridden method. Therefore the following code became valid with Java 5:

class A {
public A m() {
return new A();
}
}

class B extends A {
public B m() {
return new B();
}
}

6/2/09

JavaOne

Time flies, and one more JavaOne has arrived. For those of you in the sunny California, enjoy it!

6/1/09

Java Gotcha 6- Mutable constants

Most of the developers assume that whenever the final keyword is used in a variable it indicates a constant, that is, a variable which gets assigned with an immutable value. That is not entirely correct, the final keyword, whenever applied to a variable, indicates that the variable can only get one value being assigned once.

public class MyClass {

private final int myVar;

private int myOtherVar = getMyVar();

private int andAnotherVar;

public MyClass() {

myVar = 10;

andAnotherVar = getMyVar();

}

public int getMyVar() {

return myVar;

}

public int getMyOtherVar() {

return myOtherVar;

}

public int getAndAnotherVar() {

return andAnotherVar;

}

public static void main(String args[]) {

MyClass mc = new MyClass();

System.out.println(mc.getMyVar());

System.out.println(mc.getMyOtherVar());

System.out.println(mc.getAndAnotherVar());

}

}

The previous code will print the sequence 10 0 10. Therefore, while dealing with final variables, we must distinguish the ones which have a value assigned at compile time, which work as constants, from the ones which get their values at runtime.

Archive

My Profile

Paulo
Vila Real, Portugal
View my complete profile