Uncharted Territory
-
Private Shared Function GeneratePadding(ByVal Length As Integer) As String Const CharString As String = "abcdefghijklmnopqrstuvwxyz" Const UCaseCharString As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Const CharStringUse As String = CharString & UCaseCharString & "0123456789" Dim CharStringLen As Integer = Len(CharStringUse) Dim Character As Integer Dim ReturnValue As String = "" Dim x As Integer Randomize() For x = 1 To Length Character = CInt(Int((CharStringLen * Rnd()) + 1)) ReturnValue &= Mid(CharStringUse, Character, 1) Next Return ReturnValue End Function
Why
Why
Why
Why
Why?
Why?
###Why?
##Why?
#Why?
#WHY?FUCKING SERIOUSLY WHY?
Why declare Const at the function level rather than the class level?
Why then assign those two Const to ANOTHER Const?!?!?!
Why not set UCaseCharString to CharString.ToUpper() instead of typing it all out?
Why type it out AT ALL, and risk typos, missing letters or transposed letters, when you have an ASCII chart? edit: this function returns a string that's going to be hashed and used as a salt....
Why explicitly cast to an Int-- TWICE-- when it will already be cast to an Int when you assign it to an Int?
#WHYWHYWHYWHYWHY?
-
I would like to license this software.
-
You forgot:
WHY use VISUAL BASIC?!
-
WHY use VISUAL BASIC?!
for microaggressing me.Why not use...
Private Shared Function GeneratePadding(Length as Integer) As Byte() Static rng = System.Security.Cryptography.RandomNumberGenerator.Create() Dim arr(Length) As Byte rng.GetBytes(arr) Return arr End Function
-
WHY use VISUAL BASIC?!
The whole system is in VB. There is a push to move the codebase to C# over the next few years. I've come to not give a fuck other way.
Why not use...
Private Shared Function GeneratePadding(Length as Integer) As Byte() Static rng = System.Security.Cryptography.RandomNumberGenerator.Create() Dim arr(Length) As Byte rng.GetBytes(arr) Return arr End Function ```</blockquote> :heart: :heart: :heart: :heart: :heart: You're hired.
-
Why not use...
Private Shared Function GeneratePadding(Length as Integer) As Byte() Static rng = System.Security.Cryptography.RandomNumberGenerator.Create() Dim arr(Length) As Byte rng.GetBytes(arr) Return arr End Function ```</blockquote> Because you get relatively low bit density (4 bits per character) when viewed as a string. I see this type of function when people are creating identifiers that either need to be manually transcribed or need to be barcoded and they are trying to pack it into as small a space as possible without using hard to pronounce characters. Lorne's example gives almost 6 bits per character. When I do it, I usually omit the characters "1Il0O" to avoid confusion.
-
You forgot a why...
Why use VB6 compatibility functions instead of native .Net equivalents? There's no place for Mid() in 2015, even in VB.
-
@Lorne_Kates said:
Why declare Const at the function level rather than the class level?
... that's the WTF you came up with looking at that?
Also, I do that all the fucking time. If that function is the only consumer of the const value, why wouldn't you?
-
Character ranges would be useful?
@antiquarian, don't your fancy languages have those?
-
@antiquarian, don't your fancy languages have those?
You mean like this?
lowercaseLetters :: [Char] lowercaseLetters = [a..z]
-
@Lorne_Kates said:
Why declare Const at the function level rather than the class level?
INB4 someone mentions that literals are actually unnamed consts, therefore they're littered all over the place and not just the class level and function level.
-
Character ranges
And then you run your application in Poland and suddenly your padding has an ą in it.
Filed under: the collation flamewar thread is
-
... that's the WTF you came up with looking at that?
Yes, that would be one of them. Followed by all the others I listed. That's how words work.
-
-
not even
It might be if you selected the entire sentence?
-
INB4 someone mentions that literals are actually unnamed consts
What's even worse is when they aren't, and you can do things like
LET 4 = 3 IN foo
.
-
What's even worse is when they aren't, and you can do things like LET 4 = 3 IN foo.
This is a feature of Cool, isn't it?
-
No, but
1 + 1
allocates memory on the heap if that's any consolation.
-
No, but 1 + 1 allocates memory on the heap if that's any consolation.
Instead of just doing the math at compile time and sticking the result in there instead?
That's doing it wrong
-
@Lorne_Kates said:
Why not set UCaseCharString to CharString.ToUpper() instead of typing it all out?
Because some programmers don't assume that no one would ever set their computer to the Turkish locale.
-
Dude, that's not even a complete turnip.
That isn't how you spell "ice cream"
Filed under: I'm hungry.
-
-
-
-
Because you get relatively low bit density (4 bits per character) when viewed as a string.
Base64url encode it then? Or even better, of you are dealing with bytes use the bytes and get 8 bits per "character"!
When I do it, I usually omit the characters "1Il0O" to avoid confusion.
Those characters would only confuse humans, not computers, so is irrelevant. Fwiw I had to once have a base 32 code that humans would write down (product was on DVD with no nvram) and would omit OIS: mapping to 015. It also omitted U to avoid certain letter combinations!
-
It also omitted U to avoid certain letter combinations!
So it wrote things like “Belgim”?
-
-
-
Belgim
Maybe "BELG1M". If you entered "belgim" it would still work though, thanks for me being user friendly and not just returning some "invalid code" error. (Code length notwithstanding)
-
body is valid
-
Fine,
ToUpperInvariant()
.
-
No
Where do I file a feature request?
1 + 1
allocates memory on the heap if that's any consolation.Maybe. Can I do something like
if (1 + 1 = 3) { /* always done */ }
?
-
Well, the only thing that can be on the left of = is an identifier. And the condition of if needs to be Boolean. And else is syntactically required for an if expression (there are no statements).