Re: Which design pattern is good for this?



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

.



Relevant Pages

  • Re: [ANN] Chronic-0.1.0
    ... See below for the wide variety of formats Chronic will parse. ... I've been wrestling with that concept for ... awhile not in a OS X Dashboard clock I made. ... Which matches a pattern that knows to look for the next future January, and beginning with the start of that month, look for the next future Tuesday three times. ...
    (comp.lang.ruby)
  • Re: match string by re using some pattern
    ... [huge snip] ... for instance we parse http web page ... It isn't a pattern as far as ... #$price -> MUSIC ...
    (comp.lang.perl.misc)
  • Please help, Im a newb at perl and I cant figure this out.
    ... Basically I want to parse some C++ source code and replace some ... So I need a pattern that will match only the first " of every ... Alex ...
    (comp.lang.perl)
  • Re: Beautiful Code : Pity he didnt ask here...
    ... Looking at all those \d is kind of hard to parse also. ... way of expression that pattern is considerably clearer: ... Readability improves even more when Oniguruma allows for named captures. ...
    (comp.lang.ruby)
  • Re: Deposit on glass for framed photo
    ... If you use a RC paper or a paper with no porus substrate, the inks don't dry. ... regular pattern (one was vertical fuzzy stripes, ... glass meticulously with Glass Plus, and use a paper backing on the frame. ...
    (comp.periphs.printers)