suppose a very common scenario:
XYZMovie (a fictional movie website) provides an interface that allows developers to get basic information about a movie (movie name, actors, screening time, ratings, etc.)
interface looks like this: http:api.xyzmovie.com/get?nam...
I used the crawler to cache the data of the site to the local database. Now there is a movie query program, which should be able to set local or network priority queries. If the local or network queries fail, change to another query:
class XYZMovieDataSource
{
XYZMovie GetMovie(string id or name, etc, priority)
{
XYZMovie m;
if(priority == local) { dosomething }
else { dosomething }
return m;
}
XYZMovie GetMovieFromLocal(string id or name, etc) { dosomething }
XYZMovie GetMovieFromNetwork(string id or name, etc) { dosomething }
}
is there a better design pattern?