GitHub How to Java EE

New app

checkout my new app under development:


Must read: Java interfaces

When client code interacts with names, it will invoke those methods that are declared by List, and which are implemented by ArrayList.

Java EE JAVA SE JavaScript My Project Spring framework

Action time: Let’s start some project

Dear readers and me, I’ve decided that I should start developing my own application. Only this action can justify my accumulation of knowledge. Therefore, let’s decide on couple things:

  1. Frontend: jQuery, AJAX and JavaScript
  2. Backend: Spring framework

As for app idea, I’ve decided that I will be making clone of project which I’m working on now. But I won’t reuse any materials from it, only the knowledge I’ve acquired. I want my project to be opensource so all the codes will be available on my GitHub account. The link I will put once I got anything to show.

Thank you.

Good programming practice Java EE

For the better Enterprise solutions!

I’ve decided to slightly divert from my Java SE certification preparation and research more about Spring framework. SF is chosen because it fits to be enterprise engine and it’s has good support among the developers. Beside that Oracle is borrowed the concept of Dependency injection from the Spring and implemented it in it’s own EJB.

Since I’m looking for job now, I might as well start building the web app on SF so that I can show the working prototype to employers.

I’ve completed couple spring started guides and uploaded one to the cloud:

My other rest services, not Spring though:

Rest Post service via Jersey:

Rest Get service that returns JSON via Jackson and data taken using Hibernate:


Good programming practice Java EE JAVA SE

Static method and static variable

In Java, static denotes class methods and class variables (as opposed to instance methods and instance variables). These methods and variables can be accessed without an instance present.

Contrast this to instance methods and instance variables: they must be accessed through an object. For example, length() operates on an object:

In contrast, valueOf cannot operate on an object; moreover, it creates a new object when called:

Note how instance methods are called using <objectName> followed by a dot ., while static methods are accessed using <className> followed by a dot ..

Good programming practice How to Java EE JAVA SE

JUnit: Unit Testing

JUnit is used for unit testing. The unit testing is one of the testing methodologies that tests module or method that was written.

Writing the test is done by creating normal java class, except we use special annotations for it.

Note: best practice in unit testing is to have multiple tests for single method.

Let’s say you have method calculateMinAge(), it’s good idea to create multiple test methods

Unlike other java classes, JUnit test class has different structure:

@Suit or @TestRetention <– this annotation helps to include the current class file into larger test group, containing other test files

@Before <– this annotation can be used to initialize the objects that are used in different methods. Also the method name should be called setUp(). Ex:


public void setUp(){}



Good programming practice How to Java EE JAVA SE

Inline If statement

In order to save the lines of code instead of using the typical if else we can use inline if statment:

skeleton is (a condition b ? do this() : do that())



(a>3 ? peal() : leave())

In above example a will be checked if it’s bigger than 3 if so run peal() if not run leave()


getAge(a>3 ? a=10: null)

in above example if a more than 3 then a will be assigned to 10 if not then get will run with value null.

Good programming practice How to Java EE JAVA SE

Conflict merging

In case of conflicts,

1. copy Current changes from Right to left
2. right click on the file, Mark as merged.

Data persistance Java EE

JPA: Difference between the createQuery vs createNamedQuery

Good programming practice Java EE JAVA SE Uncategorized

Static method

One rule-of-thumb: ask yourself “does it make sense to call this method, even if no Obj has been constructed yet?” If so, it should definitely be static.

So in a class Car you might have a method double convertMpgToKpl(double mpg) which would be static, because one might want to know what 35mpg converts to, even if nobody has ever built a Car. But void setMileage(double mpg) (which sets the efficiency of one particular Car) can’t be static since it’s inconceivable to call the method before any Car has been constructed.