Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #5464
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: How to name class which will read and write configuration to file |
| References | <4253758a-484a-424f-ac42-6fa2c2cffad4@googlegroups.com> <mk4ipq$24r$1@speranza.aioe.org> |
| Message-ID | <9ux9x.13412$HS4.2372@fx07.iad> (permalink) |
| Date | 2015-05-27 22:13 -0700 |
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. Then your Configuration class has so many responsibilities that it is a mess... If you need to write the data to a file, I would have an interface "ConfigurationWriter" with the "XmlConfigurationWriter" implementation. I would have a separate interface "ConfigurationReader" with the "XmlConfigurationReader" implementation. I would also suggest that the interfaces don't know about a specific file, but have an argument passed to the load/save method which is the stream to read from/write to. (For example, InputStream/OutputStream in Java) Hope this helps, Daniel.
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to name class which will read and write configuration to file pavelkastornii@gmail.com - 2015-05-26 14:39 -0700
Re: How to name class which will read and write configuration to file August Karlstrom <fusionfile@gmail.com> - 2015-05-27 16:02 +0200
Re: How to name class which will read and write configuration to file Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2015-05-27 22:13 -0700
Re: How to name class which will read and write configuration to file August Karlstrom <fusionfile@gmail.com> - 2015-05-28 08:32 +0200
Re: How to name class which will read and write configuration to file Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2015-05-28 09:23 -0700
Re: How to name class which will read and write configuration to file August Karlstrom <fusionfile@gmail.com> - 2015-05-28 21:25 +0200
Re: How to name class which will read and write configuration to file Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2015-05-28 21:28 -0700
csiph-web