Are your kids running your home?

by Erik Lane 28. September 2005 01:31

Non-tech post but well worth reading and the author is a personal favorite.

Are your kids running your home?

Tags:
Categories: Faith and Family

Zero-width negative lookbehind assertion

by Erik Lane 28. September 2005 01:12

This group contruct continues match only if the sub-expression does not match at the position on the left.

I learned how to use this yesterday.  I had some ASP files that have two tables in them.  One has an include statement just above it at the top of the file and the other had all of the content that I needed. 

<!--#include virtual="includes/file.asp"-->

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td> I don't want this table </td>

  </tr>

</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td> I want this table </td>

  </tr>

</table>

Every regex I tried that included some variation of "<table>...</table>" would return one match that included both tables.  Grrr.

In comes the negative lookbehind assertion.  I mentioned that at the top of the file, before the first table, was an include statement.  All include statements have "-->".  A negative lookbehind assertion means that it will only be returned as a match if the match is not proceeded by a specific value.

Here is my expression:  (?<!-->\s*)(<table[\x0A-\x7E]*>[\x0A-\x7E]*</table>)

Here I'm saying I want to match any table tag, its contents and the closing table tag....as long as it's NOT proceeded by a combination of white space and "-->".  The negative lookbehind syntax I'm using is "(?<!-->\s*)".  Yes, it includes the parenthesis (but not the quotes).

You can also do the opposite and only include matches that are proceeded by a specific value.  Those are called positive lookbehind assertions and that syntax would be "(?<=-->\s*)".

Tags:

Refactoring to Patterns

by Erik Lane 26. September 2005 16:28

Man, the work.  Seems like I've been busting my rear the last two weeks with just enough time to eat and sleep.  Part of the work was meeting with an integration partner in Santa Barbara, CA.  I've never been there before and man it was beautiful.  The mountains, ocean, and weather was really great.  We were able to get some solid work done but I've come home with even more work and a shorter deadline that what I was expecting.  It's a challenge but that's a good thing.

Anywho, flying back and forth gave me an opportunity to read the white paper Refactoring to Patterns which the book Refactoring to Patterns is based on.  It is very good and if you have the means, I highly recommend picking it up*.  Lots of good code samples and gives you things to look out for when you are refactoring.  He also touches on being cautious of over using patterns.  Since its not the complete book its a quicker read too.  I'm sure the book goes into much greater detail so it's now on my watch list.

 

*10 pts (??) for the movie that I'm trying to quote here w/o googling.

Tags:

Design Patterns from {CodeKeep} via Data & Object Factory

by Erik Lane 13. September 2005 15:01

Man, I'm on patterns for some reason.  Dave Burke has a good blog post on the Observer Pattern and James Avery has listed 23 patterns over at CodeKeep

I've found that the ones over at CodeKeep are just a copy/paste from Data & Object Factory.  Either way, lots of good code samples and education.

Tags:

Passing Values Between Controls

by Erik Lane 13. September 2005 09:55

If you have access to the October issue of asp.netPRO magazine check out the ControlFreak column written by Steve OrrBack in March I was trying pass data between a User Control and its page.  This article would've been another good resource at the time.

More than just covering passing data between User Controls he covers a laundry list of questions on how to pass values between pages, controls, and other objects.  He reminds us that all controls inherit from the Control class so they can all interact with each other. These are few I took note of:

  • Passing data to a user control.
  • Pass data back to the page from a user control.
  • Pass a value between two user controls.
Tags:

Design Patterns - Why and How

by Erik Lane 12. September 2005 02:03

I will be honest and say that I haven't knowingly used a Design Pattern.  Although I read a lot about them and have attended a meeting on them, I guess I just don't know enough so I can be on the lookout to implement them.  I really do like the thought of having "a general solution to a common problem in software design" or a "description or template for how to solve a problem that can be used in many different situations".  Those are the things that are appealing to me.

You read posts and articles that point out the good things and yet still say that they shouldn't be used unless it is necessary.  I agree that added complexity for the sake of complexity isn't a good thing.  I don't know about you but I can learn more by writing code than by reading about it - don't get me wrong, reading is very important and should done too.  Most times I will start off by reading but then I will hit the IDE to get my feet wet and store it away for a time when I can use this new piece of knowledge...whatever it is.  Then why and how should I learn them?

I'm about ready to get another book to read and I've been wanting to get Head First Design Patterns.  I've read that it is solid on content and easier to read than similar books on the subject.  Then I read the review over at Coding Horror.

 "Beginning developers never met a pattern or an object they didn't like. Encouraging them to experiment with patterns is like throwing gasoline on a fire. And yet that's exactly what this book does."

So which is it?  Experiment and learn or stay in the dark and not get any better?  I'm sure there is a compromise in there somewhere.  Jeremy D. Miller had previously blogged questioning why design patterns aren't common knowledge.  He received some good feedback and to help all of us out he is starting a series of posts over the next few months on Learning About Design Patterns.

 Why - "Thinking and learning about design patterns is a great way to learn the ins and outs of Object Oriented Programming...."
 How - "Write code.  Do some sort of nontrivial, personal coding project where you can freely experiment with design patterns..."
 

I think somewhere in there is a compromise between throwing gas on the fire and never lighting the match.  Jeremy's first installment is out - Dynamic Behavior with the Decorator Pattern.

Tags:

Zondervan Bible Search

by Erik Lane 11. September 2005 16:23
Both Brian and Joel mentioned it on their blogs and I think it is pretty cool.  I've always bee partial to BibleGateway but that doesn't mean I won't give the new one a shot.  Joel doesn't get religous on you but if you've read any of my blog you know I can at times...only because I care my friend.  :-)