- 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
The Java way of implementing Generics is more efficient - it's a compile time feature that doesn't bloat the resulting byte code. C# uses a C++ approach, where for every type of generic container (List<Foo>, List<Bar>) another class is generated at compile time.
Admin
But the general rule to optimization is that you can either be memory efficient or time efficient. Either approach is "good" depending on the environment.
The Java approach is more memory efficient, but not much more memory efficient. You're saving a couple of KB at most.
The C# approach is more time efficient: it's faster.
On a modern system, the C# approach is clearly better. It may waste a few KB, but when system memory today is measured in GB, who cares?
And it guarantees that you can't mix types, even when compiler warnings are disabled.
Admin
On the other hand, if everything is an Object (unless it doesn't really exist, duh), then the uninitialised state of null rears its ugly head again. This is an unfortunate consequence of the design of the language. Nothing wrong with that; all languages have compromises built into their design. However, I would argue that to have a primitive type of "boolean" that actually is a boolean, and a class type of "Boolean" that is no such thing, is simply a lie.
I tend to the KattMan side of this argument. Exuberant chucking of exceptions for something trivial such as a non-initialised boolean that, in fact, indicates a design flaw is not the way to go. (And yes, I'm aware that KattMan argues that null, defaulting to the "assumed" state, is valid "in most languages." I'd go further and claim that you cannot "assume" the state of a true boolean, and that the compiler should barf, or at least warn. But that would only work with strongly typed languages, indeed with compiled languages -- inferred typing would be fine -- and is, I suppose, my personal preference. There is no such thing as "finished state." There is only "state.")
Don't even get me started on Perl's wonderful "auto-vivification."
Admin
Wow.
I'm truly impressed by your deeply profound statement. Would you care to elaborate what you do find reproachable about certain languages and/or share your invaluable notion of what language you do deem worthy of your highly esteemed attention...
...or are you just trolling (and most likely hacking yourself along in VB and thinking of it as "programming")?
Admin
Admin
Let's see what we have here: -singleton -factory -It seems like the factory "pre-cache" its products. Since it's have a property named YES. This guy really know how to optimize -A product class that can represent a YES or NO value that is comparable to a string . Quite good for dynamic typing -An interface (IYesNo) to access all these stuffs ... A new world of boolean This is a revolution in programming. Wtf man, why is it a wtf?
Wait a minute, string parsing? Maybe he is trying to deal with "yes" and "no" in different language? Still wtf though.
Captcha: gotcha . No, you didn't
Admin
Geekwad is quite right. His/her original point was
What if you don't want data, but a model? What if the model needs to support subscribers who might be in another process written in another language running on a different server? What if you are talking to your subscribers with a lossy channel (for instance, the ultimate consumer might even be a human, who are inherently lossy) and need to keep track of your client's states as well as your own?
These are standard requirements in the big world beyond the provinces. Most of the comments on this item are just haystraw giggles.
Admin
Unfortunately, it isn't just new developers that do things like that. I've seen code that was written by experienced folks that do similarly silly things.
A simple example... image a C++ class that has two data members and one member function. It doesn't inherit from anything and nothing inherits from it. The member function sets or returns the value of the private member variable based on the value of the public member variable.
Since the class doesn't actually use any C++ capabilities (inheritance, polymorphism, etc), a simple struct would have been much more appropriate. The code base I am working with is filled with such ... things.
-V-
Admin
Admin
too YesNoFactory.getFactoryInstance().YES.getDescription().equals(array[0].toUpperCase()), too YesNoFactory.getFactoryInstance().YES.getDescription().equals(array[0].toUpperCase()).