Re: Which design pattern is good for this?
- From: "Jon Skeet [C# MVP]" <skeet@xxxxxxxxx>
- Date: Thu, 25 Oct 2007 00:18:43 -0700
On Oct 25, 6:23 am, namekuseijin <namekusei...@xxxxxxxxx> wrote:
Which design patter is best for this? A dictionary with decorate design
pattern? sound too heavy....
how about the WTF?! design pattern?
seriously, a better pattern is DRY: why implement the aforementioned
classes when you could simply do, say, Int.Parse( text ) for a given
chunk of text inside a try block?
Because it provides encapsulation of parsing and validation. Instead
of having a giant switch statement (or something similar) the OP can
define the columns, and then just keep calling Parse etc. Sounds
reasonable to me.
Now, as for your suggestion: if you're going to try to parse something
and catch exceptions, the TryParse methods are better than calling
Parse inside a try block.
Jon
.
- Follow-Ups:
- Re: Which design pattern is good for this?
- From: namekuseijin
- Re: Which design pattern is good for this?
- References:
- Re: Which design pattern is good for this?
- From: namekuseijin
- Re: Which design pattern is good for this?
- Prev by Date: Multiplying Decimals
- Next by Date: Re: Which design pattern is good for this?
- Previous by thread: Re: Which design pattern is good for this?
- Next by thread: Re: Which design pattern is good for this?
- Index(es):
Relevant Pages
|