Comment On Important-Function(), IsNumber(), and More()

" "I found a function called 'Important-Function' in a colleague's PowerShell script," wrote B. Versteylen, "after expanding the function, I discovered this." [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Important-Function(), IsNumber(), and More()

2011-04-04 18:17 • by Jenema (unregistered)
343238 in reply to 343193
boog:
fake boog's sock puppet:
boog:
So "merde!" means campfire? I don't get it.

Your an idiot.

And you need a new act, my transparent troll.


Don't woory booger, I thought you was funny (for once)

Re: Important-Function(), IsNumber(), and More()

2011-04-04 18:26 • by Banna (unregistered)
343239 in reply to 343196
hoodaticus:
<snip loads of stuff>
Here's an example:
class blah 

{
Item _item;
blah(Item item) { _item = item; /* what would this do without case sensitivity?*/ }
Item Item { get { return _item; } set { _item = value; } }
}


Without case sensitivity, you need to be an expert in the compiler to predict what it will do.


Although I agree that Case-Sensitivity is a wonderful way of ensuring you know what you are doing, I'm not sure whether calling an Item item would be allowed in a case insensitive language.

If nothing else, I think Case-Sensitivity aids readability, not just because there is a consistency with each instance, but because it allows using standards to distinguish between Constants, variables, methods etc. Although this is still possible in case-insensitive languages, insisting on case ensures that this standard (if used) is used for each occurrence aiding readability and therefore maintainability.

(I'm not a big fan of instance variables mimicking Object names in different case - although I suppose as a parameter to a method it might make sense (eq myObject.equals(Object object); )).

Re: Important-Function(), IsNumber(), and More()

2011-04-04 20:34 • by Mike (unregistered)
I'll fix that boolean code!

if( ( ( value == true ) == true ) || ( ( value == false ) == true ) ) {
...
}

Just remember one thing: You can't write too much code that compares booleans against true and false.

Re: Important-Function(), IsNumber(), and More()

2011-04-04 21:26 • by chrismcb
343241 in reply to 343150
Serial Public Interface:
The important function, could lay dormant in an application for years before someone thought to look at the logs, then realise like all logs, they are useless when the debug code and the release code do not use the same stack traces.



You put stack traces in your logs?

Re: Important-Function(), IsNumber(), and More()

2011-04-04 21:27 • by chrismcb
343242 in reply to 343194
eternicode:


Obviously floats and doubles don't count as numbers.


Obviously negative numbers don't count either.

Re: Important-Function(), IsNumber(), and More()

2011-04-04 21:50 • by TK (unregistered)
343244 in reply to 343184
Mike:
Anonymous:
C-Octothorpe:
hoodaticus:
That last sample is some really good VB.NET alright.

Can you really do _ for line continuation in C#, and if you do, will boog strangle a penguin?


boog will strangle the penguin no matter what. I think we all know that by now...

And no, you can't do _ for line continuation because *dusting off my flamewar hat* C# is a REAL language which doesn't require hand-holding like this.

zis comment is merde!

Almost, but not quite - you don't need _ in C# because C# is a REAL language that has line terminators. Hence if you don't terminate the line, you can flow onto the next without requring an explicit continuation symbol. What kind of merde language doesn't have line terminators?
Python.

:)
Indeed. I used to prefer ; as a command terminator until I learned Python. The kicker for me was that I noticed the Perl version of my Python scripts (with roughly the same number of lines) contained far more ;'s in Perl then \'s in Python.

Python's reliance on line continuation is much aided by the fact that unbalanced (), [], or {} imply line continuation. So, in practice, my multi-line Python code rarely requires a line continuation character.

Re: Important-Function(), IsNumber(), and More()

2011-04-04 23:00 • by the beholder (unregistered)
343245 in reply to 343239
Banna:
hoodaticus:
<snip loads of stuff>
Here's an example:
class blah 

{
Item _item;
blah(Item item) { _item = item; /* what would this do without case sensitivity?*/ }
Item Item { get { return _item; } set { _item = value; } }
}


Without case sensitivity, you need to be an expert in the compiler to predict what it will do.


Although I agree that Case-Sensitivity is a wonderful way of ensuring you know what you are doing, I'm not sure whether calling an Item item would be allowed in a case insensitive language.

If nothing else, I think Case-Sensitivity aids readability, not just because there is a consistency with each instance, but because it allows using standards to distinguish between Constants, variables, methods etc. Although this is still possible in case-insensitive languages, insisting on case ensures that this standard (if used) is used for each occurrence aiding readability and therefore maintainability.

(I'm not a big fan of instance variables mimicking Object names in different case - although I suppose as a parameter to a method it might make sense (eq myObject.equals(Object object); )).
While VB has plenty WTFs to go about, this was the one thing Microsoft did well: It is case-insensitive, but once you define an identifier one way e.g. SimpleSocketCollectionFactory from then on you can type it as SiMpLeSoCkEtCoLlEcTiOnFaCtOrY or any other case, and the IDE will autocorrect the identifier. Reserved words autocorrect too.

The good thing about it is that you'll never have a moron write hoodaticus's code snippet, because Item would be either the class, the instance, or the method, but not all of them. (OTOH, other WTFs are still available to the moron)

There's a way around if you are evil enough, but I can't remember what it is anymore.

Re: Important-Function(), IsNumber(), and More()

2011-04-04 23:20 • by Sudo (unregistered)
343246 in reply to 343178
frits:
Steve The Cynic:
Anonymous:
Didn't you do French in highschool? I knew "merde" and I also know "foutre le camp", but these are literally the only French words I remember (clearly it was a very useful class).

I live in northern France, and a more common "bad word" around here is "putain". The literal sense is "whore", but it gets used for just about anything, including as a general assertion of frustration.

For emphasis, "putain de merde" works as well...


Shitwhore would make a great band name.
Turns out there's a band on MySpace called "Shitwhores". They suck worse than Akismet.

Re: Important-Function(), IsNumber(), and More()

2011-04-04 23:26 • by Sudo (unregistered)
343247 in reply to 343240
Mike:
I'll fix that boolean code!

if( ( ( ( value == true ) == true ) || ( ( value == false ) == true ) ) != false ) {
...
}

Just remember one thing: You can't write too much code that compares booleans against true and false.
That's better... you almost missed one!

Re: Important-Function(), IsNumber(), and More()

2011-04-05 00:06 • by S (unregistered)
I have to agree. The worse VB.NET code gets, the more it looks like C#

Re: Important-Function(), IsNumber(), and More()

2011-04-05 05:44 • by itsmo (unregistered)
343250 in reply to 343189
justsomedude:
boog's sock puppet:
boog:
So "merde!" means campfire? I don't get it.

Your an idiot.


*You're



Yor

Re: Important-Function(), IsNumber(), and More()

2011-04-05 06:16 • by Level 2 (unregistered)
343251 in reply to 343153
Anonymous:
C-Octothorpe:
hoodaticus:
That last sample is some really good VB.NET alright.

Can you really do _ for line continuation in C#, and if you do, will boog strangle a penguin?


boog will strangle the penguin no matter what. I think we all know that by now...

And no, you can't do _ for line continuation because *dusting off my flamewar hat* C# is a REAL language which doesn't require hand-holding like this.

zis comment is merde!

Almost, but not quite - you don't need _ in C# because C# is a REAL language that has line terminators. Hence if you don't terminate the line, you can flow onto the next without requring an explicit continuation symbol. What kind of merde language doesn't have line terminators?

All languages have line terminators. All languages have statement terminators. In some languages they are the same character.

Re: Important-Function(), IsNumber(), and More()

2011-04-05 06:25 • by methinks (unregistered)
Who is this Jessica in Berlin?

Re: Important-Function(), IsNumber(), and More()

2011-04-05 08:14 • by Anonymouse (unregistered)
343253 in reply to 343150
Serial Public Interface:
The important function, could lay dormant in an application for years before someone thought to look at the logs, then realise like all logs, they are useless when the debug code and the release code do not use the same stack traces.



It looks as if he's simulating a log entry in the terminal window. This code does not log at all. Probably the real actions are logged like "Log-Function $logTime "Applying action X" instead of using Write-Host.

Captcha: aliquam - A question asked Ali

Re: Important-Function(), IsNumber(), and More()

2011-04-05 08:57 • by QJ (unregistered)
TRWTF is the tortuous way the random numbers are used?

Re: Important-Function(), IsNumber(), and More()

2011-04-05 11:11 • by hoodaticus
343313 in reply to 343235
Jimminfy:
hoodaticus:
Vilx-:
I wonder - I'm not a C++ expert, but the PrBoolFlag function - if the inbool was obtained via some memory-magic manipulations (like casting an int* to a bool*); and they used some weird compiler for an embedded software (which might be since it seems to have something to with printers); could it not be that it was possible for the value to actually be something that the compiler doesn't recognize as either true or false?
That is compiler dependent.

Is that not his point?
Assertions do not usually end in question marks. Shall I elaborate? Some compiler versions implement bool C-style, so for those compilers, you only have two possible states of a boolean. For the rest, it might be possible.

Re: Important-Function(), IsNumber(), and More()

2011-04-05 11:11 • by hoodaticus
343314 in reply to 343235
Jimminfy:
hoodaticus:
Vilx-:
I wonder - I'm not a C++ expert, but the PrBoolFlag function - if the inbool was obtained via some memory-magic manipulations (like casting an int* to a bool*); and they used some weird compiler for an embedded software (which might be since it seems to have something to with printers); could it not be that it was possible for the value to actually be something that the compiler doesn't recognize as either true or false?
That is compiler dependent.

Is that not his point?
Assertions do not usually end in question marks. Shall I elaborate? Some compiler versions implement bool C-style, so for those compilers, you only have two possible states of a boolean. For the rest, it might be possible.

Re: Important-Function(), IsNumber(), and More()

2011-04-05 11:37 • by hoodaticus
343318 in reply to 343230
boog:
boog (cheap imitation):
boog:
boog (cheap imitation):
C-Octothorpe:
Since when did this site degrade into The Daily Retarded Trolling Attempt?

I know I started when I saw one of boog's idiotic comments featured.

In other words, somebody submitted some code he wrote to this site, and I posted a mean comment about it.

This and this. I'll let the internet jury decide whose guilty of the bigger idiocy: boog or Remy.
How stalkeresque. You certainly like to keep track of my posting habits.

Kind of disturbing really, but a little flattering.
It gets more disturbing the more you think about it.

Re: Important-Function(), IsNumber(), and More()

2011-04-05 13:30 • by It's a-me, Mario! (unregistered)
343358 in reply to 343255
QJ:
TRWTF is the tortuous way the random numbers are used?


It's been build so there's a random (1% per run) chance to call a random (out of 15) phrase.

Captcha: paratus - the missing part when it is shortened to "ap."

Re: Important-Function(), IsNumber(), and More()

2011-04-06 00:55 • by Zoc (unregistered)
343398 in reply to 343149
bsaksida:
I can not see the link to youtube site. Unavaible in my country due to publisher limit
It's a Ladytron song, with the lyrics: Destroy everything you touch / Today / Destroy me / This way

Maybe this one will work for you: http://www.metacafe.com/watch/304991

Re: Important-Function(), IsNumber(), and More()

2011-04-06 06:17 • by Azarien (unregistered)
I wonder if John Connor has been destoried properly.

Re: Important-Function(), IsNumber(), and More()

2011-04-06 09:54 • by Design Pattern (unregistered)
343433 in reply to 343242
chrismcb:
eternicode:


Obviously floats and doubles don't count as numbers.


Obviously negative numbers don't count either.

+1

Re: Important-Function(), IsNumber(), and More()

2011-04-06 11:38 • by EvanED
343492 in reply to 343244
TK:
Indeed. I used to prefer ; as a command terminator until I learned Python. The kicker for me was that I noticed the Perl version of my Python scripts (with roughly the same number of lines) contained far more ;'s in Perl then \'s in Python.

Python's reliance on line continuation is much aided by the fact that unbalanced (), [], or {} imply line continuation. So, in practice, my multi-line Python code rarely requires a line continuation character.

I write a bit of Python, and I haven't had an explicit \ in my code for ages. There have been a few times where I've inserted extra () to avoid them (I prefer that solution), but even that's rare.

I feel like I went into Python with an open mind about the line endings and indentation-sensitivity. I wound up liking not needing semicolons and rather disliking the indentation thing. (IMO it makes editing harder, and I've definitely seen websites complete destroy the meaning of Python code by not preserving the indentation.) I do sometimes wonder if the time I spent with Basic back in the day contributed to my like of the line-ending thing.

Needs moar evil!

2011-04-06 16:49 • by DaveK
343566 in reply to 343198
hoodaticus:
Coyne:
hoodaticus:
Coyne:
hoodaticus:
Coyne:
My favorite is "destroyEverythingYouTouch". That pattern will be very useful in the future. I plan to create all of these:
/*snip*/ int increment(int &x) { return x--; }

I like this one, especially since it returns x, which allows you to read x's value, and then, after you read its returned value, it decrements it.


Exactly: Neither the return nor the change to x counts as an increment. The name is a doubled lie.
How about:
return ++x----;


That's not right. The routine's name is "increment". Following the pattern we must therefore do anything but increment (and preferably exactly the opposite of that).
I was merely attempting to make it appear as if it incremented, but then decrement it back after the return.
I agree, if it returns the wrong result, people would notice something was up with it straight away, it would be far more evil to return the correct result so that they won't notice x has changed until the /next/ time they try to use it which could be much much later. By which time your function will have made its escape and be miles from the scene of the crime.

Your syntax is way off though. You can't combine the inc/dec operators like that because they need an lvalue to work on, and after the first one has been applied you don't have an lvalue any more, just the result of that first operation, which is a plain old integer rvalue. So you can't write "x++++" for the same reason that you can't write (e.g. if x == 3 to start with) "4++".

What you were looking for is "return 1 + x--;".

Re: Important-Function(), IsNumber(), and More()

2011-04-07 05:42 • by Dave (unregistered)
The inBool one accidentally had a comment line removed:


if ( (inbool == true) || (inbool == false) ) {
value = inbool;
retval = 0;
} else {
// inbool == FILE_NOT_FOUND

printf("\n???SW.ERROR:Printer/PrIntDpi: illegal 0 \n");
retval = CPERR_BoolArgBad;
}


FTFY.

Re: Important-Function(), IsNumber(), and More()

2011-04-07 09:47 • by hm (unregistered)
Isn't it vital to know which way to destroy things?

private function "destroyEverythingYouTouch" {

today();

destroyMe();

thisWay();
}

Re: IsNumber()

2011-04-10 09:30 • by Nutster
Bool IsNumber (string str) 

{
return str _
.Replace ("0", "") _
.Replace ("1", "") _
.Replace ("2", "") _
.Replace ("3", "") _
.Replace ("4", "") _
.Replace ("5", "") _
.Replace ("6", "") _
.Replace ("7", "") _
.Replace ("8", "") _
.Replace ("9", "") _
.Length == 0;
}

There are two things that jump out at me here.

1. IsNumeric was left out of VB.Net 1.x! What were they thinking? Were they thinking? Probably, not; it is Microsoft after all. They finally put it back in version 2.

2. This thing has a false positive with a null string ("") and false negatives with -5, 3.4, 2e5, 3e+4, etc. Adapting this general design to allow these, however, would allow invalid strings like "3..4", "-e5", "3+4", etc.

You actually have to break the string into fields (leading, integer, decimal point, fraction, E, exponent) to parse this properly without a built-in function.

Re: Important-Function(), IsNumber(), and More()

2011-04-28 12:15 • by zenstain (unregistered)
345669 in reply to 343181
trtrwtf:
Coyne:
hoodaticus:
Coyne:
My favorite is "destroyEverythingYouTouch". That pattern will be very useful in the future. I plan to create all of these:
/*snip*/ int increment(int &x) { return x--; }

I like this one, especially since it returns x, which allows you to read x's value, and then, after you read its returned value, it decrements it.


Exactly: Neither the return nor the change to x counts as an increment. The name is a doubled lie.


It's the opposite of an increment. It's an excrement.


I am stealing this. Thank you.

Re: Important-Function(), IsNumber(), and More()

2011-05-30 16:07 • by Max E. (unregistered)
The sad thing about the PrBoolFlag function is, it doesn't handle FileNotFound.
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment