Re: Design Patterns
- From: "Flinky Wisty Pomm" <Pathogenix@xxxxxxxxx>
- Date: 13 Jan 2007 08:08:56 -0800
Buy, borrow, or steal a copy of Refactoring by Martin Fowler.
http://hanuska.blogspot.com/2006/08/swich-statement-code-smell-and.html
has some info on refactoring from a switch to a polymorphic dispatch,
but the Refactoring book should be your first port of call for things
like this.
sck10 wrote:
Hello,
I just started reading about Design Patterns and UML Class Diagrams on the
web. Anyway, I have a method that I use to format currency given certain
parameters that are supplied from the dataset from SQL Server. I was going
to create another one for Fixed, Percent ect. I know I could create a
switch statement to do this, but wanted to try to use UML as a learning
process.
So I'm trying to figure out how to break up the simple method below to do
this. Any suggestions or references would be appreciated.
sck10
public class StringFormat
{
public string NumberFormater(
object CompareValue, string CompareToValue,
object FormatValue,
string StartReturn, string EndReturn)
{
string strCompareValue = Convert.ToString(CompareValue);
double dblFormatValue;
string strFormatValue;
if(strCompareValue == CompareToValue)
{
dblFormatValue = Convert.ToDouble(FormatValue);
return StartReturn + string.Format("{0:C0}", FormatValue) + EndReturn;
}
else
{
return string.Format("{0:C0}", FormatValue);
} // end if
}
}
.
- Follow-Ups:
- Re: Design Patterns
- From: sck10
- Re: Design Patterns
- References:
- Design Patterns
- From: sck10
- Design Patterns
- Prev by Date: Re: Generic Development/Production Question
- Next by Date: Re: What's better for Session[]... object or struct?
- Previous by thread: Re: Design Patterns
- Next by thread: Re: Design Patterns
- Index(es):
Relevant Pages
|