[{"data":1,"prerenderedAt":1248},["ShallowReactive",2],{"blog:2007:refactoring-shared-libraries-and-public-apis":3,"blogMore-Development":1234,"comments-refactoring-shared-libraries-and-public-apis":1247},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"category":11,"tags":12,"excerpt":17,"body":41,"_type":1225,"_id":1226,"_source":1227,"_file":1228,"_stem":1229,"_extension":1230,"url":1231,"wordCount":1232,"minutes":286,"commentCount":1233},"/blog/2007/refactoring-shared-libraries-and-public-apis","2007",false,"en","Refactoring shared libraries and public APIs","Refactoring is an essential process to keep code clean and elegant while it evolves. IDE’s offer common refactorings (although somewhat short of those prescribed in Fowler’s excellent Refactoring book and way short of the overall goals explained in Kerievsky’s Refactoring Patterns).","2007-10-01T11:32:47+00:00","Development",[13,14,15,16],".NET","Visual Studio","C#","refactoring",{"type":18,"children":19},"root",[20,36],{"type":21,"tag":22,"props":23,"children":24},"element","p",{},[25,28,30,32,34],{"type":26,"value":27},"text","Refactoring is an essential process to keep code clean and elegant while it evolves. IDE’s offer common refactorings (although somewhat short of those prescribed in Fowler’s excellent ",{"type":26,"value":29},"Refactoring",{"type":26,"value":31}," book and way short of the overall goals explained in Kerievsky’s ",{"type":26,"value":33},"Refactoring Patterns",{"type":26,"value":35},").",{"type":21,"tag":22,"props":37,"children":38},{},[39],{"type":26,"value":40},"One limitation of existing tools is that they can only update references within your solution. When you are refactoring a shared library this is a problem, especially if it is your public API to the outside world.",{"type":18,"children":42,"toc":1218},[43,63,67,72,77,84,98,162,190,343,362,367,373,466,478,683,689,879,885,890,1044,1049,1113,1118,1172,1178,1199,1204,1212],{"type":21,"tag":22,"props":44,"children":45},{},[46,47,55,56,62],{"type":26,"value":27},{"type":21,"tag":48,"props":49,"children":53},"a",{"href":50,"rel":51},"https://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FRefactoring-Improving-Design-Existing-Code%2Fdp%2F0201485672&tag=dam-20&linkCode=ur2&camp=1789&creative=9325",[52],"nofollow",[54],{"type":26,"value":29},{"type":26,"value":31},{"type":21,"tag":48,"props":57,"children":60},{"href":58,"rel":59},"https://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FRefactoring-Improving-Design-Existing-Code%2Fdp%2F0201485672http%3A%2F%2Fwww.amazon.com%2FRefactoring-Patterns-Addison-Wesley-Signature-Kerievsky%2Fdp%2F0321213351&tag=dam-20&linkCode=ur2&camp=1789&creative=9325",[52],[61],{"type":26,"value":33},{"type":26,"value":35},{"type":21,"tag":22,"props":64,"children":65},{},[66],{"type":26,"value":40},{"type":21,"tag":22,"props":68,"children":69},{},[70],{"type":26,"value":71},"We need to introduce metadata to document how the API has evolved and extend the tools to generate and understand this metadata.",{"type":21,"tag":22,"props":73,"children":74},{},[75],{"type":26,"value":76},"Let’s take a look at a few of the refactoring in Visual Studio and see how they could be documented using the .NET metadata mechanism of choice, attributes.",{"type":21,"tag":78,"props":79,"children":81},"h2",{"id":80},"rename",[82],{"type":26,"value":83},"Rename",{"type":21,"tag":22,"props":85,"children":86},{},[87,89,96],{"type":26,"value":88},"Starting simple lets we had a property named ",{"type":21,"tag":90,"props":91,"children":93},"code",{"className":92},[],[94],{"type":26,"value":95},"Reference",{"type":26,"value":97},":",{"type":21,"tag":99,"props":100,"children":105},"pre",{"className":101,"code":102,"language":103,"meta":104,"style":104},"language-csharp shiki shiki-themes everforest-light dracula","public string Reference {\n  get { return id; }\n}\n","csharp","",[106],{"type":21,"tag":90,"props":107,"children":108},{"__ignoreMap":104},[109,133,153],{"type":21,"tag":110,"props":111,"children":114},"span",{"class":112,"line":113},"line",1,[115,121,127],{"type":21,"tag":110,"props":116,"children":118},{"style":117},"--shiki-default:#F57D26;--shiki-dark:#FF79C6",[119],{"type":26,"value":120},"public",{"type":21,"tag":110,"props":122,"children":124},{"style":123},"--shiki-default:#3A94C5;--shiki-dark:#FF79C6",[125],{"type":26,"value":126}," string",{"type":21,"tag":110,"props":128,"children":130},{"style":129},"--shiki-default:#5C6A72;--shiki-dark:#F8F8F2",[131],{"type":26,"value":132}," Reference {\n",{"type":21,"tag":110,"props":134,"children":136},{"class":112,"line":135},2,[137,142,148],{"type":21,"tag":110,"props":138,"children":139},{"style":129},[140],{"type":26,"value":141},"  get { ",{"type":21,"tag":110,"props":143,"children":145},{"style":144},"--shiki-default:#F85552;--shiki-dark:#FF79C6",[146],{"type":26,"value":147},"return",{"type":21,"tag":110,"props":149,"children":150},{"style":129},[151],{"type":26,"value":152}," id; }\n",{"type":21,"tag":110,"props":154,"children":156},{"class":112,"line":155},3,[157],{"type":21,"tag":110,"props":158,"children":159},{"style":129},[160],{"type":26,"value":161},"}\n",{"type":21,"tag":22,"props":163,"children":164},{},[165,167,172,174,180,182,188],{"type":26,"value":166},"We are going to rename ",{"type":21,"tag":90,"props":168,"children":170},{"className":169},[],[171],{"type":26,"value":95},{"type":26,"value":173}," to ",{"type":21,"tag":90,"props":175,"children":177},{"className":176},[],[178],{"type":26,"value":179},"StockCode",{"type":26,"value":181}," for the ",{"type":21,"tag":183,"props":184,"children":185},"em",{},[186],{"type":26,"value":187},"1.1.0.0",{"type":26,"value":189}," release. The tool could introduce a stub for backward compatibility while also marking it with metadata giving us:",{"type":21,"tag":99,"props":191,"children":193},{"className":101,"code":192,"language":103,"meta":104,"style":104},"[DeprecatedRefactorRename(\"StockCode\", \"1.1.0.0\")]\npublic string Reference {\n  get { return StockCode; }\n}\n\npublic string StockCode {\n  get { return id; }\n}\n",[194],{"type":21,"tag":90,"props":195,"children":196},{"__ignoreMap":104},[197,253,268,284,292,302,319,335],{"type":21,"tag":110,"props":198,"children":199},{"class":112,"line":113},[200,205,211,216,222,227,231,236,240,244,248],{"type":21,"tag":110,"props":201,"children":202},{"style":129},[203],{"type":26,"value":204},"[",{"type":21,"tag":110,"props":206,"children":208},{"style":207},"--shiki-default:#3A94C5;--shiki-default-font-style:inherit;--shiki-dark:#8BE9FD;--shiki-dark-font-style:italic",[209],{"type":26,"value":210},"DeprecatedRefactorRename",{"type":21,"tag":110,"props":212,"children":213},{"style":129},[214],{"type":26,"value":215},"(",{"type":21,"tag":110,"props":217,"children":219},{"style":218},"--shiki-default:#8DA101;--shiki-dark:#E9F284",[220],{"type":26,"value":221},"\"",{"type":21,"tag":110,"props":223,"children":225},{"style":224},"--shiki-default:#8DA101;--shiki-dark:#F1FA8C",[226],{"type":26,"value":179},{"type":21,"tag":110,"props":228,"children":229},{"style":218},[230],{"type":26,"value":221},{"type":21,"tag":110,"props":232,"children":233},{"style":129},[234],{"type":26,"value":235},", ",{"type":21,"tag":110,"props":237,"children":238},{"style":218},[239],{"type":26,"value":221},{"type":21,"tag":110,"props":241,"children":242},{"style":224},[243],{"type":26,"value":187},{"type":21,"tag":110,"props":245,"children":246},{"style":218},[247],{"type":26,"value":221},{"type":21,"tag":110,"props":249,"children":250},{"style":129},[251],{"type":26,"value":252},")]\n",{"type":21,"tag":110,"props":254,"children":255},{"class":112,"line":135},[256,260,264],{"type":21,"tag":110,"props":257,"children":258},{"style":117},[259],{"type":26,"value":120},{"type":21,"tag":110,"props":261,"children":262},{"style":123},[263],{"type":26,"value":126},{"type":21,"tag":110,"props":265,"children":266},{"style":129},[267],{"type":26,"value":132},{"type":21,"tag":110,"props":269,"children":270},{"class":112,"line":155},[271,275,279],{"type":21,"tag":110,"props":272,"children":273},{"style":129},[274],{"type":26,"value":141},{"type":21,"tag":110,"props":276,"children":277},{"style":144},[278],{"type":26,"value":147},{"type":21,"tag":110,"props":280,"children":281},{"style":129},[282],{"type":26,"value":283}," StockCode; }\n",{"type":21,"tag":110,"props":285,"children":287},{"class":112,"line":286},4,[288],{"type":21,"tag":110,"props":289,"children":290},{"style":129},[291],{"type":26,"value":161},{"type":21,"tag":110,"props":293,"children":295},{"class":112,"line":294},5,[296],{"type":21,"tag":110,"props":297,"children":299},{"emptyLinePlaceholder":298},true,[300],{"type":26,"value":301},"\n",{"type":21,"tag":110,"props":303,"children":305},{"class":112,"line":304},6,[306,310,314],{"type":21,"tag":110,"props":307,"children":308},{"style":117},[309],{"type":26,"value":120},{"type":21,"tag":110,"props":311,"children":312},{"style":123},[313],{"type":26,"value":126},{"type":21,"tag":110,"props":315,"children":316},{"style":129},[317],{"type":26,"value":318}," StockCode {\n",{"type":21,"tag":110,"props":320,"children":322},{"class":112,"line":321},7,[323,327,331],{"type":21,"tag":110,"props":324,"children":325},{"style":129},[326],{"type":26,"value":141},{"type":21,"tag":110,"props":328,"children":329},{"style":144},[330],{"type":26,"value":147},{"type":21,"tag":110,"props":332,"children":333},{"style":129},[334],{"type":26,"value":152},{"type":21,"tag":110,"props":336,"children":338},{"class":112,"line":337},8,[339],{"type":21,"tag":110,"props":340,"children":341},{"style":129},[342],{"type":26,"value":161},{"type":21,"tag":22,"props":344,"children":345},{},[346,348,353,355,360],{"type":26,"value":347},"The library is both binary and source compatible but with a little IDE work they could get a warning that ",{"type":21,"tag":90,"props":349,"children":351},{"className":350},[],[352],{"type":26,"value":95},{"type":26,"value":354}," is now ",{"type":21,"tag":90,"props":356,"children":358},{"className":357},[],[359],{"type":26,"value":179},{"type":26,"value":361}," and given the choice of updating all the references in their project.",{"type":21,"tag":22,"props":363,"children":364},{},[365],{"type":26,"value":366},"Nice. Let’s try a few more:",{"type":21,"tag":78,"props":368,"children":370},{"id":369},"remove-parameters",[371],{"type":26,"value":372},"Remove Parameters",{"type":21,"tag":99,"props":374,"children":376},{"className":101,"code":375,"language":103,"meta":104,"style":104},"public bool AddStock(int quantity, DateTime arrival, StorageBin location) {\n   ...\n}\n",[377],{"type":21,"tag":90,"props":378,"children":379},{"__ignoreMap":104},[380,446,459],{"type":21,"tag":110,"props":381,"children":382},{"class":112,"line":113},[383,387,392,398,402,407,413,417,422,427,431,436,441],{"type":21,"tag":110,"props":384,"children":385},{"style":117},[386],{"type":26,"value":120},{"type":21,"tag":110,"props":388,"children":389},{"style":123},[390],{"type":26,"value":391}," bool",{"type":21,"tag":110,"props":393,"children":395},{"style":394},"--shiki-default:#8DA101;--shiki-dark:#50FA7B",[396],{"type":26,"value":397}," AddStock",{"type":21,"tag":110,"props":399,"children":400},{"style":129},[401],{"type":26,"value":215},{"type":21,"tag":110,"props":403,"children":404},{"style":123},[405],{"type":26,"value":406},"int",{"type":21,"tag":110,"props":408,"children":410},{"style":409},"--shiki-default:#5C6A72;--shiki-default-font-style:inherit;--shiki-dark:#FFB86C;--shiki-dark-font-style:italic",[411],{"type":26,"value":412}," quantity",{"type":21,"tag":110,"props":414,"children":415},{"style":129},[416],{"type":26,"value":235},{"type":21,"tag":110,"props":418,"children":419},{"style":207},[420],{"type":26,"value":421},"DateTime",{"type":21,"tag":110,"props":423,"children":424},{"style":409},[425],{"type":26,"value":426}," arrival",{"type":21,"tag":110,"props":428,"children":429},{"style":129},[430],{"type":26,"value":235},{"type":21,"tag":110,"props":432,"children":433},{"style":207},[434],{"type":26,"value":435},"StorageBin",{"type":21,"tag":110,"props":437,"children":438},{"style":409},[439],{"type":26,"value":440}," location",{"type":21,"tag":110,"props":442,"children":443},{"style":129},[444],{"type":26,"value":445},") {\n",{"type":21,"tag":110,"props":447,"children":448},{"class":112,"line":135},[449,454],{"type":21,"tag":110,"props":450,"children":451},{"style":117},[452],{"type":26,"value":453},"   ..",{"type":21,"tag":110,"props":455,"children":456},{"style":129},[457],{"type":26,"value":458},".\n",{"type":21,"tag":110,"props":460,"children":461},{"class":112,"line":155},[462],{"type":21,"tag":110,"props":463,"children":464},{"style":129},[465],{"type":26,"value":161},{"type":21,"tag":22,"props":467,"children":468},{},[469,471,476],{"type":26,"value":470},"We are switching to a managed warehouse and so we no longer need to know where items are stored so we refactor and remove the ",{"type":21,"tag":90,"props":472,"children":474},{"className":473},[],[475],{"type":26,"value":435},{"type":26,"value":477},".",{"type":21,"tag":99,"props":479,"children":481},{"className":101,"code":480,"language":103,"meta":104,"style":104},"[DeprecatedParameterRemoved(\"location\", \"1.1.0.0.\")]\npublic bool AddStock(int quantity, DateTime arrival, StorageBin location) {\n  return AddStock(quantity, arrival);\n}\n\npublic bool AddStock(int quantity, DateTime arrival) {\n  ...\n}\n",[482],{"type":21,"tag":90,"props":483,"children":484},{"__ignoreMap":104},[485,535,590,607,614,621,664,676],{"type":21,"tag":110,"props":486,"children":487},{"class":112,"line":113},[488,492,497,501,505,510,514,518,522,527,531],{"type":21,"tag":110,"props":489,"children":490},{"style":129},[491],{"type":26,"value":204},{"type":21,"tag":110,"props":493,"children":494},{"style":207},[495],{"type":26,"value":496},"DeprecatedParameterRemoved",{"type":21,"tag":110,"props":498,"children":499},{"style":129},[500],{"type":26,"value":215},{"type":21,"tag":110,"props":502,"children":503},{"style":218},[504],{"type":26,"value":221},{"type":21,"tag":110,"props":506,"children":507},{"style":224},[508],{"type":26,"value":509},"location",{"type":21,"tag":110,"props":511,"children":512},{"style":218},[513],{"type":26,"value":221},{"type":21,"tag":110,"props":515,"children":516},{"style":129},[517],{"type":26,"value":235},{"type":21,"tag":110,"props":519,"children":520},{"style":218},[521],{"type":26,"value":221},{"type":21,"tag":110,"props":523,"children":524},{"style":224},[525],{"type":26,"value":526},"1.1.0.0.",{"type":21,"tag":110,"props":528,"children":529},{"style":218},[530],{"type":26,"value":221},{"type":21,"tag":110,"props":532,"children":533},{"style":129},[534],{"type":26,"value":252},{"type":21,"tag":110,"props":536,"children":537},{"class":112,"line":135},[538,542,546,550,554,558,562,566,570,574,578,582,586],{"type":21,"tag":110,"props":539,"children":540},{"style":117},[541],{"type":26,"value":120},{"type":21,"tag":110,"props":543,"children":544},{"style":123},[545],{"type":26,"value":391},{"type":21,"tag":110,"props":547,"children":548},{"style":394},[549],{"type":26,"value":397},{"type":21,"tag":110,"props":551,"children":552},{"style":129},[553],{"type":26,"value":215},{"type":21,"tag":110,"props":555,"children":556},{"style":123},[557],{"type":26,"value":406},{"type":21,"tag":110,"props":559,"children":560},{"style":409},[561],{"type":26,"value":412},{"type":21,"tag":110,"props":563,"children":564},{"style":129},[565],{"type":26,"value":235},{"type":21,"tag":110,"props":567,"children":568},{"style":207},[569],{"type":26,"value":421},{"type":21,"tag":110,"props":571,"children":572},{"style":409},[573],{"type":26,"value":426},{"type":21,"tag":110,"props":575,"children":576},{"style":129},[577],{"type":26,"value":235},{"type":21,"tag":110,"props":579,"children":580},{"style":207},[581],{"type":26,"value":435},{"type":21,"tag":110,"props":583,"children":584},{"style":409},[585],{"type":26,"value":440},{"type":21,"tag":110,"props":587,"children":588},{"style":129},[589],{"type":26,"value":445},{"type":21,"tag":110,"props":591,"children":592},{"class":112,"line":155},[593,598,602],{"type":21,"tag":110,"props":594,"children":595},{"style":144},[596],{"type":26,"value":597},"  return",{"type":21,"tag":110,"props":599,"children":600},{"style":394},[601],{"type":26,"value":397},{"type":21,"tag":110,"props":603,"children":604},{"style":129},[605],{"type":26,"value":606},"(quantity, arrival);\n",{"type":21,"tag":110,"props":608,"children":609},{"class":112,"line":286},[610],{"type":21,"tag":110,"props":611,"children":612},{"style":129},[613],{"type":26,"value":161},{"type":21,"tag":110,"props":615,"children":616},{"class":112,"line":294},[617],{"type":21,"tag":110,"props":618,"children":619},{"emptyLinePlaceholder":298},[620],{"type":26,"value":301},{"type":21,"tag":110,"props":622,"children":623},{"class":112,"line":304},[624,628,632,636,640,644,648,652,656,660],{"type":21,"tag":110,"props":625,"children":626},{"style":117},[627],{"type":26,"value":120},{"type":21,"tag":110,"props":629,"children":630},{"style":123},[631],{"type":26,"value":391},{"type":21,"tag":110,"props":633,"children":634},{"style":394},[635],{"type":26,"value":397},{"type":21,"tag":110,"props":637,"children":638},{"style":129},[639],{"type":26,"value":215},{"type":21,"tag":110,"props":641,"children":642},{"style":123},[643],{"type":26,"value":406},{"type":21,"tag":110,"props":645,"children":646},{"style":409},[647],{"type":26,"value":412},{"type":21,"tag":110,"props":649,"children":650},{"style":129},[651],{"type":26,"value":235},{"type":21,"tag":110,"props":653,"children":654},{"style":207},[655],{"type":26,"value":421},{"type":21,"tag":110,"props":657,"children":658},{"style":409},[659],{"type":26,"value":426},{"type":21,"tag":110,"props":661,"children":662},{"style":129},[663],{"type":26,"value":445},{"type":21,"tag":110,"props":665,"children":666},{"class":112,"line":321},[667,672],{"type":21,"tag":110,"props":668,"children":669},{"style":117},[670],{"type":26,"value":671},"  ..",{"type":21,"tag":110,"props":673,"children":674},{"style":129},[675],{"type":26,"value":458},{"type":21,"tag":110,"props":677,"children":678},{"class":112,"line":337},[679],{"type":21,"tag":110,"props":680,"children":681},{"style":129},[682],{"type":26,"value":161},{"type":21,"tag":78,"props":684,"children":686},{"id":685},"reorder-parameters",[687],{"type":26,"value":688},"Reorder Parameters",{"type":21,"tag":99,"props":690,"children":692},{"className":101,"code":691,"language":103,"meta":104,"style":104},"[DeprecatedParametersReordered(\"arrival, quantity\", \"1.1.0.0.\")]\npublic bool AddStock(int quantity, DateTime arrival) {\n  return AddStock(arrival, quantity);\n}\n\npublic bool AddStock(DateTime arrival, int quantity) {\n  ...\n}\n",[693],{"type":21,"tag":90,"props":694,"children":695},{"__ignoreMap":104},[696,745,788,804,811,818,861,872],{"type":21,"tag":110,"props":697,"children":698},{"class":112,"line":113},[699,703,708,712,716,721,725,729,733,737,741],{"type":21,"tag":110,"props":700,"children":701},{"style":129},[702],{"type":26,"value":204},{"type":21,"tag":110,"props":704,"children":705},{"style":207},[706],{"type":26,"value":707},"DeprecatedParametersReordered",{"type":21,"tag":110,"props":709,"children":710},{"style":129},[711],{"type":26,"value":215},{"type":21,"tag":110,"props":713,"children":714},{"style":218},[715],{"type":26,"value":221},{"type":21,"tag":110,"props":717,"children":718},{"style":224},[719],{"type":26,"value":720},"arrival, quantity",{"type":21,"tag":110,"props":722,"children":723},{"style":218},[724],{"type":26,"value":221},{"type":21,"tag":110,"props":726,"children":727},{"style":129},[728],{"type":26,"value":235},{"type":21,"tag":110,"props":730,"children":731},{"style":218},[732],{"type":26,"value":221},{"type":21,"tag":110,"props":734,"children":735},{"style":224},[736],{"type":26,"value":526},{"type":21,"tag":110,"props":738,"children":739},{"style":218},[740],{"type":26,"value":221},{"type":21,"tag":110,"props":742,"children":743},{"style":129},[744],{"type":26,"value":252},{"type":21,"tag":110,"props":746,"children":747},{"class":112,"line":135},[748,752,756,760,764,768,772,776,780,784],{"type":21,"tag":110,"props":749,"children":750},{"style":117},[751],{"type":26,"value":120},{"type":21,"tag":110,"props":753,"children":754},{"style":123},[755],{"type":26,"value":391},{"type":21,"tag":110,"props":757,"children":758},{"style":394},[759],{"type":26,"value":397},{"type":21,"tag":110,"props":761,"children":762},{"style":129},[763],{"type":26,"value":215},{"type":21,"tag":110,"props":765,"children":766},{"style":123},[767],{"type":26,"value":406},{"type":21,"tag":110,"props":769,"children":770},{"style":409},[771],{"type":26,"value":412},{"type":21,"tag":110,"props":773,"children":774},{"style":129},[775],{"type":26,"value":235},{"type":21,"tag":110,"props":777,"children":778},{"style":207},[779],{"type":26,"value":421},{"type":21,"tag":110,"props":781,"children":782},{"style":409},[783],{"type":26,"value":426},{"type":21,"tag":110,"props":785,"children":786},{"style":129},[787],{"type":26,"value":445},{"type":21,"tag":110,"props":789,"children":790},{"class":112,"line":155},[791,795,799],{"type":21,"tag":110,"props":792,"children":793},{"style":144},[794],{"type":26,"value":597},{"type":21,"tag":110,"props":796,"children":797},{"style":394},[798],{"type":26,"value":397},{"type":21,"tag":110,"props":800,"children":801},{"style":129},[802],{"type":26,"value":803},"(arrival, quantity);\n",{"type":21,"tag":110,"props":805,"children":806},{"class":112,"line":286},[807],{"type":21,"tag":110,"props":808,"children":809},{"style":129},[810],{"type":26,"value":161},{"type":21,"tag":110,"props":812,"children":813},{"class":112,"line":294},[814],{"type":21,"tag":110,"props":815,"children":816},{"emptyLinePlaceholder":298},[817],{"type":26,"value":301},{"type":21,"tag":110,"props":819,"children":820},{"class":112,"line":304},[821,825,829,833,837,841,845,849,853,857],{"type":21,"tag":110,"props":822,"children":823},{"style":117},[824],{"type":26,"value":120},{"type":21,"tag":110,"props":826,"children":827},{"style":123},[828],{"type":26,"value":391},{"type":21,"tag":110,"props":830,"children":831},{"style":394},[832],{"type":26,"value":397},{"type":21,"tag":110,"props":834,"children":835},{"style":129},[836],{"type":26,"value":215},{"type":21,"tag":110,"props":838,"children":839},{"style":207},[840],{"type":26,"value":421},{"type":21,"tag":110,"props":842,"children":843},{"style":409},[844],{"type":26,"value":426},{"type":21,"tag":110,"props":846,"children":847},{"style":129},[848],{"type":26,"value":235},{"type":21,"tag":110,"props":850,"children":851},{"style":123},[852],{"type":26,"value":406},{"type":21,"tag":110,"props":854,"children":855},{"style":409},[856],{"type":26,"value":412},{"type":21,"tag":110,"props":858,"children":859},{"style":129},[860],{"type":26,"value":445},{"type":21,"tag":110,"props":862,"children":863},{"class":112,"line":321},[864,868],{"type":21,"tag":110,"props":865,"children":866},{"style":117},[867],{"type":26,"value":671},{"type":21,"tag":110,"props":869,"children":870},{"style":129},[871],{"type":26,"value":458},{"type":21,"tag":110,"props":873,"children":874},{"class":112,"line":337},[875],{"type":21,"tag":110,"props":876,"children":877},{"style":129},[878],{"type":26,"value":161},{"type":21,"tag":78,"props":880,"children":882},{"id":881},"move-method",[883],{"type":26,"value":884},"Move Method",{"type":21,"tag":22,"props":886,"children":887},{},[888],{"type":26,"value":889},"Existing tools offer little support for MoveMethod because they haven’t considered how to refactor the references. It is difficult to retain binary compatibility unless the class has a reference to class that now has the method we are interested in.",{"type":21,"tag":99,"props":891,"children":893},{"className":101,"code":892,"language":103,"meta":104,"style":104},"[DeprecatedMethodMoved(\"StockController\", \"Add\", \"1.1.0.0\")]\npublic bool AddStock(DateTime arrival, int quantity) {\n  return stockController.Add(this, arrival, quantity);\n}\n",[894],{"type":21,"tag":90,"props":895,"children":896},{"__ignoreMap":104},[897,963,1006,1037],{"type":21,"tag":110,"props":898,"children":899},{"class":112,"line":113},[900,904,909,913,917,922,926,930,934,939,943,947,951,955,959],{"type":21,"tag":110,"props":901,"children":902},{"style":129},[903],{"type":26,"value":204},{"type":21,"tag":110,"props":905,"children":906},{"style":207},[907],{"type":26,"value":908},"DeprecatedMethodMoved",{"type":21,"tag":110,"props":910,"children":911},{"style":129},[912],{"type":26,"value":215},{"type":21,"tag":110,"props":914,"children":915},{"style":218},[916],{"type":26,"value":221},{"type":21,"tag":110,"props":918,"children":919},{"style":224},[920],{"type":26,"value":921},"StockController",{"type":21,"tag":110,"props":923,"children":924},{"style":218},[925],{"type":26,"value":221},{"type":21,"tag":110,"props":927,"children":928},{"style":129},[929],{"type":26,"value":235},{"type":21,"tag":110,"props":931,"children":932},{"style":218},[933],{"type":26,"value":221},{"type":21,"tag":110,"props":935,"children":936},{"style":224},[937],{"type":26,"value":938},"Add",{"type":21,"tag":110,"props":940,"children":941},{"style":218},[942],{"type":26,"value":221},{"type":21,"tag":110,"props":944,"children":945},{"style":129},[946],{"type":26,"value":235},{"type":21,"tag":110,"props":948,"children":949},{"style":218},[950],{"type":26,"value":221},{"type":21,"tag":110,"props":952,"children":953},{"style":224},[954],{"type":26,"value":187},{"type":21,"tag":110,"props":956,"children":957},{"style":218},[958],{"type":26,"value":221},{"type":21,"tag":110,"props":960,"children":961},{"style":129},[962],{"type":26,"value":252},{"type":21,"tag":110,"props":964,"children":965},{"class":112,"line":135},[966,970,974,978,982,986,990,994,998,1002],{"type":21,"tag":110,"props":967,"children":968},{"style":117},[969],{"type":26,"value":120},{"type":21,"tag":110,"props":971,"children":972},{"style":123},[973],{"type":26,"value":391},{"type":21,"tag":110,"props":975,"children":976},{"style":394},[977],{"type":26,"value":397},{"type":21,"tag":110,"props":979,"children":980},{"style":129},[981],{"type":26,"value":215},{"type":21,"tag":110,"props":983,"children":984},{"style":207},[985],{"type":26,"value":421},{"type":21,"tag":110,"props":987,"children":988},{"style":409},[989],{"type":26,"value":426},{"type":21,"tag":110,"props":991,"children":992},{"style":129},[993],{"type":26,"value":235},{"type":21,"tag":110,"props":995,"children":996},{"style":123},[997],{"type":26,"value":406},{"type":21,"tag":110,"props":999,"children":1000},{"style":409},[1001],{"type":26,"value":412},{"type":21,"tag":110,"props":1003,"children":1004},{"style":129},[1005],{"type":26,"value":445},{"type":21,"tag":110,"props":1007,"children":1008},{"class":112,"line":155},[1009,1013,1018,1022,1026,1032],{"type":21,"tag":110,"props":1010,"children":1011},{"style":144},[1012],{"type":26,"value":597},{"type":21,"tag":110,"props":1014,"children":1015},{"style":129},[1016],{"type":26,"value":1017}," stockController.",{"type":21,"tag":110,"props":1019,"children":1020},{"style":394},[1021],{"type":26,"value":938},{"type":21,"tag":110,"props":1023,"children":1024},{"style":129},[1025],{"type":26,"value":215},{"type":21,"tag":110,"props":1027,"children":1029},{"style":1028},"--shiki-default:#DF69BA;--shiki-default-font-style:inherit;--shiki-dark:#BD93F9;--shiki-dark-font-style:italic",[1030],{"type":26,"value":1031},"this",{"type":21,"tag":110,"props":1033,"children":1034},{"style":129},[1035],{"type":26,"value":1036},", arrival, quantity);\n",{"type":21,"tag":110,"props":1038,"children":1039},{"class":112,"line":286},[1040],{"type":21,"tag":110,"props":1041,"children":1042},{"style":129},[1043],{"type":26,"value":161},{"type":21,"tag":22,"props":1045,"children":1046},{},[1047],{"type":26,"value":1048},"Let’s say the current calling code looks something like:",{"type":21,"tag":99,"props":1050,"children":1052},{"className":101,"code":1051,"language":103,"meta":104,"style":104},"stockController.DoSomething();\nselectedProduct.AddStock(DateTime.Now, input.Value);\n",[1053],{"type":21,"tag":90,"props":1054,"children":1055},{"__ignoreMap":104},[1056,1074],{"type":21,"tag":110,"props":1057,"children":1058},{"class":112,"line":113},[1059,1064,1069],{"type":21,"tag":110,"props":1060,"children":1061},{"style":129},[1062],{"type":26,"value":1063},"stockController.",{"type":21,"tag":110,"props":1065,"children":1066},{"style":394},[1067],{"type":26,"value":1068},"DoSomething",{"type":21,"tag":110,"props":1070,"children":1071},{"style":129},[1072],{"type":26,"value":1073},"();\n",{"type":21,"tag":110,"props":1075,"children":1076},{"class":112,"line":135},[1077,1082,1087,1092,1098,1103,1108],{"type":21,"tag":110,"props":1078,"children":1079},{"style":129},[1080],{"type":26,"value":1081},"selectedProduct.",{"type":21,"tag":110,"props":1083,"children":1084},{"style":394},[1085],{"type":26,"value":1086},"AddStock",{"type":21,"tag":110,"props":1088,"children":1089},{"style":129},[1090],{"type":26,"value":1091},"(DateTime.",{"type":21,"tag":110,"props":1093,"children":1095},{"style":1094},"--shiki-default:#35A77C;--shiki-dark:#F8F8F2",[1096],{"type":26,"value":1097},"Now",{"type":21,"tag":110,"props":1099,"children":1100},{"style":129},[1101],{"type":26,"value":1102},", input.",{"type":21,"tag":110,"props":1104,"children":1105},{"style":1094},[1106],{"type":26,"value":1107},"Value",{"type":21,"tag":110,"props":1109,"children":1110},{"style":129},[1111],{"type":26,"value":1112},");\n",{"type":21,"tag":22,"props":1114,"children":1115},{},[1116],{"type":26,"value":1117},"However with a little ingenuity the IDE could examine the new method and map existing parameters based on name and type. If it still doesn’t have enough information consider local variables and properties of the objects it does have to present choices. This works especially well if your parameters are not primitives. Our code becomes:",{"type":21,"tag":99,"props":1119,"children":1121},{"className":101,"code":1120,"language":103,"meta":104,"style":104},"stockController.DoSomething();\nstockController.Add(selectedProduct, DateTime.Now, input.Value);\n",[1122],{"type":21,"tag":90,"props":1123,"children":1124},{"__ignoreMap":104},[1125,1140],{"type":21,"tag":110,"props":1126,"children":1127},{"class":112,"line":113},[1128,1132,1136],{"type":21,"tag":110,"props":1129,"children":1130},{"style":129},[1131],{"type":26,"value":1063},{"type":21,"tag":110,"props":1133,"children":1134},{"style":394},[1135],{"type":26,"value":1068},{"type":21,"tag":110,"props":1137,"children":1138},{"style":129},[1139],{"type":26,"value":1073},{"type":21,"tag":110,"props":1141,"children":1142},{"class":112,"line":135},[1143,1147,1151,1156,1160,1164,1168],{"type":21,"tag":110,"props":1144,"children":1145},{"style":129},[1146],{"type":26,"value":1063},{"type":21,"tag":110,"props":1148,"children":1149},{"style":394},[1150],{"type":26,"value":938},{"type":21,"tag":110,"props":1152,"children":1153},{"style":129},[1154],{"type":26,"value":1155},"(selectedProduct, DateTime.",{"type":21,"tag":110,"props":1157,"children":1158},{"style":1094},[1159],{"type":26,"value":1097},{"type":21,"tag":110,"props":1161,"children":1162},{"style":129},[1163],{"type":26,"value":1102},{"type":21,"tag":110,"props":1165,"children":1166},{"style":1094},[1167],{"type":26,"value":1107},{"type":21,"tag":110,"props":1169,"children":1170},{"style":129},[1171],{"type":26,"value":1112},{"type":21,"tag":78,"props":1173,"children":1175},{"id":1174},"keeping-it-clean",[1176],{"type":26,"value":1177},"Keeping it clean",{"type":21,"tag":22,"props":1179,"children":1180},{},[1181,1183,1189,1191,1197],{"type":26,"value":1182},"We don’t want our classes being cluttered with deprecated code indefinitely so the solution should contain two extra revision numbers, one detailing the oldest revision of attributes to keep in the source, the other for the oldest revision to compile into the binary. All the ",{"type":21,"tag":90,"props":1184,"children":1186},{"className":1185},[],[1187],{"type":26,"value":1188},"[Deprecated]",{"type":26,"value":1190}," marked methods and properties can slip into another file, perhaps ",{"type":21,"tag":90,"props":1192,"children":1194},{"className":1193},[],[1195],{"type":26,"value":1196},"Product.deprecated.cs",{"type":26,"value":1198}," so they stay out of sight until needed.",{"type":21,"tag":22,"props":1200,"children":1201},{},[1202],{"type":26,"value":1203},"For .NET it would need somebody at Microsoft to take this on board and move us forward from ObsoleteAttribute as the facility should be cross-tool and so adding it solely to SharpDevelop would be of limited gain.",{"type":21,"tag":22,"props":1205,"children":1206},{},[1207],{"type":21,"tag":183,"props":1208,"children":1209},{},[1210],{"type":26,"value":1211},"[)amien",{"type":21,"tag":1213,"props":1214,"children":1215},"style",{},[1216],{"type":26,"value":1217},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":104,"searchDepth":135,"depth":135,"links":1219},[1220,1221,1222,1223,1224],{"id":80,"depth":135,"text":83},{"id":369,"depth":135,"text":372},{"id":685,"depth":135,"text":688},{"id":881,"depth":135,"text":884},{"id":1174,"depth":135,"text":1177},"markdown","content:blog:2007:refactoring-shared-libraries-and-public-apis.md","content","blog/2007/refactoring-shared-libraries-and-public-apis.md","blog/2007/refactoring-shared-libraries-and-public-apis","md","/blog/2007/refactoring-shared-libraries-and-public-apis/",694,0,[1235,1239,1243],{"title":1236,"date":1237,"url":1238},"HTML5 Video Cheatsheet: Optimizing videos for the web","2025-12-05T00:00:00Z","/blog/2025/html5-video-cheatsheet/",{"title":1240,"date":1241,"url":1242},"Transactions in the MongoDB EF Core Provider","2025-10-25","/blog/2025/mongodb-explicit-transactions/",{"title":1244,"date":1245,"url":1246},"Queryable Encryption with the MongoDB EF Core Provider","2025-09-22","/blog/2025/mongodb-queryable-encryption/",[],1779264591719]