- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
Comments anyone?
.... or just be wicked:
Admin
Admin
Why reinvent the whell? The static method Concat() of the class String does exactly what it sounds like :) string result = String.Conact( string1, string2, string3, ... ); http://msdn.microsoft.com/en-us/library/system.string.concat.aspx
Admin
Dude, where's my String?
Admin
Functional programming has trade offs and benefits just like OOP. anyone who says it is 'better' without qualifying HOW and WHERE...yah there the same people who say you ALLWAYS need a finaly block even if it is empty.
managers are not programmers; managers manage, programmers program. Managers who try to program, usually can't even manage.
Admin
Admin
I have to disagree with the first rule. It's perfectly OK to change something to a function call, even if the function call is longer, if doing so centralizes knowledge in the program and there is a chance that "fact" will change. In Ruby terms, "don't repeat yourself."
It's also OK if it'll reduce coupling in a program (for example, accessors on classes)
Admin
In my opinion that's the same level as introducing "#define begin {" to help pascal programmers in programming C without learning the language.
Moral: If you don't know what a symbol in your language does, look it up. Find one of those bulky things with thousands of non-empty sheets of paper glued together. One of those can tell you what the symbol means! Don't try to make the scary symbol go away by inventing new names.
Admin
While I completely agree with you, this is one exception. Can't do that with Vectors, Matrices or Quaternions. Those classes can't contain vtables because I need to be able to take an array of vectors and pass it to the video card. At that point in time, a 3 component vector class better only contain X,Y,Z and be 12 bytes. Also considering the amount of times these functions are liable to be called per second the overhead of a virtual call begins to matter.
For higher level functionality such as D3DXFont or D3DXEffect I have exactly such an abstraction layer for. So when I need an Effect I just call Effect::create() with appropriate parameters and get either a D3DX9 or D3DX10 effect returned as necessary.
Admin
Let's be clear on one thing. TopCod3r isn't a troll. Trolls love to engage in personal attacks, and other disruptive argumentative tactics. Trolls also have no sense of humor and delight in outrage.
This is satire.
I, for one, would happily eat a baby for lunch with TopCod3r.
Admin
Admin
Admin
It's really bad hacking, but I think I have a deep emotional relationship with unless by now...
Admin
This is ambiguous. Are you saying that you would:
Admin
I have the same love affair with the ternary operator:
string message = x>0 ? string.Empty : "Parameter x must be Positive1";
Partly to run faster, mostly to confuse and infurate junior developers.
Admin
Admin
Admin
You are redefining the meaning of the word "troll".
You must think the existing definition is merely an example and suggestion
Admin
Remember, troll, with this meaning, significantly predates the web.
Admin
I am Impressed!!! A utilities company has a glossary including troll...I wonder if that somehow refers to other messages on their site
Admin
Admin
No, an array which is interpolated in a string has spaces placed between each element.
A good example of why perl is awesome and frustrating at the same time.
Admin
(shadow '+) (defgeneric + (a &rest b)) (defmethod + ((a number) &rest b) (apply #'cl:+ a b)) (defmethod + ((a string) &rest b) (apply #'concatenate 'string a b))
Admin
sub StringConcat { local $" = ";"; "@_"; } print &StringConcat ("There's", "always", "another", "way"); There's;always;another;way
Admin
FIRT!
If you read the post, he's reimplementing functions that only exist in one version of the API, because it needs to work on both versions.Admin
Many years ago when I was young and stupid I wrote a BASIC program with the line
I was thinking "(x=0) or (x=1)", but of course no matter what the value of x was, this test always evaluated to true.
Admin
Clearly the right way to do this is with a proper object-oriented design:
Then of course you would invoke it with:
This then sets us up for the brilliant (or brillant) extension of allowing a variable number of parameters by having the setters keep track of which parameters were set and then only concatenating those actually given!
The scary part is, there are probably plenty of programmers out there who would think this is a good idea.
Admin
Haha, win!
Admin
Admin
I'd rather port jonny five's code to a new platform / language than yours. Imagine all the 100s / 1000s / millions of (x % 2)==0 you'd have to convert by hand, instead of reimplementing an isEven() function or macro.
Ditto the StrConcat(). Your new language doesn't support the concatenation operator -- now whaddya do?
Admin
I for one was getting tired of the signal outweighing the noise in the comments. I'm glad we can go back to having to put up with, define, explain, and reply to trolling. Hooray.
Admin
Admin
there is a main difference between "#define begin" and "isEven(number)". #Define begin just replaces one symbol for another. It's pure renaming. Is even encapsulates the test wether a number is even or not. This can be done in multiple ways (as shown here in the forum) and can be messed up in ifs (as shown here as well). Once it is encapsulated, tested (or proven) and used everywhere, no one else can mess it up. And % is more complex than + - * or / and that means not everybody can grasp the concept and even transfer it to another concept like "even".
Admin
There, ftfy. ;) </flame>
Admin
Lyle told me he wrote a better grep to convert that exact code formation! And, er, then... a better sed!
Admin
All of you got trolled. IMHO.
Admin
Not as much as... waitaminit!
Nice try, [#REF TopCod3r]
Admin
:-( oops I did it again!! (I fixed that bug dozens of times)
Admin
Admin
Hell yeah, and extend that further - what if the target platform doesn't support addition? Easy, just define
int add(int n1, int n2) { return n1 + n2; }
And so on .....
You've got to be kidding, or trolling.
Admin
Should have made a function. Then you'd only have to fix it once.
Admin
Unfortunately, readability is mostly in the eye of the beholder, and some of the people who are teaching are not good at reading. I think that if you find yourself eschewing most of the features of your chosen language in the name of readability, then the notion of readability that you're trying to support is doing you more harm than good.
Back on topic: Not sure which language this is, but in some languages it's sometimes useful to define named functions to do dumb things, because the name of that function can be used as a callback.
If I were bringing the benefit of the doubt, that's what I'd propose was the case :)
Admin
thank you. i did not want to be the one to first bring this fact up. then again, this person admits to not paying attention in programming classes, i really doubt h or she was even awake in the theory classes.
simplest explanation of functional vs procedural programming: functional programming allows a user to treat anything as a first class rope to hang themself with. procedural programming tends to give you enough atoms to make a good, strong gallows of your very own.
Admin
oh! i can see a few issues with that! the duplication! and it's error prone when you need to add more overloads for additional parameters!
write yourself a code generator and you can easily extend this brillant function to support more parameters than you'll ever need! Without writing a single line of code!
Admin
Of course number&1 is likely 31 clock cycles faster.
Admin
(The quickest way to write a better SSDS is to wave a strong magnet over the (magnetic) disk it's stored on.)
Admin
You know there is an advantage to this. Depending on how well the language handles strings, you may want to change the way all of your concats are done say for memory utilization and performance. For example, read the article on the .NET CLR handling of strings http://blog.briandicroce.com/2008/02/04/stringbuilder-vs-string-performance-in-net/ .
Once you learn this vital lesson in .NET, you would have to find all string concats and replace them with the stringbuilder... with the function, you have only one place to make the change = NICE!!! :)
Admin
But code reuse is so important it really should have been:
(preserving the obviously intentional skipping of param3)!
Admin
Syntactic sugar and principle of least astonishment went to hell, obviously. A language platform requires you to read extra documentation because a commonly-expected-to-be-mutable type is in fact immutable -- that's no argument for inventing wrappers for everything...
I personally think that immutable strings in .net are a mistake: I'd much rather have string generate an internal representation that's very compact and "hard" to modify upon initial construction, and then when it's mutated it would switch to a representation that's cheaper/more amenable to modification. If a string class is immutable, it should not have the += operator available, pure and simple - to do otherwise is misleading. A += on a .net string instance should cause a compile-time error. I have a constant string class that I use in C++, and it sure enough it does not try to construct new strings when abused via +=. operator += is declared private and left unimplemented, so that noone is ever under an impression that it ought to be available ;)
Cheers, Kuba