Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

split into two methods. Isn’t that duplicating code?

0
Posted

split into two methods. Isn’t that duplicating code?

0

Sometimes the implementation of both methods indeed looks very similar. It is split into two methods to ensure that the implementation will either take over the full set of new settings, or reject them entirely. It would be dreadful, if, during load settings part of the settings would be taken over (by assigning them to the internal variables), just to realize half way through that some values are invalid – and then ending it with an exception. Separating the validation step from the assigning (loading) step adds robustness to the application.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123