Declarative programming brings many huge benefits: ease in maintainability, scalability, readability. Java is heavily designed in OOP, an imperative paradigm, which seems impossible to be declarative. However, in this article, I will show how to achi...
nambach.hashnode.dev5 min read
I solved this a bit differently with property objects in Codename One. The core idea was to eliminate getters/setters and use general purpose property objects: codenameone.com/blog/properties-are-amazing.html
So the code would be:
public class Book implements PropertyBusinessObject {
public final Property<Book, String> isbn = new Property<>("isbn");
public final Property<Book, String> title = new Property<>("title");
public final Property<Book, String> author = new Property<>("author");
}
Notice I need the string names since code in Codename One is often obfuscated and I want runtime information.
Then we can create a book with a factory like this:
Book b = new Book()
.author.set("Shai Almog")
.title.set("Create an Uber Clone in 7 Days");
Mukund Madhav
Software Engineer - React JS and Spring for Java
Really interesting idea of mimicking Lambok. Will try this one.