arrowarrow Shoutbox
 
info In this area you may insert brief and quick contents that you do not deem fit or sufficiently relevant to be placed in your blog. Add new contents: click here
 
arrowarrow Currently available topics
 
Viewing only topics of: A All topics: click here
All topics: 104
Sender: A

Programming: Facing A String, Regexp. Facing Mr. Programming Apocalypse Now, Ignore.

http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Topic: 42 permalink
Visits: 2,227
When you program you deal with an issue (a problem to solve) and with an input. Those are your dinner companions.  
 
Now, if the input is a string, the first think you ought to think is: may I achieve my goal with the mere use of a regular expression?  
Only after that consideration, think about the rest.  
 
It is true that regular expressions may be resource demanding on big inputs, and thus far from optimal.  
Yet, as it often happens when we are adviced by "Mr. Programming Apocalypse Now", rarely strings fall in that cataclysmic scope.  
You know "Mr. Programming Apocalypse Now", how s/he is and thinks: those guys who advice you not to write foo=(foo<foo2)?foo:100; because you are performing an "unnecessary assignment"; true, but do you really care about that picosecond in your precious application, when you are gaining much as far as coding clarity is concerned?  
Sure, good programming rules ought to be applied at all times regardless of circumstances, just to improve the good habit: and in fact it is exactly those who don't know how and why they apply them, who are so concerned about applying them at all times. Those who know better, couldn't care less about a picosecond most of the times, and they "waste" it without particular regrets or concerns about their reputation or about the consolidation of their good habits: for they master perfectly their good and bad ones both.  
 
At any rate, facing a string, if your goal can be achieved with a regular expression, it is always worth to put that regexp in your library too, also if you eventually decide to walk a different path and propose an eventual solution to your riddle that does not rest on that regexp.
Cast your vote for this topic. «Negative Positive»
Click here to save your vote
Current average: 0.00, Voters: 0
Insufficient form parameters: you forgot to fill in some field/s You must reload the page to view the updates You did not cast a vote. You need to cast a vote by selecting a radio button. Impossible to proceed