add Factory Pattern - java, python