Question

I have an application that depends on a dll (named datalib) intended to store data in xml format.

There is a tight couple between my app and that dll.

All over the code my app retrieve data using that dll in this manner:

var data = datalib.Parameters.HostAddress;

I want my app to have an ability for replacement of data source (for instance to SQL Server database).

For unfortune, my app within it's business logic convey strongly typed objects from datalib to other modules which depends on datalib tightly to.

What possible ways are available in my situation to achieve the ability for replacement of data source? Am I need to create my own domain layer with the ability to map it's entities to datalib's entities?

Was it helpful?

Solution

Suggest reading up on these concepts from the below links and elsewhere:

  1. Repository Pattern
  2. Data Mapper

Essentially, you want to achieve loose coupling around the external data access library (datalib.dll). This could be achieved in many ways - from a simple DataAccess class to more extensible Repository type factory classes.

You would have to make that choice, based on the cost vs. benefits in each approach. Hope this helps.

OTHER TIPS

As per my understanding The datasource needs to configured dyanamincally and it should be used by datalib

  1. Write a independent program which reads a configuration file to get datasource.

  2. Test that program to see it can access different datasource. The method can return a DataSource (in Java. Not much idea about the language)

  3. Modify the datalib to change the code to access the program you write in step 2.

In this way we are not breaking any contract datalib and the invokation points in your application and you can achieve some decoupling.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top