Comment On StripChar() = "Extreme NIH"

For those not aquianted with NIH, it stands for Not Invented Here and refers to the tendancy of programmers to avoid using third party tools because, after all, it's something that they could write themselves. I'd bet that it's something that we're all guilty of doing at least once or twice. But I can honestly say that I have never developed my own version of a built-in function, unlike the author of this VB6 function sent in by Eric: [expand full text]
« PrevPage 1Next »

re: StripChar() = "Extreme NIH"

2004-06-08 15:03 • by Mike Raiford
Actually,

This *could* be a hold over from the VB5 days when there was no such thing as a replace function.

re: StripChar() = "Extreme NIH"

2004-06-08 15:19 • by Jim Bolla
Even still, they could've replaced the implemenation of the function to just use Replace, even if they wanted to leave the method in there.

re: StripChar() = "Extreme NIH"

2004-06-08 15:48 • by David Burton
check out this function written by a Sr. Dev where I work, he could have user Replace(str,"'","''")

'Function: QuoteForFilter
'Description: This function returns the passed string with single quote(')
'characters replaced with two single quote characters. Prepares the
'string to be used as part of a RowFilter expression.
'For example:
' QuoteForFilter("PIG'S FEET") returns "PIG''S FEET"
Private Function QuoteForFilter(ByVal criteria As String) As String
Dim alCharBuffer As New System.Collections.ArrayList(criteria.Length)
Dim c As Char

For Each c In criteria
alCharBuffer.Add(c)
If c = "'"c Then
alCharBuffer.Add("'"c)
End If
Next
Return New String(CType(alCharBuffer.ToArray(GetType(Char)), Char()))
End Function

re: StripChar() = "Extreme NIH"

2004-06-09 00:05 • by FistyTheFerret
Although piss funny, I'm with Mike.

After developing a whole lotta shit in j1.4 I find out that the client is still on 1.3 (yes, I believed them when they said 1.4). As a result I had to write my own split and replace functions.

re: StripChar() = "Extreme NIH"

2004-06-09 08:20 • by Richard
The mobile JVM for WinCE we're using implements java 1.1 spec. How much NIH do you think we have _had_ to do...?!?

Before you ask, I don't know why we're using Java on PocketPC either.

re: StripChar() = "Extreme NIH"

2004-06-09 09:39 • by Eric
"This *could* be a hold over from the VB5 days when there was no such thing as a replace function."

It wasn't. The first version of this software was written in VB6 SP5.

re: StripChar() = "Extreme NIH"

2004-06-09 12:22 • by Mike Raiford
"It wasn't. The first version of this software was written in VB6 SP5"

Like I said.. it could be. Obviously, this was not the case in this instance.

Heh, I remember how relieved I was when I found out VB6 had a replace function. That meant I could rip out the several dozen instances of the function from our software ;)

Why someone would ever want to roll their own on something like this in VB is incredible. This is slower (and obviously, more complicated) than just using Replace.



re: StripChar() = "Extreme NIH"

2004-07-20 04:55 • by James
jesus h christ! or you could do something like:

$somestring =~ s/[c]+//g;

in a language with Perlish regular expressions, where c is the character to whack.

re: StripChar() = "Extreme NIH"

2004-10-16 16:43 • by plugwash
modern languages have a huge number of builtins

this does not mean that every coder knows every builtin of every language they use

Re: re: StripChar() = "Extreme NIH"

2005-11-27 19:30 • by Crusty
51885 in reply to 22313
Anonymous:
modern languages have a huge number of builtins



this does not mean that every coder knows every builtin of every language they use







That's what language/function references are for.



One of the most reliable ways to produce WTFs is to code without a net manual.

Re: StripChar() = "Extreme NIH"

2005-11-27 23:11 • by BPFH
We've got a boatload of code where I work that exhibits this
quality.  I stripped a good deal of it out a couple of years ago,
but our most persistent offender (used in far too many places to
remove) is CopyChars().



CopyChars() is basically strncpy().

Re: re: StripChar() = "Extreme NIH"

2005-11-29 10:54 • by FredSaw
52037 in reply to 51885

Anonymous:
That's what language/function references are for.


Okay, but you have to get your coffee and settle into your easy chair and read the reference from front to back.  Either that or study all of the "What's new?" section of the documentation.  You can't just go looking up new keywords by intuiting them. 


Imagine our author above, moving from VB5 to VB6 and hoping they've added a character removal routine, so he does a search on "stripChar", "charStrip", "charRemove", "stringRemove", "charDelete", and any other targets he can think of that would describe removing a character from a string.  But because he's trying to remove a character, not swap it for something else, it never occurs to him to look for "replace".

Re: re: StripChar() = "Extreme NIH"

2005-11-29 13:51 • by Otto
52049 in reply to 52037

That's a good theory, except that googling for "vb6 remove characters from string" gives you this as the first result: http://www.codeguru.com/vb/gen/vb_misc/text/article.php/c2739/


Google. It's like the ultimate reference manual.

Re: re: StripChar() = "Extreme NIH"

2010-10-01 08:57 • by tharpa
323839 in reply to 52049
Otto:
That's a good theory, except that googling for "vb6 remove characters from string" gives you this as the first result: http://www.codeguru.com/vb/gen/vb_misc/text/article.php/c2739/
Google. It's like the ultimate reference manual.


I wonder if he wrote his solution faster than you could implement something you found via a search engine.

Re: StripChar() = "Extreme NIH"

2012-05-10 05:38 • by Fausto (unregistered)
Reinventing the wheels isn't necessarily a bad thing to do.

In some languages, like AS3, building your own version of built-in methods can be very useful, especially if you're looking for soem performance improvements.

A good example of this would be to inline your own version of Math.abs() or pretty much anything of the Math class.

Not having to call the method from an external class and doing some improvements (like building some bitwise hell) can result in a method that returns the same than the built-in one, but that will also run hundreds (and sometimes thousands) of times faster.

« PrevPage 1Next »

Add Comment