Regular Expressions, Reverend Jim Ignatowski and You

Posted: July 30th, 2010 | Author: | Filed under: Regular Expressions | 4 Comments »

Regular Expressions

I use regular expressions just often enough to have to totally re-learn them every time I need to use them. After a round of Google searches, reading over a few good regex sites (here’s one) and a bit of head scratching and code tinkering I end up with the code I need.

In this particular case I needed append a variable with punctuation in cases where the variable ended in an alphanumeric character. Regex to the rescue!

1
2
3
4
5
6
7
<cfset variables.question = "what does the yellow light mean" />
<cfif ReFindNoCase("[a-zA-Z0-9]$", variables.question )>
     <cfset variables.question = variables.question & "?" />
</cfif>
<cfoutput> 
     #variables.question #
</cfoutput>

Reverend Jim Ignatowski

This has nothing to do with regular expressions, but it’s a classic moment from Taxi.

You

The next time you need some regex help you may want to check out http://www.regular-expressions.info. If you have any good regex tips or sites leave them in the comments below. As usual, spammers will be shot on site.


I’m Just Sayin’: Firebug Break Points Are Cool

Posted: July 22nd, 2010 | Author: | Filed under: I'm Just Sayin' | No Comments »

http://getfirebug.com/doc/breakpoints/demo.html


Firefox Add-Ons

Posted: July 21st, 2010 | Author: | Filed under: Firefox | No Comments »

I’m into my first week at my new job and I’ve been spending some time getting my workstation setup.  This task includes getting Firefox installed and adding some key Add-Ons.  Here’s my list…

Hopefully you will find some of these helpful.  Have I missed anything cool?  Please post your favorites in the comments section.  Cheers!

UPDATE
August 2nd, 2010

Two Firefox Add-Ons that every web software developer should have are The Firefox Accessibility Extension and Total Validator


CFUnited

Posted: July 21st, 2010 | Author: | Filed under: ColdFusion | No Comments »

It’s hard to believe, but this year’s CFUnited will be the last. I had a chance to attend CFUnited a few years ago and found it to be fun and inspiring.

I urge my fellow ColdFusion developers to take advantage of CFUnited this year (while it’s..sniff…still here).  As always the speaker and topic lineup is top notch.


The Strategy Pattern

Posted: July 7th, 2010 | Author: | Filed under: Design Patterns | 2 Comments »

I’ve read and coded my way through the first chapter of Head First Design Patterns and enjoyed working with the MiniDuckSimulator sample. The author(s) make a good case for favoring composition over inheritance. I look forward to understanding this concept on a deeper, actionable level as I continue onto Chapter 2. I’ve included some (but not all) of my code from Chapter 1…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* 
MiniDuckSimulator.java
creates a new instance of MallardDuck and ModelDuck 
and demonstrates the different behaviors of each
*/
public class MiniDuckSimulator{
	public static void main(String[] args){
 
		System.out.println("-- new MallardDuck instance...");		
 
		Duck mallard = new MallardDuck();
		mallard.performQuack();
		mallard.performFly();
 
		System.out.println("-- new ModelDuck instance...");		
 
		Duck model = new ModelDuck();
		model.performFly();
 
		//		now he can fly!
		model.setFlyBehavior(new FlyRocketPowered());
		model.performFly();	
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
/* 
MallardDuck.java
a duck that has wings and can quack
*/
public class MallardDuck extends Duck{
 
	//	constructor
	public MallardDuck(){
		quackBehavior = new Quack();
		flyBehavior = new FlyWithWings();
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
/* 
ModelDuck.java
a duck that cannot fly
*/
public class ModelDuck extends Duck{
 
	//	constructor
	public ModelDuck(){
		flyBehavior = new FlyNoWay();
		quackBehavior = new Quack();
	}
}
1
2
3
4
5
6
7
/*
FlyBehavior.java
the interface!
*/
public interface FlyBehavior {
	public void fly();
}
1
2
3
4
5
6
7
8
9
/*
FlyNoWay.java
implements FlyBehavior
*/
public class FlyNoWay implements FlyBehavior{
	public void fly(){
		System.out.println("I can't fly :(");
	}
}
1
2
3
4
5
6
7
8
9
/*
FlyRocketPowered.java
implements FlyBehavior
*/
public class FlyRocketPowered implements FlyBehavior{
	public void fly(){
		System.out.println("I'm flying with a rocket");
	}
}

Diving Head First Into Head First Design Patterns

Posted: July 6th, 2010 | Author: | Filed under: Design Patterns, O-O | 1 Comment »

Over the last few days I’ve been sinking my teeth into Head First Design Patterns. I’m really enjoying both learning about Design Patterns as well as slinging some Java code.