oop - Not Feeling Right about Data Access Design using Many Methods -


when started had interface:

public interface iblogreader {     blogpost getlatest();     ienumerable<blogpost> findbydate(datetime from, int limit);     ienumerable<blogpost> findbycategory(string category, int limit);     ienumerable<blogpost> findbyauthor(string author, int limit); } 

then needed different permutations of queries (findbyauthorwithcategory, findbydatewithauthor, etc.) figured needed change approach keep growing. need more , different queries. next had interface such as:

public struct findcriteria {     datetime? from;     string category;     string author; }  public interface iblogreader {     blogpost getlatest();     ienumerable<blogpost> find(findcriteria criteria); } 

the interface smaller , refrain making many methods. however, moved many method implementation big-honking single method implementation. made me feel better while. thinking of moving approach wrapped big-honking query method series of individual objects each object handled specifics , call results:

public abstract class querycommand {     protected iblogreader reader = null;     public querycommand(iblogreader reader)     {         this.reader = reader;     }      public abstract void execute(); }  public class getlatest : querycommand {     public blogpost getresults();     public void execute(); }  public class findbydate : querycommand {     public ienumerable<blogpost> getresults();     public void execute(); } 

it still doesn't feel right. read repository pattern , don't see how applies. seemed me still end many methods in end. data being stored in cloud. using specification pattern heavy weight reading of bring of records local qualification. in attempt created individual dao objects , wrapped them inside of repository-like facade object. end result same began with...many methods...but repository didn't of work.

should resolve myself having either many methods or many objects , on it?

it looks query object. use variation of it:

public class filter {     public datetime? postdate { get; set; }     public datetime? lastcomment { get; set; }     public string author { get; set; } } 

and resolving non-null criteria filter expression.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -