Daniel Pitts
5/28/2015 4:23:00 PM
On 5/27/15 11:32 PM, August Karlstrom wrote:
> On 2015-05-28 07:13, Daniel Pitts wrote:
>> On 5/27/15 7:02 AM, August Karlstrom wrote:
>>> On 2015-05-26 23:39, pavelkastornii@gmail.com wrote:
>>>> I have a Configuration class and conf.xml file which contains
>>>> configuration data. I am thinking about naming class, that will read
>>>> data from xml-> java and write data java-> xml. ConfigProvider is not
>>>> good way as it suitable onlt for xml->java. ConfigReaderWriter is a
>>>> better, but maybe someone will suggest another variants?
>>>>
>>>
>>> Why not simply add the read and write methods to the Configuration
>>> class?
>> That is a terrible idea if this is a long-lived project. What happens
>> when they want to support yml too? Or json? Or something else.
>
> If you try to anticipate every possible future change to the
> requirements your application will indeed be very complex. In this
> (unlikely) case I would rather let a separate tool handle the conversion
> to XML.
It really depends on the type of product you are creating, including the
expected lifetime and user-base.
However, the "S.O.L.I.D" principles are often helpful regardless of what
your system ultimately aims to be.
In particular, the "Single Responsibility Principle" seems relevant
here. A class that represents a Configuration, shouldn't also represent
a ConfigurationLoader and ConfigurationSaver.