How do I Design and Interface (OOP kind) in Java so that I can either use direct database access or use web services? -


at moment have query database not own has web service, provide get. since in house (sort of), might able direct access in future can better data in query.

i don't want have write again , again. if did in java write interface (programming kind, think implements interface, oop)? how this? or write whole new class , "plug in."

this regular client/server architecture. http request, server calls servlet or jsp, returns data.

i'm not sure if idea correct design or not.

definitely sounds should use interface different implementations here. like:

public interface dataaccess {     data getdata(); } 

then can code against api , plugin/inject different implementation needed. have this:

public class directdataaccess implements dataaccess {     public data getdata() {         //use jdbc, orm, or similar     } } 

or this:

public class webservicedataaccess implements dataaccess {     public data getdata() {         //call web service     } } 

but long client code references dataaccess interface, have decoupled client service.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -