# How to create ISO Date String

It is a more and more common task that we need to have a date or maybe date with time as String.

There are two reasonable ways to do this:
* We may want the date formatted in the users Locale, whatever that is.
* We want to use a generic date format, that is for a broader audience or for usage in data exchange formats, log files etc.

The first issue is interesting, because it is not always trivial to teach the software to get the right locale and to use it properly… The mechanisms are there and they are often used correctly, but more often this is just working fine for the locale that the software developers where asked to support.

So now the question is, how do we get the ISO-date of today in different environments.

## Linux/Unix-Shell (bash, tcsh, …)

date "+%F"

## TeX/LaTeX

 \def\dayiso{\ifcase\day \or 01\or 02\or 03\or 04\or 05\or 06\or 07\or 08\or 09\or 10\or% 1..10 11\or 12\or 13\or 14\or 15\or 16\or 17\or 18\or 19\or 20\or% 11..20 21\or 22\or 23\or 24\or 25\or 26\or 27\or 28\or 29\or 30\or% 21..30 31\fi} \def\monthiso{\ifcase\month \or 01\or 02\or 03\or 04\or 05\or 06\or 07\or 08\or 09\or 10\or 11\or 12\fi} \def\dateiso{\def\today{\number\year-\monthiso-\dayiso}} \def\todayiso{\number\year-\monthiso-\dayiso} 
This can go into a file isodate.sty which can then be included by \include or \input Then using \todayiso in your TeX document will use the current date. To be more precise, it is the date when TeX or LaTeX is called to process the file. This is what I use for my paper letters.

## LaTeX

(From Fritz Zaucker, see his comment below):
 \usepackage{isodate} % load package \isodate % switch to ISO format \today % print date according to current format 

## Oracle

 SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD') FROM DUAL; 
On Oracle Docs this function is documented.
It can be chosen as a default using ALTER SESSION for the whole session. Or in SQL-developer it can be configured. Then it is ok to just call
 SELECT SYSDATE FROM DUAL; 

Btw. Oracle allows to add numbers to dates. These are days. Use fractions of a day to add hours or minutes.

## PostreSQL

(From Fritz Zaucker, see his comment):
 select current_date; —> 2016-01-08 
 select now(); —> 2016-01-08 14:37:55.701079+01 

## Emacs

In Emacs I like to have the current Date immediately:
 (defun insert-current-date () "inserts the current date" (interactive) (insert (let ((x (current-time-string))) (concat (substring x 20 24) "-" (cdr (assoc (substring x 4 7) cmode-month-alist)) "-" (let ((y (substring x 8 9))) (if (string= y " ") "0" y)) (substring x 9 10))))) (global-set-key [S-f5] 'insert-current-date) 
Pressing Shift-F5 will put the current date into the cursor position, mostly as if it had been typed.

## Emacs (better Variant)

(From Thomas, see his comment below):
 (defun insert-current-date () "Insert current date." (interactive) (insert (format-time-string "%Y-%m-%d"))) 

## Perl

In the Perl programming language we can use a command line call
 perl -e 'use POSIX qw/strftime/;print strftime("%F", localtime()), "\n"' 
or to use it in larger programms
 use POSIX qw/strftime/; my \$isodate_of_today = strftime("%F", localtime()); 
I am not sure, if this works on MS-Windows as well, but Linux-, Unix- and MacOS-X-users should see this working.

If someone has tried it on Windows, I will be interested to hear about it…
Maybe I will try it out myself…

## Perl 5 (second suggestion)

(From Fritz Zaucker, see his comment below):
 perl -e 'use DateTime; use 5.10.0; say DateTime->now->strftime(„%F“);‘ 

## Perl 6

(From Fritz Zaucker, see his comment below):
 say Date.today; 
or
 Date.today.say; 

## Ruby

This is even more elegant than Perl:
 ruby -e 'puts Time.new.strftime("%F")' 
will do it on the command line.
Or if you like to use it in your Ruby program, just use
 d = Time.new s = d.strftime("%F") 

Btw. like in Oracle SQL it is possible add numbers to this. In case of Ruby, you are adding seconds.

It is slightly confusing that Ruby has two different types, Date and Time. Not quite as confusing as Java, but still…
Time is ok for this purpose.

## C on Linux / Posix / Unix

 #include #include #include 

 main(int argc, char **argv) { 

 char s[12]; time_t seconds_since_1970 = time(NULL); struct tm local; struct tm gmt; localtime_r(&seconds_since_1970, &local); gmtime_r(&seconds_since_1970, &gmt); size_t l1 = strftime(s, 11, "%Y-%m-%d", &local); printf("local:\t%s\n", s); size_t l2 = strftime(s, 11, "%Y-%m-%d", &gmt); printf("gmt:\t%s\n", s); exit(0); } 
This speeks for itself..
But if you like to know: time() gets the seconds since 1970 as some kind of integer.
localtime_r or gmtime_r convert it into a structur, that has seconds, minutes etc as separate fields.
stftime formats it. Depending on your C it is also possible to use %F.

## Scala

 import java.util.Date import java.text.SimpleDateFormat ... val s : String = new SimpleDateFormat("YYYY-MM-dd").format(new Date()) 
This uses the ugly Java-7-libraries. We want to go to Java 8 or use Joda time and a wrapper for Scala.

## Java 7

 import java.util.Date import java.text.SimpleDateFormat

 

... String s = new SimpleDateFormat("YYYY-MM-dd").format(new Date()); 
Please observe that SimpleDateFormat is not thread safe. So do one of the following:
* initialize it each time with new
* make sure you run only single threaded, forever
* use EJB and have the format as instance variable in a stateless session bean
* protect it with synchronized
* protect it with locks
* make it a thread local variable

In Java 8 or Java 7 with Joda time this is better. And the toString()-method should have ISO8601 as default, but off course including the time part.

## Summary

This is quite easy to achieve in many environments.
I could provide more, but maybe I leave this to you in the comments section.
What could be interesting:
* better ways for the ones that I have provided
* other databases
* other editors (vim, sublime, eclipse, idea,…)
* Office packages (Libreoffice and MS-Office)
* C#
* F#
* Clojure
* C on MS-Windows
* Perl and Ruby on MS-Windows
* Java 8
* Scala using better libraries than the Java-7-library for this
* Java using better libraries than the Java-7-library for this
* C++
* PHP
* Python
* Cobol
* JavaScript
* …
If you provide a reasonable solution I will make it part of the article with a reference…

# What do +, – and * with Integer do?

When using integers in C, Java or Scala, we often use what is called int.

It is presented to us as the default.

And it is extremely fast.

Ruby uses by default arbitrary length integers.

But what do +, – and * mean?

We can rebuild them, in Ruby, kind of artificially restrict the integers to what we have in other programming langauges as int:

 MODULUS = 0x100000000; LIMIT   =  0x80000000;

 def normalize(x)   r = x % MODULUS;   if (r < -LIMIT) then     return r + MODULUS;   elsif (r >= LIMIT)      return r - MODULUS;   else     return r;   end end def intPlus(x, y)   normalize(x+y); end def intMinus(x, y)   normalize(x-y); end def intTimes(x, y)   normalize(x*y); end 

x = 0x7fffffff; y = intPlus(x, x); z = intPlus(x, x); puts("x=#{x} y=#{y} z=#{z}"); 

What is the outcome?

Exactly what you get when doing 32-Bit-Ints in C, Java, Scala or C#:
 x=2147483647 y=-2 z=-2 

int is always calculated modulo a power of two, usually . That is the
x % MODULUS  in normalize(). The Rest of the function is just for normalizing the result to the range .

So we silently get this kind of result when an overflow situation occurs, without any notice.
The overflow is not trivial to discover, but it can be done.
For addition I have described how to do it.

I gave a talk that included this content adapted for Scala at Scala Exchange 2015.

# Devoxx 2015

This year I have had the pleasure to visit the Devoxx-Conference in Antwerp in Belgium.

I have visited the following talks:

There is a lot to write about this and I will get back to specific interesting topics in the future…

My previous visits in 2012, 2013 (part 1), 2013 (part 2), and 2014 have their own blog articles.

# Java: Using Enums for Singletons

This singleton pattern is not really a big deal, but overused because it gives us the coolness of knowing about design patters without learning too much stuff for that… It does have its uses in some programming languages, while more or less implicit or obsolete in others, depending on the point of view.

I have already discussed the generalization of the singleton.
Actually it can be seen that the enum of Java and of languages who do something like Java’s enum in a similar way can be used as a way to build a singleton by just limiting it to one instance. Having been skeptical about this as an abuse of enums that might confuse people who read this I would now suggest to embrace this as a possible and useful way to write singletons and to be familiar with it when reading other people’s code or even to use it when writing code.

The enum way to write a singleton is the most elegant way in Java, because it uses least boiler plate code and includes some benefits that are usually ignored, especially when it comes to serialization that has to be addressed in singletons quite often, but is quite often ignored, resulting in multiple instances of the „singleton“ to float around…

So here we go:

 enum Singleton  {     INSTANCE;

     private long count;     private Singleton() {         count = 0;     } 

    public synchronized long nextValue() {         return count++;     } } 

Remarks:

• For real programs it would be important to check if long is sufficient or BigInteger is needed.
• For real programs using an AtomicLong could be a better way than using synchronized.

# Design Patterns: Singleton

Deutsch

This Singleton Pattern has the advantage to be easy to memorize.

The only really interesting aspect of it is the issue of initialization („lazy or „eager“) and maybe the dependencies between multiple singletons.

But I would like to mention two generalizations.

A Singleton exists once in the whole program. Generalizations can address the uniqueness in two ways. Either the number of instances can be increased from one to a small number or the universe („whole program“) can be changed. What is the universe in a big software system that is running on multiple servers with many processes and components?

Changing from one to a small fixed finite number is quite a routine thing. Java developers are calling this enum, but other programming language often have similar structures or at least allow to build them easily by restricting the generation of objects and creating the whole set of instances statically and making them accessible. I am not talking about the enum of C, C++ and C#.

The other, slightly more complex generalization looks at the „universe“. An application can be distributed and have several parallel processes, not only threads. This would mean dealing with a larger universe, which can become slightly tricky, but some examples of that are actually routine. Think of a database that exists once in the application to allow operating on the same data and keeping them consistent. Frameworks sometimes allow for an application server wide more or less classical singleton that exists once in the whole server landscape but can be accessed more or less transparently. An interesting case that is needed quite often is a global counter. It can be done using a DB-sequence. Or giving disjoint subsets of the numbers that could be generated to different processes and server. Or by using something like a UUID and praying that no collisions will occur. But an application wide singleton might be useful in some cases. Some frameworks are talking about a „bean“ with „application scope“. On the other hand smaller universes are even more useful. A typical example is the „session scope“.

Maybe just understanding these as a proper generalization of the singleton pattern will help in making these frameworks more understandable and more useful. The investment of having started with the most simple design pattern might actually pay off. Looking into some of the other patterns could be a worth while task for the future… 😉

# Using Collections

When Java came out about 20 years, it was great to have a decent and quite extensive collection library available as part of the standard setup and ready to use.

Before that we often had to develop our own or find one of many interesting collection libraries and when writing and using APIs it was not a good idea to rely on them as part of the API.

Since Java 2 (technical name „Java 1.2“) collection interfaces have been added and now the implementation is kind of detached, because we should use the interfaces as much as possible and make the implementation exchangeable.

An interesting question arose in conjunction with concurrency. The early Java 1 default collections where synchronized all the way. In Java 2 non synchronized variants were added and became the default. Synchronization can be achieved by wrapping them or by using the old collections (that do implement the interfaces as well since Java 2).

This was a performance improvement, because most of the time it is expensive and unnecessary overhead to synchronize collections. As a matter of fact special care should be used anyway to know who is accessing a collection in what way. Even if the collection itself does not get broken by simultaneous access, your application most likely is, unless you really know what you are doing. Are you?

Now it is usually a good idea to control changes of a collection. This is achieved by wrapping it with some Collections.umodifyableXXX-method. The result is that accessing the wrapped collection with set or put will cause an exception. It was a good approach, as a first shot, but not where we want to be now.

Of the wrapped collection still references to the inner, non-wrapped collection can be around, so it can still change while being accessed. If you can easily afford it, just copy collections when taking them in or giving them out. Or go immutable all the way and wrap your own in an umnodifiable-wrapper, if that works.

What I would like to see is something along the following lines:

• We have two kinds of collection interfaces, those that are immutable and those that are mutable.
• The immutable should be the default.
• We have implementations of the collections and construction facilities for the immutable collections
• The immutable implementation is off course the default.

I do not want to advocate going immutable collections only, because that does come at a high price in terms of efficiency. The usual pattern is to still have methods that modify a collection, but these leave the original collection as it is and just create a modified copy. Usually these implementations have been done in such a smart way that they share a lot, which is no pain, because they are all immutable. No matter how smart and admirable these tricks are, I strongly doubt that they can reach the performance of modifiable collections, if modifications are actually used a lot, at least in a purely single threaded environment.

Ruby has taken an interesting approach. Collections have a method freeze that can be called to make them immutable. That is adding runtime checks, which is a good match for Ruby. Java should check this at compile time, because it is so important. Having different interfaces would do that.

I recommend checking out the guava-collection library from google. It does come with most of the issues described here addressed and I think it is the best bet at the moment for that purpose. There are some other collection libraries to explore. Maybe one is actually better then guava.

# Find the next entry in a sequence

In Facebook, Xing, Google+, Vk.com, Linkedin and other of these social media networks we are often encountered with a trivial question like this:
 1->2 2->8 3->18 4->32 5->50 6->72 7->? 
There are some easy patterns. Either it is some polynomial formula or some trick with the digits.
But the point is, that any such sequence can easily be fullfilled by a polynomial formula. That means we can put any value for 7 and make it work. Or any answer is correct. So what would probably be the real question is the most simple function to full-fill the given constraints. Simplicity can be measured in some way… If the solution is unique is unclear, but let us just look at the polynomial solution.

A function is needed that takes as parameter a list of key-value-pairs (or a hash map) and that yields a function such that the function of any of the key is the associated value.

Assuming a polynomial function in one variable we can make use of the chinese remainder theorem, which can be applied to univariate polynomials over a field as well as to integral numbers. For a polynomial p(X) we have

where is the polynomial variable and is a concrete value.

We are looking for a polynomial such that for given values we have

or in another way

which is exactly the Chinese remainder theorem.
Let

and

We can see that for all the polynomials

have the properties

or

where is the Kronecker symbol, which is 0 if the two indices differ and 1 if they are equal.
Or as congruence:

Then we can just combine this and use

This can easily be written as a Ruby function
 def fun_calc(pairs)   n = pairs.size   result = lambda do |x|     y = 0     n.times do |i|       p_i = pairs[i]       x_i = p_i[0].to_r       y_i = p_i[1].to_r       z = y_i       n.times do |j|         if (j != i)           p_j = pairs[j]           x_j = p_j[0]           z *= (x - x_j) / (x_i - x_j)         end       end       y += z     end     y   end   result end 
This takes a list of pairs as a parameter and returns the polynomial function als lambda.
It can be used like this:
 lop = [[0, 0], [1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 64]]

 f = fun_calc(lop) 

20.times do |x|   y = f.call(x)   puts sprintf("%6d -> %6d", x, y) end 
Put this together into a ruby program and add some parsing for the list of pairs or change the program each time you use it and all these „difficult“ questions „that 99.9% fail to solve“ are not just easy, but actually soluble automatically.

This is interesting for more useful applications. I assume that there will always be situations where a function is needed that meets certain exact values a certain inputs and is an interpolation or extrapolation of this.

Please observe that there are other interesting and useful ways to approach this:

• Use a „best“ approximation from a set of functions, for example polynomials with a given maximum degree
• use cubic splines, which are cubic polynomials within each section between two neighboring input values such that at the input values the two adjacent functions have the same value (, of course), the same first derivative and the same second derivative.

For highway and railroad construction other curves are used, because the splines are making an assumption on what is the -axis and what is the -axis, which does not make sense for transport facilities. They are using a curve called Clothoid.

Use Java, C, Perl, Scala, F# or the programming language of your choice to do this. You only need Closures, which are available in Java 8, F#, Scala, Perl, Ruby and any decent Lisp dialect. In Java 7 they can be done with an additional interface as anonymous inner classes. And for C it has been described in this blog how to do closures.

# Testing Java- and C-programs with Ruby and Perl

It is very important to write good unit tests for software that is non-trivial and that is relied on by other pieces of software.
Often the logic of the software can easily be covered by the native testing facilities of the programming language, like JUnit for Java or, much less well known but available, CUnit for C. When a lot of framework code is involved or third party libraries are used heavily, there is almost no other way for certain tests, because setting up the environment cannot easily be achieved elsewhere.

But we also encounter cases where writing good unit tests in the same language as the library itself becomes a pain. We procrastinate the issue of writing them and end up with way too little or no unit tests at all. A lot of software deals with doing some calculations or transformations of numbers and strings, usually a lot of numbers and a lot of strings. Now Strings are the strength of the Perl programming language and are not really implemented very well or at least not very powerful or easy to use in most other languages. Specifically the String facilities of Perl are much superior to those of Java and C. Off course our software needs to perform well, it needs to integrate into the environment and follow the global corporate software standards, so Java or C or some other programming language is the choice that should not be challenged here for the productive software. But some tests of the functionality can more easily be achieved by iterating over some input data and creating output of the input data combined with the results. This can be perl code already or something really easy to parse. Perl is really the tool that can parse almost anything, but we do not really want to be distracted by unnecessary work but get our job done. So something like generating Perl code or CSV or YAML or JSON, but please not XML if not really needed, should do. Then we can pipe the output to perl or to a perl script and this will tell us, if everything is ok. When we know our platform, it can even be done that the Java- or C-Unit-test stores the output to a file or pipe and calls the Perl script on it and fails or succeeds depending on its output.

When it comes to numeric types, Ruby is very strong. It has unlimited size integers by default, which can be casted to n-bit-integers using constructions like
xx=x&(1<<n)-1,
it has Rational, LongDecimal (as an external gem) and Complex and is easily extendible.

Usually we can expect that corporate constraints on which tools and programming languages may be used are less restrictive when it comes to unit tests. Integrating this on a continuous integration platform is a job that needs to be addressed but it is worth the effort, if a lot of tests become easier with this approach. And doing tests in another language makes tests more credible.

Off course the general idea is applicable for other combinations. Look into Scala, F#, Clojure, JavaScript, Python and some others as well, if they seem to be more helpful than Ruby or Perl for your unit testing automation. But this does indeed raise the question if a world where corporate policies allowed Scala and Closure instead of Java, F# instead of C# and Elixir instead of Erlang and PL/I instead of Cobol would be better.

# Residue Class Rounding

Deutsch

If you do not know what residue classes are, just read on, it will be explained to the extent needed later on.

The concept of rounding seems familiar, but let us try to grab it a little bit more systematically.

Let us assume a set of numbers and a subset of it, whose elements can be represented in the programming or software environment we are having in mind. We want to use a metric . Usually we have three requirements for :

• Identity of indiscernibles:
• Symmetry:
• Triangular inquation:

Usually the number that we are dealing with can be considered to be within the world of real or complex numbers, we can hence assume that , often even or if we are honest . Then we are usually working with , which is kind of implicitly clear. If you do not know complex numbers, just think of real or even rational numbers, which is the most common case anyway. Off course the concepts for rounding of -adic numbers are really interesting and beautiful, but since I do not want to explain -adic numbers here, I will not extend on this issue.

What is our intuitive understanding of rounding?
Maybe just a map
,
that is chosen with certain constraints for each x in such a way that is minimal.
We need the constraints to enforce uniqueness if multiple values with minimal exist. The classical case of rounding to integral numbers has to answer the question of how to round . If is a subset of the real numbers, which is „usually“ the case, we have ordering. We can choose between the following constraints:

ROUND_UP
Z.B. and and
ROUND_DOWN
Z.B. and and
ROUND_CEILING
Z.B. and and
ROUND_FLOOR
Z.B. and and
ROUND_HALF_UP
Minimize , but if multiple optimal values exist for , pick the one furthest away from 0, for example and and and
ROUND_HALF_DOWN
Minimize , but if multiple optimal values exist for , pick the one closest to 0, for example and and and
ROUND_HALF_CEILING
Minimize , but if multiple optimal values exist for , pick the largest, for example and and and
ROUND_HALF_FLOOR
Minimize , but if multiple optimal values exist for , pick the smallest, for example and and and
ROUND_HALF_EVEN
Minimize , but if multiple optimal values exist for , pick the one with even last digit. Please observe that this constraint is useful in the classical case, but it cannot be generalized. For example: and and and and
ROUND_UNNECESSARY
This constraint does not work in the mathematical sense (or only with ugly abusive math formulas), but programmatically we can do that: We try and throw an exception if not .

Usually we are thinking in the decimal system (even though our computers prefer something else, but the computer should serve us and not vice versa..). So we pick a power of ten with , so . Now we simply define
,
which means that contains all numbers of with a maximum of digits after the decimal point. This rounding works quite well with something like LongDecimal in Ruby or BigDecimal in Scala or Java, but BigDecimal offers fewer rounding modes than LongDecimal for Ruby.

Now we look at the residue class rounding. We assume such a power of ten . Then we need an integral number and a set of numbers , we call them residues. Now we define .
That means that if we fill the number with zeros to the given number of places after the decimal point, remove the decimal point and perform a division with residue of this number by , the residue lies in . In this case ROUND_HALF_EVEN can become difficult to implement and ambiguous, so we might need to sacrifice it. But even worse, we have to deal with the case that 0 is not in and provide rules how to round 0. The candidates have self-explanatory names:

• ZERO_ROUND_TO_PLUS
• ZERO_ROUND_TO_MINUS
• ZERO_ROUND_TO_CLOSEST_PREFER_PLUS
• ZERO_ROUND_TO_CLOSEST_PREFER_MINUS
• ZERO_ROUND_UNNECESSARY

An important application of this is and . This is used in Switzerland and probably other currency regions for rounding money amounts to multiples of 5 Rappen (0.05 CHF). This has already been described in „Rounding of Money Amounts„. If we have and we have the usual non-CHF-rounding case. Maybe there are even cases for and . But the concept is more general, if you like to use it.

# Devoxx 2014 in Belgium

In 2014 I have visited the Devoxx conference in Antwerp in Belgium.

Here are some notes about it:

# What is Devoxx?

• Devoxx ist a conference organized by the Belgian Java User Group.
• Belgium is trilingual (French, Flemish and German), but the conference is 100% in English.
• The location is a huge cinema complex, which guarantees for great sound, comfortable seats and excellent projectors. It is cool.
• 8 tracks, overflow for keynotes
• Well organized (at least this year), more fun than other conferences…
• sister conferences:
• Devoxx FR
• Devoxx PL
• Devoxx UK
• Voxxed (Berlin, Ticino,….)

• Java / Oracle
• Android / Oracle
• Startups, Business, IT in enterprises / ING-Bank
• Java-Server, JBoss, Deployment / Redhat
• JVM-languages
• Web
• SW-Architecture
• Security
• Whatever roughly fits into these lines and is considered worth being talked about by the speaker and the organizers…

These are some of the talks that I have attended:

# Scala and Java8

• Many conceptional features of Scala have become available in Java 8 with lambdas.
• Problem: different implementation and interoperability between Java and Scala.
• Development of Scala will make lambdas of Scala and Java interoperabel.

• Concept from category theory. (5% of mathematicians do algebra, 5% of algebraians do category theory, but this very abstract and very theoretical piece of math suddenly becomes interesting for functional programming. Off course our functional programming world lacks the degree of infiniteness that justifies the theory at all, but concepts can be applied anyway)
• Monoid (+, *, concat,…)
• Functor
Wikipedia
• Wikipedia de

• example: List with a functor
is flatten: ;

# Probability & Decisions

• Example: Software for automatic steering of house infrastructure
• Heuristics and probability theory
• False positives / false negatives: what hurts? (usually both)
• Very good explanation of probability theory and its use

# Clojure

• Clojure is another JVM-language
• It is a Lisp-Dialekt, recognizable by its source having an abundance of opening and closing parentheses: (+ (* 3 4) (* 5 6))…
• strong support for functional programming.
• Dynamically typed (for us: Just think of everything being declared as „Object“ and implicit casts being performed prior to method calls.
• After Java itself, Scala, Groovy and Javascript it appears to me to be the fifth most common JVM-language

# MapReduce

• „No one at Google uses MapReduce anymore“
• Google has replaced it with more general and more performance sensitive concepts and implementations.
• Optimized: save steps, combine them etc.
• Can be used as cloud service (Cloud Dataflow)

# Key Note ING

• ING considers itself to be an „open bank“
• Not the money is lieing around openly for burglers to play with it, but they claim to be open for new ideas.
• Mobile app is the typical interface to the bank.
• IT has a lot of influence („IT driven business“)
• Feasability from the IT side is considered important
• Agile Prozesses (Scrum) vs. Enterprise IT
• IT has slowly moved to these agile processes.
• „Enterprise IT is what does not work“

# Material Design

• GUI-Design with Android and Web Material Design
• Visual ideas available for both platforms
• Polymer design for Web

# SW-Architecture with Spring

• Spring 4.1
• „works with WebSphere“
• DRY
• Lambda from Java8 can simplify many APIs out of the box by just replacing one-method anonymous and inner classes.
• Generic Messaging Interface (wasn’t JMS that already???)
• Caching, be careful when testing, but can be disabled.
• Test on start.spring.io
• Spring works well with Java. Also with Groovy, which comes from the same shop as spring. Combination with Scala „experimental“

# Lambda_behave

• High-Level testing-Framework
• Uses Java8-Features (Lambda etc.)
• Description in natural language.
• Like Cucumber…
• Source of randomness can be configured. This is very important for monte-carlo-testing, simulations and the like.

# Builtin Types of Scala and Java

• In Java we find „primitive types“ (long, int, byte, char, short, double,…)
• Probleme with arithmetic with int, long & Co: Overflow happens unnoticed
• With float and double Rounding errors
• With BigInteger, BigDecimal, Complex, Rational error prone, clumpsy and unreadable syntax.
• In Scala we can write a=b*c+d*e even for newly defined numerical types.
• Remark: Oracle-Java-guys seem to consider the idea of operator overloading for numerical types more interesting than before, as long as it is not used for multiplying exceptions with collections and the like.
• Spire library

# Future of Java (9, 10, …)

## Part I

• Numerical types are in issue. That primitive types behave as they do and are kind of the default won’t change.
• Generics and type erasure (where is the problem)?
• Jigsaw vs. Jars vs. OSGi still open how that will fit together, but jar is there to stay.
• Jigsaw repository: Could well be located with maven central. Oracle does not work in such a way that this being hosted directly by Oracle is likely to happen, if third party software is there as well.

## Part II

• Benchmarking with Java is hard because of hot spot optimization
• JMH is a good tool
• New ideas are always hard to introduce because of the requirement of remaining compatible with old versions.
• Java might get a „repl“ some day, like irb for Ruby…

## Part III

• Collection literals (promised once for Java 7!!!) did not make it into Java 8, unlikely for Java 9
• With upcoming value types this might be more reasonable to find a clean way for doing that.
• For Set and List somthing like
new TreeSet(Arrays.asList(m1, m2, m3,…., mn))
• For maps something like a pair would be useful. Tuples should come and they should be based on value types. The rest remains as an exercise for the reader.

## Part IV

• Tail-Recursion can now be optimized in an upcoming version.
• Because of the security-manager, that analyzed stacktraces this was impossible for a long time. (weird!!!)
• C and Lisp have been doing this for decades now…
• Statement: Generics are hard, but having understood them once they become easy. So keep trying….
• Covarianz und Contravarianz (Bei Array falsch gelöst)

## Part V

• Arrays 2.0: indexing with long could become an issue. Some steps towards list, but with array syntax. (studies and papers only)
• Lists have two extreme implementations: ArrayList and LinkedList. We would love to see more „sophisticated“ Lists, maybe some hybrid of both
• Checked exceptions: critical issue, it was a problem with generics and lambda. And way too many exceptions are checked, just think of whatever close()-methods can throw, that should not be checked.

# Semantic source code analysis

• Useful for high level testing tools
• Static and dynamic analysis
• Dataflow analysis: unchecked data from outside, think of SQL-injection, but also CSS, HTML, JavaScript, JVM languages and byte code

# Functional ideas in Java

Functional:

• Functions or methods are „first class citizens“
• Higher order functions (C could that already)
• Closures
• Immutability (function always returns the same result)
• „lazy“-constructions can be possible though
• For big structures we always have the question of immutability vs. performance
• But functional is much more thread-friendly

# 50 new things in Java8

## Part I

• Lambda (see below)
• Streams (see below)
• Default implementations in interfaces
• Date/Time (loke Joda time)
• Optional (better than null)
• Libraries can work with lambda
• Parallel (use with care and only when needed and useful)

## Part II

• String.join()
• Something like „find“ in Unix/Linux
• Writing comparators is much easier
• Maps of Maps, Maps of Collections easier
• Sorting is better: quicksort instead of mergesort, can be parallelized

# Groovy for Android

• Problem with JVM languages other than Java: library has to be included in each app. 🙁
• Solution: jar optimization tool helps
• Second problem: dynamic languages have to be compiled on demand on the device
• Solution: „static“ programming, dynamic features possible but not performing well

# Lambdas

• Lambdas are anonymous functions
• Idea given: interface XY with one method uvw()
 XY xy = new XY() { public long uvw(long x) { return x*x } }; 
new
XY xy = x -> x*x;
• shorter, more readable, easier to maintain, interface becomes superfluous in many cases.
• Closure means that final variables from the surrounding context can be included
• Instance methods can be seen as closures also, the include the instance in a closure like way.

# Streams

• Streams are somewhere in the vicinity of Collection, Iterable, Iterator and the like, but something new.
• They have methods that allow a function to be applied on all elements
• Elegant for programming stuff like
• Sum
• Product
• Maximum
• Minimum
• First / last / any element with certain property
• all elements with a certain property
• all transformed Elements…
• It turns out to be a wise decision to make it different from Iterable, Iterator, Collection,… and rather provide wrapping capabilities where needed.