Learning design pattern and algorithm in Java