---
title: "Comment by Shai Almog on \"A new way to construct objects in Java\" | Hashnode"
description: "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:"
url: "https://hashnode.com/posts/a-new-way-to-construct-objects-in-java/61961e0890fac127e6ea5f22/comment/619644750b25eb28701f5f4a"
---

[Discussion](https://hashnode.com/posts/a-new-way-to-construct-objects-in-java/61961e0890fac127e6ea5f22)

Comment [A new way to construct objects in Java](https://hashnode.com/posts/a-new-way-to-construct-objects-in-java/61961e0890fac127e6ea5f22)

[Shai Almog](https://hashnode.com/@talktotheduck)

[Nov 18, 2021](https://hashnode.com/posts/a-new-way-to-construct-objects-in-java/61961e0890fac127e6ea5f22/comment/619644750b25eb28701f5f4a)

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](https://www.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");
```

[Nam Bach](https://hashnode.com/@nambach)

[Nov 19, 2021](https://hashnode.com/posts/a-new-way-to-construct-objects-in-java/61961e0890fac127e6ea5f22/comment/619644750b25eb28701f5f4a#reply-6196fff9db238d58f5e23c4d)

Thanks for your comment, that looks great!
