What is a good design pattern and terminology for decoupling output?

Posted by User on Programmers See other posts from Programmers or by User
Published on 2012-07-10T00:57:18Z Indexed on 2012/07/10 3:22 UTC
Read the original article Hit count: 233

I have a program where I want to save some data record. And I want the output type to be flexible such that I could save the data record to a text file, xml file, database, push to a webservice.

My take on it would be to create an interface such as DataStore with a Save() method, and the concrete subclasses such as TextFileDataStore, DatabaseDataStore, etc.

  1. What is the proper name/terminology for this type of pattern (I'm using the term "DataStore", log4net names things "appenders", .net they talk about "providers" and "persistence")? I want to come up with good class names (and method names) that fit with a convention if there is one.

  2. can you point me to a decent example, preferably in C#, C++, or java?

Update

Managed to find this stack overflow question, Object persistence terminology: 'repository' vs. 'store' vs. 'context' vs. 'retriever' vs. (…), which captures the terminology part of my question pretty well although there's not a decent answer yet.

© Programmers or respective owner

Related posts about design-patterns

Related posts about persistence