Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1 #39

Closed
Auraliano opened this issue Oct 8, 2015 · 6 comments
Closed

#1 #39

Auraliano opened this issue Oct 8, 2015 · 6 comments

Comments

@Auraliano
Copy link

public class DataHolder {
public final String data;

public DataHolder(String data) {
    this.data = data;
}

}

If it has many properties , create many construct method ? it similar to use get()/set() way

@Ghost141
Copy link

Ghost141 commented Oct 8, 2015

Then you probably should consider the builder pattern. https://github.com/cxxr/better-java#the-builder-pattern

@Auraliano
Copy link
Author

Builder pattern can resolve this question,But If it only has one attribute, why do you need to create a class?

@cxxr
Copy link
Owner

cxxr commented Oct 8, 2015

In Java, everything is an object.

@cxxr cxxr closed this as completed Oct 8, 2015
@Auraliano
Copy link
Author

If a class includes only one string attribute ,Why not use string directly?

@Hinsteny
Copy link

Hinsteny commented Oct 9, 2015

Maybe we can use 'Optional' in java8!

@cxxr
Copy link
Owner

cxxr commented Oct 9, 2015

It was an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants