- 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
Why stop there? You could return a vector of vectors of order vectors, or a vector of error vectors...
This could change the world!
Admin
This excerpt from the book description says it all:
"best practices" for reusable component design illustrated in Visual Basic.
Admin
Wow! I'm just waiting to see you're code posted here. You apparently have no concept of polymorphism.
The String class overrides the Object.equals(Object) method. It doesn't matter whether the reference is of type Object or of type String the method of the underlying class is called. In this case if the referenced object is of type String the String.equals(Object) method will be called.
Notice that the equals method of the String class takes as a parameter and Object not a String. This is overriding a method. This is polymorphism.
If the Vectory returned a reference to an object of type Foo and Foo had overriden the equals(Object) method then the method on Foo would be called.
Please note the capitalization of the word Object vs. the word object as the first is a reference to the type and the latter is a reference to a generic thing.
Admin
erm, correct me if im wrong, but didnt what you just write agree with what the guy you quoted said?
the code in question used '=' for the assignment, instead of '.equals()', and therefore not work?
Admin
I get "yeah for polymorphism".
This is the whole idea behind polymorphism. It will always call the method in the real class, not in the type that the variable references. If this weren't the case, how would it call any class that implemented an interface?
Admin
That's true.... you don't need the first cast
Admin
MVP, are you a "star developer"?
Admin
Aaaargh! APL?! I still occasionally wake up in a cold sweat curled into fetal position, thinking about programming APL...
My first job out of school was writing scripts for StatGraphics using APL. The entire language was a WTF...
Admin
Order Vector, Error Vector ... Vector Vector duck ...
I'm a Vector, He's Vector, mushroom cheescake Vector ... :p
isn't it blatantly obvious that a "key => value" pair mechanism (struct, associative array, dictionary...) lends itself much better than a vector for kind of data that gets passed around ...
Admin
It's funny how the first phrase kind-of sounds like a Composite pattern implementation gone very bad
Admin
dammit'
this contract is due tomorrow morning, and I've only covered half of it yet...
Admin
Sweet merciful god, somebody get this man a HashMap!
Then it would still be a WTF, but at least it would be a self-documenting WTF. [:P]
Admin
Peter Piper picked a peck of pickled vectors.
Round the ragged rocks the rat... dooorgh!
Whaaat? What do you say? I don't understand you, speak Java!
Ooh you think you're so good! "Look at me! I don't need vectors!"
SHUTUP!
Admin
You're not using the ? : operator to its full potential there.
(String)orderVector.get(orderVector.get(4).equals("shipped") ? 6 : 5);
Admin
Of course, there's the Objective-C method: invoke:withObject:
ex:
[objectOne invoke:@selector(someMethod:) withObject:object2];
For better or worse, this allows you to call any method on an object with any (single) parameter through the runtime and completely avoid compile-time checking. ("With great power comes great responsibility.")
Admin
Admin
Or, better yet, an "Order" object
Admin
Whether that's a good thing is another debate. What's less debatable is that common practice recommends validating input data and placing it into internal data structures upon entry.
Admin
I suspect the confusion comes from the fact that:
class Test {
void print(Object o) {
System.out.println("Object");
}
void print(String s) {
System.out.println("String");
}
public static void main(String[] args) {
Object o = "bob";
new Test().print(o);
}
}
Prints out "Object" becuase overloading uses reference type where as overridding uses the runtime type.
Admin
Can't do that. Too unflexible. What if you want to use the same program to do a totally different job? You have to start over writing a new program, while the clever guy just changes 250000 parameters to adjust the program (of course, he would then ask you to slightly adopt the specification for the new program, so it matches what he can actually deliver...)
Admin
or with a bit of 'pepper' for the maintainer:
poNumber = (String)orderVector.get(5 + ((!orderVector.get(4).equals("shipped")) ? 0 : 1));
putting it this way we even get a nice smiley at the end of the line.
the one with the '5' as a mouth looked kind of grumpy with my font...
Admin
Tried that, doesn't make it better.
Vector:
HashMap:
Admin
This book looks mega-scary. The first line of the abstract is enough to convince me every copy should be collected and incinerated, and the authors terminated with extreme prejudice: "Suitable for any project manager or VB software professional willing to think outside the proverbial box."
Admin
Admin
Damn. Now everyone knows...
Admin
Those buffoons with their years of experience, I'll show them !
Admin
The goggles actually worked this time.
I would love to see how you would promote this sort of software:
"OOP is handicapped by strict class types that force you to actually plan your projects out and think about what you want to do - tired of those wasted minutes of planning? Let VOP set you free!"
Admin
I'm more than a little concerned by this review of the book by "kzadora":
Damn right it's bizarre! So I take it that the author only ever uses one class called Foo. Then if you want an order, you'd use:
Another reviewer comments:
So I take it that the author has only ever written one application, that concievably does everything he could ever want. None of this using Excel to edit spreadsheets, Windows as an operating system and NetBeans as an IDE. No instead you can simply use:
WTF?!
Admin
Yeah, I know, "not everybody uses Java 1.5," but nobody here has even suggested the possibility.
Admin
Lisp actually is OO thanks to CLOS. Also, pure functional is easy to debug. Find the misbehaving function in a test case, and its the same as at runtime.
Admin
foot.action("put", "in mouth")
Admin
"Tired of watching your programmers daydream instead of typing? Are your programmers wasting valuable time THINKING when they should be WORKING. VOP eliminates the drudgery of design from programming and makes producitivity soar. Watch typing rates and LOC counts go through the roof."
Admin
Actually, true VOPness requires that we must observe the cardinal rule of unification: "An implementation containing two vectors can often be replaced by one where a third vector is employed to contain them." Of course, hard-core VOPers will surely apply this rule recursively.
Hence we would have:
Admin
Aren't there relational databases for this sort of thing?
Admin
Wouldn't (String)orderVector.get(4) mean casting the vector to a String, instead of the object returned by get(4)? Perhaps I've gotten too comfortable with generics already, but I thought the cast was (String)(orderVector.get(4)) or simply (String) orderVector.get(4) (note the space).
Admin
Erm... you do know Lisp has property lists, right?
Admin
Did the contract say anything about runtime? Just invoke a new universe each time (hardware is cheap).
DoEverything Conceivable('Make my program work', Universe);
Admin
As for the extra space, you should know by now that in Java (and almost any C-like programming language) whitespace is ignored by the compiler, except when separating keywords from other keywords and identifiers, and (obviously) inside string contants, e.g. "private static" or "int foo" -- other than that it's purely aesthetic.
public class Foo{public static void main(String[]args){System.out.println("Hello, World!"));}}
Admin
public class Foo{public static void main(String[]args){System.out.println("Hello, World!");}}
Admin
Well that is almost right. But come on, people! It MUST be "shipped".equals(orderVector.get(4)) ! We do not like NullPointerExceptions, do we.
Admin
At least the Order data isn't stored in a String with '|' characters between the data.
Nobody would ever be dumb enough to do that.
...
I wish I was joking.
Unoftunately I have seen that kind of thing in a database. Yes. Lots of tables that had only one column and data was separated with a "|" character.
I was told to do some modifications to the software. I kindly refused ;)
Admin
Admin
I think we've just struck gold here folks! An anonymous coward has submitted a whole line from the mythical DoWhatIMean.java class file. Obviously there are still a few more steps to go, but I think we're well on our way to solving some core problems in computing with this one:
public interface DoWhatIMean {
public static void doEverythingConceivable(String task, Object tool);
}
The implementation is trivial. I leave it as an exercise to the reader...
Admin
Spatial Application Design.
I love it!
Multi-dimensional programming!
Programming the Universe, one String at at time!
Admin
I've seen improved versions of that scheme. Data stored with ~ delimiters for rows and | delimiters for columns. This way you get a nested table functionality for free!
Admin
Now replace getSetOrder with ExecuteDataTable() and Vector with DataTable and you'll get similar example of the same principle, but implemented by Microsoft in .NET framework.
And you know what? Sometimes novice developers are trying to justify they shitty code by saying "But look at Microsoft, they are doing the same as me! Why shouldn't we adhere to the industry's best practices?"
Admin
There is a big difference here. Unlike those clever VOP programmers, MS doesn't know what data the users of this class will want to store in it.
Admin
Sorry I couldn’t disagree more, this is the same logic that makes people think that a program compiling without errors is the same thing as a program working.
<!--[if !supportEmptyParas]--> <o:p></o:p>
Variant data types are not prone to runtime errors, sloppy programmers using variant data types are. Strong typing is a needless psychological safety net, it slows development and doesn’t really help develop functional software, it just helps create syntactically correct code. Why to you think we are seeing an increase in the number of loose typed or untyped languages.
<!--[if !supportEmptyParas]--> <o:p></o:p>
VB.NET is a monolithic development tool and is often far too cumbersome for the job. VB6 on the other hand was the screwdriver of the programming toolkit, not always the right tool for the job, but sometime you just need a screwdriver.
<!--[if !supportEmptyParas]--> <o:p></o:p>
<span style="font-size: 12pt; font-family: "Times New Roman";">There is a lot of snobbery about VB, because it put programming in the hands of the amateur some people thought everybody using it had to be an amateur.
Admin
Welcome to the world of the novice Perl programmer...
Admin
Delphi had that monstrosity as well.... I dont know if still does.