189. Refactoring code to add lambda laziness
In this problem, let’s have a refactoring session designed to transform a dysfunctional code into a functional one. We start from the following given code – a simple piece of class mapping information about application dependencies:
public class ApplicationDependency {
private final long id;
private final String name;
private String dependencies;
public ApplicationDependency(long id, String name) {
this.id = id;
this.name = name;
}
public long getId() {
return id;
}
public String getName() {
return name;
}
public String getDependencies() {
return dependencies;
}
private void downloadDependencies() {
dependencies = "list of dependencies
downloaded from repository " + Math.random();
}
}
Why did we highlight the getDependencies()
method? Because this is the point in the application where there is dysfunction. More precisely...