Saturday, May 5, 2007

extra credit

EXTRA CREDIT

{Anti-Patterns}

The Blob- This is when your code becomes more procedural than object-oriented. "The blob" refers to a large class that contains the majority of the processes. The remaining classes contain data. Hence, this code is procedural in that it is separating process from data. Object-oriented programming aims to integrate process and data. Typical causes include the lack of an object-oriented (or any) architecture, the lack of enforcing an object-oriented architecture, and iteratively adding functionality to existing classes rather than redesigning and creating new classes.

Poltergeists - These are classes that have very limited uses in the system. Poltergeists are undesirable because they are (i) unnecessary and waste resources when they "appear", (ii) inefficient because they use multiple navigation paths, (iii) clutter the code and make it difficult to read and organize. Typical causes include a lack of understanding of object-oriented design, trying to use object-oriented design when a different programming style is more appropriate, and management committing itself to an inappropriate architecture.

The Golden Hammer - This is when programmers fall in love with a certain solution or vendor product. Vendors often advocate extensions to these products to solve additional problems. The problem with this is that often the solution is suboptimal and relying on the "Golden Hammer" diverts attention away from exploring a better solution. Of course, a product may occasional be a legitimate "Golden Hammer", though developers should beware since most solutions are not. Several cause of the Golden Hammer anti-pattern are past successes (pride),
large investment of time or money in a particular solution, and reliance on proprietary products.

[src: "Software Development AntiPatterns" by William H. Brown, Raphael C. Malveau, Hays W. "Skip" McCormick III and Thomas J. Mowbray ]


{Regular Expressions}
The regular expression syntax for java is similar to that of Perl, and is contained in the java.util.regex API. The three main classes of this package are Pattern,Matcher, and PatterSyntaxException.

(i) Pattern
A Pattern object is a representation of a regular expression with no public constructors. Creating a pattern requires first invoking a public static compile method with a regular expression object. This returns a Pattern object.

(ii) Matcher

This object is what interprets that pattern and performs matching operations on string input. It also has no public constructors. Matcher objects are created by invoking the matcher method on a Pattern object.

(iii) PatternSyntaxException
This object is an unchecked exception that indicates that a syntax error in a regular expression.

[src: http://java.sun.com/docs/books/tutorial/essential/regex/intro.html ]