چند نکته اضافه برای Refactoring
نویسنده: علی یگانه مقدم
تاریخ: ۱۳۹۵/۰۲/۰۴ ۱۲:۱۰
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
public int ReturnErrorCodes(int n1)
{
if(n1==0)
return -1;
if(n1<0)
return -2;
if(n1>_max)
return -3;
return n1;
} public int ReturnErrorCodes(int n1)
{
if(n1==0)
throw new ZeroException();
if(n1<0)
throw new MinException();
if(n1>_max)
throw new MaxException();
return n1;
} Public Void Draw()
{
var x=_pointDetector.X;
var y=_pointerDetector.Y;
_rectangle.Draw(x,y);
} public Void Draw()
{
var point = _pointDetector.Point;
_rectangle.Draw(point);
} public void Conditions(){
if(a==0)
return 0;
if(b==0)
return 0;
if(c==0)
return 0;
if(d==0)
return 0;
} public void Conditions()
{
if(allConditions())
return 0;
} public void renderBanner() {
if ((platform.toUpperCase().indexOf("MAC") > -1) &&
(browser.toUpperCase().indexOf("IE") > -1) &&
wasInitialized() && resize > 0 )
{
// do something
}
} public void renderBanner() {
bool isMacOs = platform.toUpperCase().indexOf("MAC") > -1;
bool isIE = browser.toUpperCase().indexOf("IE") > -1;
bool wasResized = resize > 0;
if (isMacOs && isIE && wasInitialized() && wasResized) {
// do something
}
} public class Globalization:DateTime
{
public int NextDay()
{
}
} public class Globalization
{
public DateTime DT{get;set;}
public int NextDay()
{
}
} public bool SaveTextF(string path)
{
if (_isTextChanged)
{
if (string.IsNullOrWhiteSpace(path))
{
using (var dlg = new SaveFileDialog {Filter = "*.txt"})
{
if (dlg.ShowDialog() == DialogResult.OK)
path = dlg.FileName;
else
return false;
}
}
//call save methods on path
}
return true;
} public bool SaveTextT(string path)
{
if (!_isTextChanged) return true;
if (string.IsNullOrWhiteSpace(path))
using (var dlg = new SaveFileDialog {Filter = "*.txt"})
{
if (dlg.ShowDialog() != DialogResult.OK) return false;
path = dlg.FileName;
}
//call save methods on path
return true;
}