- 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
I'm not sure what you find contradictory. First, I say that VB - or any language - allowing you to do that is retarded. And it is. Then I go on to say that the need for separate operators is retarded. Some languages make you do that, but not VB. So... I'm talking about different things here. Clearer?
Admin
etc....
Spanish = Si
Admin
But maybe the difference is too subtle. And it's all semantic, anyway.
Admin
Admin
Someone who doesn't know how to spell "semafour".
Admin
Btw, seems 1.2/3 to me.
Admin
You could have simply placed all of the buttons on a TPanel and the stock photos on another TPanel.
Then you could loop through all of the controls on each panel and never worry about having to modify the function..
procedure TForm2.ImageMouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer); var t : integer; comp : TComponent; begin t := TImage(Sender).Tag; for comp in MyButtonPanel.Controls do begin comp.Visible := (comp.Tag = t); end;
for comp in MyPhotosPanel.Controls do begin comp.Visible := (comp.Tag = t); end; end;
Then again I haven't used Delphi in over a decade.
Admin
This isn't using arrays, the original statement is basically along the lines of:
if (t = 1) set Image4.Visible to true, else set Image4.Visible to false
CAPTHCHA: transverbero - A noun that's had a sex change?
Admin
And 1 time, I coded a 30 line function in javascript, And got it right the first time. I began to question if i was god. I haven't been able to do it since, so yes... The first draft tends to be a little rough around the edges 99 percent of the time.
Admin
I don't think that's correct Nagesh.
procedure TForm2.ImageMouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer); var t : integer; begin
// glow "buttons" t := TImage(Sender).Tag;
The procedure is named IMAGEMOUSEMOVE, and the first thing he does is determine which image caused the event handler to fire; we don't have the code that he uses to assign events to this handler, but I'm guessing he assigns all the Image control's "MouseMove" events to this one handler, which is why he needs to firstly determine the sender with
t := TImage(Sender).Tag;
This is a pretty common practice in .NET as well.
Admin
Also, Derek's code has no branches, so there will be no lost cycles when the processor misses a branch prediction. Derek's code is also much smaller, and thus more cache-friendly.
More to the point, however, you haven't profiled the code, so you really don't know. Derek's 14-line function is readable, clear, and far more maintainable than the original 280-line monster. If the 14-liner is a performance problem, it can be solved by adding an extra check to see if "t" changed. That makes it probably... 15-20 lines, which is more than 14, but far less than 280.
Seriously, how long have you been coding? The "BOOL_FUNC := BOOL_EXPR;" idiom is really common, and once you recognize it, the intent is just as clear as the verbose "if BOOL_EXPR then BOOL_FUNC := true;"Admin
This whole thing would be much easier solved by just implementing a custom glow button (or using one of the million different ones already implemented).
Admin
Admin
It is a stylistic choice. Neither approach is good or bad. When you work on a legacy code base with others you sometimes need to adopt the prevalent sytle to maintain readability even if you prefer a different style of doing things.
Admin
The first draft is only shit if you throw analysis and system design out the window and jump straight into hammering out code so that some pointy headed boss can jump straight to micromanaging the crap out of you with lttle pieces of paper on a board. Wait, that is exactly what scrum and agile development is. Nevermind.
Admin
"Visible" although it looks like variable is actually property, which means it is just automatic wrapper for getter and setter. Thus no blinking will occure, the setter looks like this:
Admin
Congratulations. You're the first person in a looooong while to get a featured comment.
(looking at the general level of the commentary here, I'm not surprised)
Admin
Admin
Take a closer look at your version of the strcpy trick... It doesn't work because you left the ++ off dest.
And (just entering the willy-waving contest for a moment) it has more parens than it needs.
This is what you want, except that in the real world, only the people who write strcpy itself should possibly be worried about this. Everyone else should just call strcpy.
And either nobody else noticed, which is disappointing, or nobody else cared enough to comment, which is more disappointing.
Admin
That's right. Languages like FORTRAN and Perl are just as good as Java and C#, so really no reason to have more than one. Why did Wirth invent Pascal anyway? So 30 years later, people on the Internet could cite his name when arguing the merits of his syntax selection.
Admin
Why ain't Alex massaging another article yet?
Admin
My current "team lead" also told me to use if/else blocks instead of ?: His rationale was that it would make porting our entire Perl code base to C much easier if the need ever arose.
I've stopped listening to anything he has said since.
Yes, I know TRWTF := Perl
Admin
Admin
The task board is a perfect metaphor for tracking work to be done. People who fear openness and accountability often poke fun at the task board. Some of us prefer to build code on time, that works, rather than hide behind project managers when the failures that were baked into the GANNT chart are realized. This is why we ship software that meets users' needs, instead of releasing a year late with features that were obsolete 1 month into the 6-month analysis phase.
Admin
Admin
VB doesn't have horrible kludges....right.
Dim x As Integer = 10 Dim y As Integer = 20 Dim z As Integer = 20 x = y = z
What is x now? x is -1, y and z are unchanged.
I much prefer C#'s transitive assignment to that kludge. Booleans aren't integers.
Admin
The world is full of dinosaurs. I was sacked from one job because my boss, being an ex-programmer, had a "been there, seen it, done it" attitude towards everything.
"I was coding when you were a baby!", he would roar, before chuckling to himself and hauling his heavy mass through the office.
Being a true Microsoft fan-boy, I enjoyed using Visual Studio, and love the way other companies spend a lot of money researching more intuitive ways of using the IDE, much to my boss' chagrin. One day he had had enough. He caught me with my licensed version of ReSharper, and promptly fired me for "disruptive behaviour". I probably shouldn't have called him out about his experience with .NET but I hate those poor souls who are so desperate to appear superior to everyone else.
It is the way of the world, with some of those left after the .com bubble burst spending all their times thinking of the good old days when they were paid ridiculous sums for nothing. Thankfully, I now contract and see less bad practice but this particular TDWTF reminded me of this encounter.
Last I heard, the company had closed down.
Admin
Admin
A witty, funny, non-frist post, first post. Awesome.
Admin
So TRWTF is that they didn't store all the button/image names in XML, amirite? :)
CAPTCHA 'illum', I feel illum when I lookum at this copypaste code.
Admin
Admin
Really? I kinda thought
would get called... exactly when the mouse moves over an image.
Admin
If you do not know how to use (let alone exploit) a language feature, that does not make that feature a bug.
Criticizing a language you clearly do not understand does, however, make you at the very least an incompetent critic.
If "people are always quick to dismiss VB" could that perhaps be because its defenderz are always so utterly full of shit?
Admin
Having said that, most experienced programmers do not consider context-sensitive semantics (such as the same operator doing completely different things depending on the code around it) "better" than context-free semantics.
Admin
Admin
Well, the young whippersnapper's "solution" is certainly dysfunctional. It is hard on the seasoned programmers' mental faculties, leading to increased TCO and reduced ROI. In short, it is not enterprisey. Also, any and all capabilities to customize the individual buttons with funny copy-paste-stale-bugs are not provided. PHB not like dat.
Admin
Admin
Err that's why I recommended using a button class, but since from the looks of their code they've never seen a class nor would know what to do with it, the code was an example of the least he could do to clean up that mess without too much refactoring.
Admin
But it's way easier to read with the ( ) than without. Which is why you should add them.
Yes, any experienced coder can figure it out if they stop and think about it, but the less stopping and thinking you have to do, the more time you can spend coding (and the easier it will be to spot bugs).
I'm sure you could solve this equation:
10 + 11 / 12 * 17 ^ 2 - -3 * 15
But wouldn't it be 20 times easier if you didn't have to navigate order of operations in your head?
Admin
I wish the last statement were true.
When used in a hypothetical statement (as in a "wish") the word "were" is used instead of "was".
Admin
We need a new construct in software. When you cut and paste the pasted code maintains a link back to the original so that when a change is made to the original it automatically is reflected in the corresponding pasted code.
What fun THAT would produce!
Admin
You mean generics? Or did you mean that you want it to update the original code when the copy-pasted version is updated (and obviously breaking the links to it from other instances of copy-pastism)?
Admin
A human, in contrast, would understand context. The point was about maintainability of the old code. The fact that someone rewrote it completely is not exactly an argument in favour, even though in both cases the verb "change" was used.
Sorry, please update your semantics database to v0.2.
Admin
Explain your logic there.
Admin
It has nothing to do with my language preference. Yes, I happend to prefer C#, but I use several languages daily, including VB.NET.
It's a combination of things, perhaps to subtle for you:
First, as has been pointed out, the = operator performs different tasks depending on context. You could call this alone a kludge, but let's continue on. Secondly vb requires option strict to use strong typing. This line will either give an answer or fail to compile based on a setting somewhere else in the code. Again, this seems rather 'kludgy, but maybe acceptable to those who prefer weak typed languages or came from the old vb world and have trouble learning new things. Lastly, if option strict is not set, the code compiles and gives the value -1 for x. The value -1 is dependent on the internal representation of a boolean from pre-.net vb, while .net booleans DON'T ACTUALLY USE THAT REPRESENTATION. Convert from bool to int using .net framework methods and you get a different value. - kludge, kludge, kludge.
Admin
Either younare being ridiculous or you're trolling. Your argument is BS, though. For one, the dot operator in C# does double duty of C++'s scope resolution operator :: and indirect member reference ->, and I'm sure there's a craggy developer out there who would complain that "the same operator accessing something on the heap and also accessing a static member" leads to horrible bugs, but I would take that statement as seriously as "assignment and comparison using the same operator is horrible and context sucks". You know what language you're dealing with, so you should know its strengths and weaknesses.
Also, -1 is just all bits turned on, but who cares as long as it's not zero. It's your own fault for putting an implicit cast from bool to int in the code. If you want an int to be a certain value based on a bool condition, use if/else or the ternary operator and stop whining about how bad you are at coding in a language you don't code in. Handy tip: no matter pre-.net, post-.net, ANSI C, or anything really: a false bool to int will be 0 and a true bool to int will be something that isn't zero.
Admin
Admin
I agree backwards compatibility is pretty much always messy. I'm not trying to say vb is worthless or anything of the kind. I was just responding to the post that said vb doesn't have or need kludges. It certainly does, but probably not much more than other languages. It's true I prefer C# to vb, but that's just my preference. I used to enjoy C++ but became spoiled by C# not needing header files. F# is a fun language as well with a some awesome features and probably a few wtf's.
Admin
If Qt toolkit supported Pascal natively without using shims, I wouldn't be using C++.
Admin
Of course, the difference is in the scoping. There is no notion of "re-assignment", as it breaks referential transparency.
In other words, equality and assignment are the same things. What you are calling "assignment" is taking a first-order sentence as an axiom in a proof or function.