An overview of REST

REST is maybe the most wrongly used word within the web world. It has became synonym with any sort of API that can be used of HTTP. As this frustrates me sometimes I will try to explain what REST is about and it is very simple and elegant in the basis.

REST stands for Representational State Transfer and is an architectural style to connect multiple components with each other. It defines some constraints to which a RESTful api should adhere. The constraints will be explained below:
Continue reading An overview of REST

Type safety

Consider the method findByDate that executes a query to find something by the year and month. One way of implementing this method in Java can be with two parameters year & month, both of type int. But this has some problems with passing valid arguments to methods and statically type checking.

public function findByDate(int year, int month) {
  // do stuff

Continue reading Type safety

MySQL regular expressions

Just found out MySQL can also use regular expression in the WHERE and I used it to match all valid URL’s and to find invalid URL’s.

To find all rows that match the regular expression

SELECT * FROM campaign
WHERE url REGEXP "^((https?|ftp)://|(www|ftp)\.)[a-z0-9-]+(\.[a-z0-9-]+)+([/?].*)?$";

To find all rows that not match the regular expression

SELECT * FROM campaign 
WHERE url NOT REGEXP "^((https?|ftp)://|(www|ftp)\.)[a-z0-9-]+(\.[a-z0-9-]+)+([/?].*)?$";