Dave Thomas on what is wrong with current programming.

Dave Thomas Interview . Insights on what is wrong with current programming
http://www.drdobbs.com/architecture-and-design/dave-thomas-interview-the-corruption-of/240166688?pgno=3 

A pearl that I really recommend together with The tragedy of Craftsmanship.

and The Coming Software Apocalypse .

This last one is a podcast for the more technical oriented ones: Combating Complexity: Fad, Fashion, and Failure in Software Development

JMH alternatives : REPL time, linux perf

Expanding on previous articles about measuring with JMH

Besides using the calls to System nanoseconds and millis …
There exist some tools for a quick feedback about the performance of your java JVM code.

ON ALL JVM
You can use the time command in the REPL
class Nothing {
public static void main(String[] args) {
}
}

Compile with:
> javac Nothing.java

and run:

> time java Nothing

real 0m0.104s
user 0m0.079s
sys 0m0.019s

ON LINUX UNIX
It is better to use perf then. You can run the command several times. You can also choose among many different categories of statistics. You need to be root.This is an example which runs the program 100 times:

sudo perf stat -e cpu-clock -r50 java HeeloWorld
Hello World! # printed 100x

Performance counter stats for ‘java HeeloWorld’ (100 runs):

190.546723 cpu-clock (msec) # 0.992 CPUs utilized ( +- 0.91% )

0.265467836 seconds time elapsed ( +- 1.49% )

Automatically generate java backend and rest api from existing database. Part 2

Expanding on the previous subject about the generation of a back-end and rest API from existing database .

  • Netbeans has a generate entities from database script
  • Jeddict  . This could be already be pre-installed in some Netbeans products
  • Dali persistence tools from Eclipse
  • Hibernate Tools

Jipster offers the on line tool JDL-studio: there you can visually create tables and relationships. Entities generation from database is only available with an external tool. Beware of some cumbersome issues.

 

Last and most important: your good SQL database may be able to generate the text of the most important queries towards you database. Look at PostgreSql . Their pgAdmin toll has many features like these for generating things.

 

 

Gerrit shortcomings

Yes one of the teams uses Gerrit.

They are completely stuck.

Developers are sensing this tool as a impediment to deliver code and participate in the building of the software.

It has happened that there is always only one person that is reviewing code: the least experienced one! Gerrit Code reviews are just toys  for children , there is no improvement in the code, people is afraid to work with it .

This small team also needs a person dedicated 50% of her time to fixing Gerrit , its installation and its environment.

As a temporary solution we have allowed that the most expert developer makes formal code reviews by passing Gerrit.

Gerrit is the wrong solution for truly agile software development

 

 

Autovalue and Eclipse = success

I needed to add the folder target\…\generated_sources amon the src folders..

That was all what was needed .

Neither enablig maven annotation processor in eclipse project, installing of apt plugin  or the following snippet in pom were needed:

<annotationProcessors> <annotationProcessor>com.google.auto.value.processor.AutoValueProcessor</annotationProcessor>

</annotationProcessors–>

Introduction to Java 8

Are you new to Java?
Are you coming back to programming after a long pause?
Good!
It is the best way to enjoy Java 8 .
Forget all the old Java things and jump directly to Java 8.
I was skeptical about it , but I realize that Java 8 is a great thing.

Here we come to some reading advice:

  • General book about Java SE 8

The best available book is Horstmann – Java SE 8 for the Really Impatient (2014) .

  • About error and exception handling

My advice is to read 7 Error Handling by Michael Feathers in the book “Clean Code A Handbook of Agile Software Craftsmanship”. The author as a voice interview online as well.

Bidirectional traversing with ListIterator

Do you need a bidirectional way to skip through a list?

A rewind – forward behavior?

Traversing the list in one way and then in the opposite direction?

The Java ListIterator in the java.util package is here ready made to your help.

An iterator for lists that allows the programmer to traverse the list in either direction.

The previous() and hasPrevious() methods are available in this class and will make the trick.

You can build a ‘media tape’ behaviour on top of it.

 

It has some loose relationships with the Elevator Algorithm used for seeking a disk in its most simplest implementation strategy, the FCFS, First Come First Served. I used this one before for other purposes than seeking a disk.

ArrayList algorithm complexity, performance and gotchas

This piece of advice is about the Java ArrayList and LinkedList. It is not a insight about a general not specified List algorithm.

ArrayList is a random access data store.

LinkedList is sequential access data store.

There are these very important performance issues to know:

  • Remove: ArrayList remove(E ) is painful slow. Please consider LinkedList if this operation is used often in your application. Also the ArrayList positional remove(index) is painful bad. These operations require constant-time in a LinkedList and linear-time in an ArrayList. (*)
  • Use ArrayList constructor that take a size argument. You can measure by your self the defference when using large lists.
  • List Interface : Iterating over the elements in a list is preferable to indexing through it if the caller does not know the implementation.
  • Remember that you have the method addAll() for bulk operations.
  • Add positional add(index) is painful O(n) on ArrayList and O(1) in LinkedList (*)
  • Set positional set(index) is painful O(n) on LinkedList and O(1) in ArrayList   (*)

(*) Also the outline of the Collections Framework states that LinkedList is better than ArrayList for accessing in the middle of the list.

Also:

Do not do this:

 int a1[] = { -23, 12, 21 };
 
for (int v : a1)
           myarraylist.add(new Integer(v));

prefer this instead:

myarrayList.addAll(Arrays.asList(23,12,21)

Also

Arrays.asList

for translating arrays to strings is obsolete. Use this instead:

System.out.println(Arrays.toString(myArray));