jmulford-bw / Java-V2-Messaging-SDK

0 stars 1 forks source link

use Immutables for models #7

Open fuchsnj opened 5 years ago

fuchsnj commented 5 years ago

Immutables gives you a nice builder pattern, and automatically generates the code for you. Having large constructors with multiple parameters is not easy to use, especially when optional params are added

n-miles commented 5 years ago

If you don't want to pull in/learn the Immutables library, I'd at least like to see some kind of fluent builder to allow things like this:

client.newMessage()
        .from("+19876543219")
        .to("+19195554444")
        .to("+12345678912")
        .withText("This is my text")
        .withMedia("https://myhost.com/path/to/file.jpg")
        .withTag("blahblah")
        .send();

Creating all these objects with new is really verbose.

I'd like to see similar interfaces for building other components like the client itself and applications.

fuchsnj commented 5 years ago

It's easier to "learn" the Immutables library than it is to write a builder yourself. Nobody wants to maintain a custom written builder class.