aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Beginner Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Beginner Question" Watch "Beginner Question" New topic
Author

Beginner Question

Marco Paul
Greenhorn

Joined: Jan 24, 2005
Posts: 14
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 ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31077
    
233

Marco,
What does the code look like now:

Personally, I would leave it alone. These are true utility methods, so I don't see the benefit of abstracting the classname away.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Marco Paul
Greenhorn

Joined: Jan 24, 2005
Posts: 14
I wasn't the original developer of the class, but here is an example of some of the method definitions in the class:

Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
I doubt that's Java... It reads like C++


42
Udayan Patel
Ranch Hand

Joined: Oct 14, 2004
Posts: 94
Originally posted by Jeroen Wenting:
I doubt that's Java... It reads like C++


No it could be java, when Regular Expressions weren't available.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Java? With "bool" and "string"... For me, it has "C#" written all over


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Udayan Patel
Ranch Hand

Joined: Oct 14, 2004
Posts: 94
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: 1332
    
    2
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
Thanks all for your help!
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Beginner Question