quote:
Originally posted by Improfane
quote:
Originally posted by CookieRevised
instead of using a workaround and don't allow 3 character words to be scrambled, fix your scrambler routine instead
Who are you referring to, the person who added something (J-Thread) or me?
It wouldn't be a workaround, if I were to correct my scrambler - it wouldn't fulfull the purpose of it. If you program, you should know that keeping your code modular is important, for that reason I made the scrambler routines separate from the talker.
So what he did to correct my code is fine because, he didn't modify the scrambler.
If I modifed the scrambler, it means it couldn't be used in another project that might not matter about the input length of 3.
I have a philosophy of generic and specific. Generic functions such as scramble, scramble and do only that, while everything else builds upon that to make specification. You build on the foundations.
Workarounds are quick and dirty to solve problems with the original code, this isn't it is just a matter of what should be input and not.
That is exactly what I'm talking about and why I call it a workaround...
Simply make your scrambler so it doesn't bug out on words less than 4 characters. The scrambler routine should be able to process any word _on its own_, no matter what length, _that_ is modular and generic, not how it currently is..
Using the current scrambler routine in other projects requires you to constantly do a check before parsing the word to the scrambler, in other words that isn't modular at all as you need more special code (the length check) inside the main procedure to let the scrambler routine work decently...
If I would use a generic modular code, I'd expect it to work with any input, and without the need of some extra checks before I call the routine...
At least move the length check inside the scrambler routine, not inside your main routine. But if you make your scrambler routine more streamlined it wouldn't even need a length check at all...
If you wanna make other scramblers, you'll see that the length check is part of the scrambling process, and not part of the main routine, because other scramblers could for example encrypt 2 letter words or what not...
Thus replacing the current scrambler routine with such a new one will also require you to modify the main code. Thus, not exactly what I call a "modular" or a "generic" function...