how can I future-proof migration of a local data layer to a future web based interface (web-service or REST)?

BACKGROUND: I am working on a .NET WinForms application now (C#) with an database for the data layer.

QUESTION: How an I develop this now such that it would be easy to migrate to a model where the data layer is abstracted via a HTTP web-service or REST interface?

For example would just use of a standard C# interface with a Factory to obtain a concrete implementation of the interface where this uses be the best?



Actually what you wanna do is to make your 2-tier application (Application <--> Database) change into an n-tier system (Application(s) <--> App Server <--> Database).

This is a complex change because you have to think of security, business logic and everything.

One Idea could be to use a third-party library like DataAbstract. This is a complete n-Tier framework, still allowing you features like LINQ to a remote data source and making n-tier development really easy. It also provides a web-service interface to easily access your business logic within the application layer from any source. Going further it provides you with client libraries for the iPhone and also windows mobile that do allow you a faster (because binary) access to the layer. You would need the web service interface only for platforms where DataAbstract is not available for.

You've hit the nail on the head - it's about abstraction. Start out right now by abstracting away from storage-specific semantics in your business logic. Develop a clean, object-oriented DAL and do all CRUD/Query operations through it, and while your object model (or domain model, if you want to recognize a difference between the two) can use concrete classes, your DAL operations should be defined in an interface. Whether you use a factory depends on your particular use case, but if you're developing with this sort of abstraction in mind, it makes sense to adopt an inversion of control container and handle this sort of wiring by dependency injection. There are lots to choose from.

You would never want to abstract a DAL with a REST interface. A REST interface is something that you expose directly to a "User Agent". You would never want your business layer to consume data via REST.

The only exception is if your primary goal is to expose the raw data to some remote third party.

Need Your Help

How to manage requirements (specifications) on Visual Studio Team Services (TFS)?

tfs requirements azure-devops

I'm using on-premise TFS and plan to migrate to Visual Studio Team Services. But I still have one question - How to properly manage (store, edit, track) requirements (specifications) for software p...

How to check if MOSS Standard or MOSS Enterprise is installed?

sharepoint moss

How is it possible to check if MOSS Standard or MOSS Enterprise is installed?