Re: C# Beginings
- From: "Michael Starberg" <starberg@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 11 Aug 2007 18:09:47 +0200
"Jesse Houwing" <Jesse.houwing@xxxxxxxxxxxxxxxx> wrote in message
news:21effc90da398c9aa5678db3ca9@xxxxxxxxxxxxxxxxxxxxx
Hello Michael,
Hello Jesse
This is also partly due to the fact that:
- people don't know enough of regular expressions to use a truly good
tactic
Indeed!
to tackle the problem (usually leading to enormous expressions)
No Shit! =)
- people never embed comments in regular expressions (?#.....)
comments, comments, comments!
- poeple never use verbatim strings in C# to make their expression
readable
RegExps readable? What planet are you from, dilbert? *S*
- even the best C# programmers usually try to avoid regex (and
parser/scanners for that matter) like the plague, never truly mastering
the technique.
Too me more serious, you really have to master it.
- I would trust a Sensei in RegExps creating good ones.
Too bad that most coders suck at it. =)
- if you've had to maintain expressions from others, you probably hate
regex by now, while you should hate the others in fact
I hate the lame coders, that thinks they mastered it. Not RegExp per se.
So these are the rules for Regex use:
- Use them right
Thanks Master of The Obvious. =)
- make them as simple as possible
Yes
- split the problem into multiple expressions, use passes for easch step
in the validation (as you would do in C#)
Hmm. That would give a O(N) or even a O(N^2) problem.
If you need several expressions, RegExps are not the way to go. Use for,
foreach and while instead... .. ...
- combine the strength of regex with the raw power of C# when needed,
don't try to do everything with an expression. (also don't try to do
everything with string manipulation)(or is that part of use them right)
.... which we tend to agree with. =)
- comments, comments, comments (or is that part of make them as simple as
possible)
Jesse
The guru Knuth said:
- Whenever you feel the need to comment your code, check your code and see
how you can improve it to get rid of the comment.
Knuth has obviously never done any RegExps. =)
who has been teaching a regex class for the past 3 years and can still be
surprised by both the strange things people try to do with regex and the
powerful expressions I'd never before thought possible.
And I am calling it RegExps. Silly me.
Is the first lesson all about that it is called 'regex' and not 'RegExp'?
For real Jesse, thanks for a great post.
My Best Regards
- Michael Starberg
.
- References:
- Re: C# Beginings
- From: Michael Starberg
- Re: C# Beginings
- From: Jesse Houwing
- Re: C# Beginings
- Prev by Date: Re: Securely accessing an Access 2007 database...and are Access 2007 databases secure?
- Next by Date: How to Convert double to bytes?
- Previous by thread: Re: C# Beginings
- Next by thread: Re: C# Beginings
- Index(es):
Relevant Pages
|