c# - What should i do if i want to create multiple overloads of CRUD methods? -


if have class represent mapping specific table in db in somehow .. class contains 30 properties .

i have created crud methods .

and find myself need (update) method should update 2 fields .


what should in manner simple example?

  1. using exist method ,filling whole object , update fields including intended 2 fields ?(useless work)
  2. -create static method name(but want keep method name cuz it's expressive ) !!and takes 2 parameters ?

i go by creating 2 separate interface , create overloaded functions each interface. group properties based on usage, want status updated time separate other common properties.

public interface icommonproperties {    public string p1{get; set;}    public string p2{get; set;}    public string p3{ get; set; } } public interface itrackable {    public string status{get; set;} } public class finalclass : icommonproperties, itrackable {    public string p1{get; set;}    public string p2{get; set;}    public string p3{get; set;}    public string status{get; set;} }  public class finalclassoperations {    public void update(finalclass finalclassinstance) { }; //updates    public void update(icommonproperties finalclassinstance) { }; //updates icommonproperties    public void update(itrackable finalclassinstance) { }; //updates status. } 

additionally, if want can create separate class updating status, , still fit in:

public class tracker : itrackable{     public string status{get; set;} } 

but yes, if 2 properties cannot separated out logically, not , keep them together.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -