Home » Author Archives: Peter Verhas

Author Archives: Peter Verhas

Generics Names

java-logo

Generics type parameter names usually contain one, single capital case character. If you start to read the official ORACLE documentation on generics the first example is /** * Generic version of the Box class. * @param <T> the type of the value being boxed */ public class Box<T> { // T stands for "Type" private T t; public void set(T ...

Read More »

Using Junit Test Name

junit-logo

Name your tests When we create Junit test usually there is no practical use of the name of the method. The Junit runner uses reflection to discover the test methods and since version 4 you are not restricted to start the name of the method with test anymore. The name of the test methods are there for documentation purpose. There ...

Read More »

Break Single Responsibility Principle

software-development-2-logo

Single Responsibility Principle (SRP) is not absolute. It exists to help the code maintainability and readability. But from time to time you may see solutions, patterns that break the SRP and are kind of OK. This is also true for other principles, but this time I would like to talk about SRP. Singleton breaks SRP The oldest and simplest pattern ...

Read More »

The Magic Setter Antipattern

java-logo

Setters and getter are evil. When the JavaBean definition was created it seemed to be a good idea. But they do a lot of harm to the Java community. Not as many as the null pointer generally, but enough. The very first thing is that many juniors believe that implementing setters and getter (hey, it is just a few click ...

Read More »

Quick, Cheap, Quality: choose two

software-development-2-logo

It is old and common wisdom. Even printed on billboard of the mechanics shop where my car is usually repaired. And as with many well known facts: they are ignored many times. Although his is a wider issue, and many statements I am going to make in this article is valid for other industries, I will focus on IT and ...

Read More »

Using junit for something else

junit-logo

junit != unit test Junit is the Java unit testing framework. We use it for unit testing usually, but many times we use it to execute integration tests as well. The major difference is that unit tests test individual units, while integration tests test how the different classes work together. This way integration tests cover longer execution chain. This means ...

Read More »

Default methods and multiple inheritance

java-logo

Recently Lukas JOOQ Eder posted and article about nested classes and their use. This is an interesting topic and his article is, as always, interesting and worth reading. There was only one slight statement I could not agree with and we had a brief reply chain leading to default method and why there can not be something like     ...

Read More »

Do not unit test bugs

java-logo

Before getting to the topic of the title let’s have a simple programming sample. On the programming task I will demonstrate some bad coding style and based on that it will be easier for me to explain why the same style is bad in unit tests. Well, now that I wrote this sentence this seems to be a obvious statement. ...

Read More »

Calling grandparent methods in Java: you can not

java-logo

In the article Fine points of protection I detailed how “protected” extends the “package private” access. There I wrote: What you can do is Override the method in the child class or call the parents method using the keyword super. And generally this is really all you can do with protected methods.   (Note that in this article I talk ...

Read More »

Fine points of protection

java-logo

In the article Some Sentences about Java I wrote that “Protected methods and fields can be used from classes in the same package (so far the same as package private) and in addition to that it can be used from other classes that extend the class containing the protected field or method.” Although the statement above is true it may ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close