C++ has got operator overloading. Java does NOT have. Java folks just say that it is bad, and provides bad abstraction and leads to very unreliable and difficult to manage code. That’s why Java doesn’t have operators overloading.
This is why I cannot check if BigDecimal is less than zero in the normal way:
public something(BigDecimal price) {
if (price < 0) {
throw new IllegalArgumentException("Price cannot be less than 0");
}
}
Instead of the above simple code I just have to write this:
public something(BigDecimal price) {
if (price.compareTo(BigDecimal.ZERO) == -1) {
throw new IllegalArgumentException("Price cannot be less than 0");
}
}
This is a kind of a nightmare, why use the compareTo function which returns that cryptic -1, 0, 1 values? I really want to have operator overloading in Java. The code will be much simpler.
Btw: PostgreSQL has operator overloading.
Posted in database, programming.
Tagged with big decimal, java, operator overloading, operators.
By Simon
– June 27, 2011
Last time I wrote about the common problem with the random function. PostgreSQL has got only the random() function, no function like random(from, to) or random(length) which returns random text of given length.
This time I just need a function that returns a random text of given length which can be used like this: SELECT random_text(42). The random text will be used as a slug in a web application, so I need only numbers and letters, and let’s also uppercase all.
Let’s create a PL/pgSQL procedure for returning a random text with given length. Continued…
Posted in database, programming.
Tagged with database, linkedin, optimization, pl/pgsql, postgresql, programming, random, sql.
By Simon
– May 30, 2011
PostgreSQL 9.1 is almost out. That’s great. There are many nice features, so I will mention some most important for me:
1. Per column collation.
This is the feature I was waiting for a long time. I’ve written some entries about the problems with collation. Now all of them has gone… from now on the collaction can be set per column, domain, index or even expression. I’ve written some posts about the problems with collations in postgresql: postgresql collation part 1 postgresql collation part 2 postgresql collation 8.4. I think these problems will magically disappear in 9.1. Really cool. Continued…
Posted in database.
Tagged with database, postgresql, postgresql 9.1.
By Simon
– May 25, 2011

Intro
Some time ago I’ve written about the review of the Sphinx Search Beginner’s Guide from Packt Publishing. The review had to appear here much earlier, but I couldn’t find enough time for everything. Continued…
Posted in database, programming.
By Simon
– May 24, 2011
Last time I’ve written about some idea on storing application settings.
I’ve finished the first version. It is fully functional, although doesn’t have any inheritance yet.
The code is on github.
Posted in database, programming.
Tagged with database, programming.
By Simon
– May 19, 2011
Django Has ORM
I’ve started clicking a small Django application. It uses PostgreSQL (that’s obvious). My local PostgreSQL databases log all queries, so I’ve clicked a little bit and checked what queries were sent to database.
The whole application has a simple model with class Tag (for tags of course). I’ve configured that to show in the admin application. I’ve added two tags, deleted them… and the PostgreSQL log file filled with all sorts of strange lines.
Continued…
Posted in database, programming.
Tagged with database, django, postgresql.
By Simon
– May 2, 2011
There is a common problem with many homemade random functions. All languages that I know have some kind of
random() function. This function returns some floating point number within the range [0.0, 1.0) with normal distribution of values.
The generators can have different values distribution, but in this entry I will just write about normally distributed generator.
Continued…
Posted in database, programming.
Tagged with database, postgresql, sql, wtf.
By Simon
– April 28, 2011

I’ve already started writing a review of the book about Sphinx from Packt Publishing.
There also is a sample chapter available about the basics of running and configuring Sphinx.
The review will be published here as soon as I finish reading, I hope it will be next week.
Posted in programming.
Tagged with book, packt publishing.
By Simon
– April 9, 2011
The Problem
When you make an application, you usually need to store some settings. Usually applications are small and there is not much to configure. Usually it is made using files. Sometimes a bunch of files.
If you have many applications, you need to store a lot of configuration files. They can be stored in many places and sometimes you need to have the same setting in all files for all applications. Managing this could be a real headache.
Imagine a system where you have many servers with many applications on each. Each application brings its own config file. A very common task is to change one URL in the configuration for all applications at once. When you have many environments (like: testing, staging and production, to name only those) you could even not notice that there was some small application with old value in the configuration. Results of such a mistake could be really strange and hard to find.
Continued…
Posted in database, programming.
Tagged with application, architecture, database, postgresql, programming, settings.
By Simon
– March 22, 2011
This transaction has been open since July 2, 2001.
We call it "Edward."
Some time ago I was asked about long running transactions. Is that really so bad and how long should a transaction run? I will try to reply that question now, as it returns all the time. The answer is not so trivial, as usually when you ask about databases.
Continued…
Posted in database.
Tagged with database, postgresql.
By Simon
– February 28, 2011