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

Implement some way to "clone" builders #17

Closed
ctron opened this issue Jul 11, 2016 · 6 comments
Closed

Implement some way to "clone" builders #17

ctron opened this issue Jul 11, 2016 · 6 comments
Assignees

Comments

@ctron
Copy link
Contributor

ctron commented Jul 11, 2016

Setting up a builder like OpcUaClientConfigBuilder takes "a few" parameters and method calls.

It would be nice to have either a "clone" method or a "copy constructor" in the builder pattern so that there is no need to do it all over again when only one parameter needs to be changed but you want to keep a mutable instance.

@kevinherron
Copy link
Contributor

What if there was a copy() method hanging off OpcUaClientConfig instead which returned a OpcUaClientConfigBuilder with all of the values pre-set from the config. This way you're not encouraged to leave some reference to a mutable, non-thread-safe object like a builder laying around.

@kevinherron
Copy link
Contributor

kevinherron commented Jul 11, 2016

I'm implementing this idea on UaTcpStackClientConfig and OpcUaClientConfig.

edit: and the server versions... even though it's less likely to be needed.

@ctron
Copy link
Contributor Author

ctron commented Jul 11, 2016

Actually I just did it for the server config because I needed them most :-)

@ctron
Copy link
Contributor Author

ctron commented Jul 11, 2016

So I will stick with my local changes and wait for your fix! Thanks!!

Just to let you know what I did. I created two additional constructors, beside the default one. Taking in "Config" and "ConfigBuilder" each. The "ConfigBuilder" just calls "this ( other.build() )", which may not be that performant, but this should not be called that often either.

But that allows one to clone the builder and also create a mutable version from an existing configuration again.

True, every type used by the configuration, should be immutable as well.

kevinherron added a commit that referenced this issue Jul 12, 2016
Adds copy() methods to the UaTcpStackClientConfig and OpcUaClientConfig objects that allow for easier copying and modification of an existing config.
@kevinherron
Copy link
Contributor

kevinherron commented Jul 12, 2016

So I've done half the work... added copy() methods to the client config objects. It's somewhat tedious and boring, especially the tests, so I'm going to take a break and implement the server ones later... 😝

kevinherron added a commit that referenced this issue Jul 12, 2016
Adds copy() methods to the UaTcpStackServerConfig and OpcUaServerConfig objects that allow for easier copying and modification of an existing config.
@kevinherron
Copy link
Contributor

Just missing tests for the server config objects now.

kevinherron added a commit that referenced this issue Jul 19, 2016
Adds copy() methods to the client and server config objects that allow for easier copying and modification of an existing config.
kevinherron added a commit that referenced this issue Jul 19, 2016
[#17] copy() methods for config objects
Pro pushed a commit to Pro/milo that referenced this issue Nov 28, 2016
Adds copy() methods to the client and server config objects that allow for easier copying and modification of an existing config.
Pro pushed a commit to Pro/milo that referenced this issue Nov 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants