Artem's blog

Thoughts on software


What do we want from log. Logging with SLF4J, logback and guice

Why do we need logging Yes, really, why do we need it in a first place? Usually we use logging for the what drug is similar to reglan viagra sold in usa escrow pharmacy viagrasamplesonline codeine promethazine syrup buy online primatene mist order from canada zoloft without insurance amoxil 500mg dosage xenical […]

, , , ,

What to do with InterruptedException in Java

Let’s discuss what you can do about annoying InterruptedException. In many situations you’d have a lot of methods like someOtherMethod() below, where you’d want to preserve it’s signature clear. Or, you call goes through 3-rd party interfaces which do not throw InterruptedException. What do you do? First of all you have to know what kind […]


Tetris for Android

I recently wrote a Tetris game for Android platform. Here it is: It is just a strait classical implementation of the Tetris. I shows drop position, next figure, increase speed with levels (up to 20), calculate score giving bonus for extra lines. And it saves score into phone’s memory, so you can keep track of […]

, ,

Why do I need inheritance in OOP? Real-world examples.

The problem in general is that it is sometimes unclear from books why do we need some particular technology. In this case we are going to discuss why do you need inheritance and where it is used in real-life applications. Let us at first remind what is inheritance (samples in Java):  Java |  copy code |? 1 public class Pet […]

, ,

Break and continue statements will stop exception flow

As it is said in The Java Language Specification ( “The preceding descriptions say “attempts to transfer control” rather than just “transfers control” because if there are any try statements within the break target whose try blocks contain the break statement, then any finally clauses of those try statements are executed, in order, innermost to […]

, , , ,

How to access overridden methods of superclass of a superclass in Java?

Let us consider an example: public class Test2 { static class TestClass1 { int x = 1; String test() { return “1”; } } static class TestClass2 extends TestClass1 { int x = 2; String test() { return “2”; } } static class TestClass3 extends TestClass2 { int x = 3; int testX() { return […]

, , , , , ,

Some approach for writing equials() and hashCode()

The problem described in details in The problem is that if we implement equals()/hashCode() as comparison and hashCode() of entity’s ids (see then the hashCode() (and, possibly, equals()) will change after saving entities if ids are generated by DB. To solve this issue I can suggest to use inner classes with equals()/hashCode(). It […]

, , , , ,

Algorithm for generating serialVersionUID for java entities

Here is some way of generating serialVersionUID for java entities. It is stable in sense that it depends only on your schema, not JVM/time or date of creation. On the other hand it depends on all fields in entity. If we have next n fields: typeName_1 fieldName_1; typeName_2 fieldName_2; … typeName_n fieldName_n;we could calculate serialVersionUID […]

, ,

Get rid of your nested if operators!

Every one of you know how it is disappointing that you can not use switch operators with strings, doubles, your custom objects, etc. But anyway sometimes it is possible to get rid of your nested ifs if you will use static maps. Let us consider an example: here we need to set JavaBean properties of […]