Hello, I am slowly trying to wrap my head around the dynamics of design patterns, and I was curious if the following makes sense. A class in one of our applications has nothing but helper methods that perform regular expression validations. To me, this code is a little clugy to look at and I was wondering if using a factory would make sense in this scenario. Here is a code example i was thinking:
does something like this make any sense or am i thinking to hard about this.
Thanks! [ January 25, 2005: Message edited by: Marco Paul ]
oops, i missed bool and string part. ah! even method names starts with uppercase. Well but then patterns are suppose to be language independent. [ January 26, 2005: Message edited by: Udayan Patel ]
Warren Dew
blacksmith
Ranch Hand
Joined: Mar 04, 2004
Posts: 1328
posted
0
Marco, if you think about it, your change would replace a single simple statement with two statements wherever a validation was used. That does not seem like and improvement to me, in either C++ or Java.
Marco Paul
Greenhorn
Joined: Jan 24, 2005
Posts: 14
posted
0
Thanks all for your help!
Malli Raman
Ranch Hand
Joined: Nov 07, 2001
Posts: 312
posted
0
Originally posted by Marco Paul: Hello, I am slowly trying to wrap my head around the dynamics of design patterns, and I was curious if the following makes sense. A class in one of our applications has nothing but helper methods that perform regular expression validations. To me, this code is a little clugy to look at and I was wondering if using a factory would make sense in this scenario. Here is a code example i was thinking:
does something like this make any sense or am i thinking to hard about this.
Thanks!
[ January 25, 2005: Message edited by: Marco Paul ]
Factory Pattern is used to return one of any of its sub class objects based on the given condition. I am not sure that your code will fall in this category.