|
Of course it wouldn't make sense in neither C++ nor C# code. But since VB doesn't require case expressions to be constant, the syntax above is acceptable. Anyway it's not just your opinion -- I find this odd and confusing too. On the other side, I am not a VB guy and maybe it's normal to them and you have to get used to Switch (True) mess.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Perhaps more interesting would be a use I've seen suggested for "Catch ... When" in vb.net: have the "When" clause invoke a function which logs the exception and always returns true (if the goal is to catch the exception, but use a centralized logging facility) or always returns false (if the goal is to log the exception and related information without having to catch and rethrow the exception).
|
|
|
|
|
Think of it as If ElseIf statements with uniform indentation of the conditionals.
Of course in this case it could be reduced to:
If [failure condition 1] Then _
Throw New Exception("Condition 1 failed.")
If [failure condition 2] Then _
Throw New Exception("Condition 2 failed.")
'etc...
'Success!
But in defence of Select Case True , it used to be the easiest way to get short-circuiting in VB6. Could this code have been around long enough to have been converted?
Regards,
Mark Hurd, B.Sc.(Ma.) (Hons.)
|
|
|
|
|
So, I'm doing a C++ class.
As I taught myself a few things in C++ and am a prper C# programmer, the first of three months is nothing but child's play.
But the problem is the teacher.
Whenever I try to do something like it's donw right, using good practices, he tell me it's not right in his course and after a short discussion where I try to tell him how it's done properly, he always says "but not in my class".
Every time I ask him something a tad more advance then what he's currently teaching, he complains about me using such advanced techniques and makes me use some beginner's stuff that is plain wrong.
The best is that he always complains and argues about my data encapsulation.
It started when he told me get and set methods were bad and I should always make every meber public, except the rare case that I have actual checking done in these methods.
And now, I created a program for the current project with a 3 tier architecture, data, console in/output and file in/output.
Yet he tells me I shouldn't and it's wrong and made me dump all methods into the data classes.
I tried to explain him that this is the right way, but as always he only tells me what he teaches is right, of course he doesn't have experience working as programmer at all but always only taught it.
I abide, because it takes only a handful minutes for me and I don't want to risk getting a lower grade because I didn't do what he said.
Did I mention that he doesn't even try to understand when don't do things 100% exactly as he says?
He just says "sorry, I don't understand" and leaves, without even looking once at the code.
But, the good part is that it's only one more week.
Monday after next I'll have a new teacher and start with C++ windows programming, I really hope that new teacher isn't such a blockhead.
modified on Friday, March 13, 2009 10:15 AM
|
|
|
|
|
That's not a coding horror; that's a teaching horror. Show some examples of what he thinks is good code.
|
|
|
|
|
Megidolaon wrote: The best is that he always complains and argues about my data encapsulation.
It started when he told me get and set methods were bad and I should always make every meber public, except the rare case that I have actual checking done in these methods. Sigh
And now, I created a program for the current project with a 3 tier architecture, data, console in/output and file in/output.
Yet he tells me I shouldn't and it's wrong and made me dump all methods into the data classes.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
The code itself is okay, but he disallows all good practices I try to use.
|
|
|
|
|
I had the same thing on my university. However I just did things 100% exactly as they wanted. Senior teachers are not a material which can be reformed, so just botch all these homeworks up, pass a damn exam and go for a beer.
And yes, I was supposed to put "Write" and "Save" methods in data containers...
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Yeah, I do as he says, no use in fighting back.
That's why I made this topic, to vent my anger...
|
|
|
|
|
He's actually a very good teacher.
The lesson here is to prepare you for dealing with your future pointy haired boss[^] that will be telling you to do far more incomprehensible things on a daily basis.
|
|
|
|
|
If I ever encounter such a boss, I'll get a new job.
|
|
|
|
|
a wise man once said
"those who can DO... those who cant TEACH"
very true sometimes... although thankfully there are exceptions to this rule
|
|
|
|
|
But the flip-side is, "you haven't truly mastered a subject until you've taught it".
|
|
|
|
|
I disagree with your attitude about the class.
There are situations where it's appropriate to use a 3-tier architecture, or to wrap public members into accessor methods. But you need to know how to do things the simple way before you can start thinking about these things.
And there are plenty of situations outside class where the "right" way is actually wrong. There are still many environments targetted by various C / C++ compilers where space is still quite limited, and in those cases we must not introduce architectural features that don't add new functionality.
As for the 3-tier architecture, this has no place whatsoever in a class assignment or in any other small program. If you're designing a system which is reasonably complex, and promises to have a long lifetime, and has idenitifiable layers, then there may be economic benefit to thinking in terms of intechangeable tiers. But for a class assignment, it's pure overkill... do you really plan on going back to your old homework code and, say, rewriting the GUI using a different architecture? If not, what possible rationale could you have for using a three-tier approach?
I run into this kind of thinking a lot professionally. Generally, I can sort through the quasi-architectural clutter that results, but this three-tier stuff really mucks things up in my experience.
I'm not saying that it's a bad pattern, simply that it's overapplied. For example, if you ask one novice programmer to write a client module and another to write a server module you're quite likely to get some sort of three-tier client running against a three-tier server. Now the nature of the assignment ("write a client" or "write a server") seems to dictate a client / server architecture; but these meticulous fresh graduates simply cannot live with themselves if they don't "do things right" and use three tiers. As as result, the vast majority of the three-tier implementations out there are pure rubbish.
My general advice is to remember that code is just a means to an end. Beautiful code does nothing in and of itself. By overdoing one particular assignment you're only distracting yourself from the other assignments and challenges you're bound to face down the road.
This is the sort of thing that is taught in Economics class, which is a great thing for a programmer to take in my opinion.
|
|
|
|
|
Reminds me of a database course I had to take once.
The teacher insisted that each table had to be placed in a separate database.
She gave us a simple accounting example that ended up with 10 databases. Account database, Client database, Invoice database, InvoiceItem database etc. Attempts to show how all the tables could be housed in one database were marked wrong & returned for reworking.
She even refused to accept it was bad purely on performance grounds, which we could easily demonstrate (it was glacially slow)!
|
|
|
|
|
I've just come across the following query in an Access ( ) application. It's supposed to run against a SQL database, but is littered with it's own views against the real database. The Name field stores a name as '[surname]; [firstname]', which makes queries unwieldy enough, but I just love how the guess the person's initials:
Left([Name],IIf(InStr([name],';')=0,Len([Name]),InStr([name],';')-1)) AS Surname,
Right([Name],Len([Name])-InStr([name],';')) AS Firstname,
Left([Name],2) AS Initials,
Now a related table stores a name as '[surname] [firstname]', and the drop-down for filtering that table has surname and first name as two separate columns. Names have no key values, and just 'exist'. The UI looks like it was designed by a three-year old on acid, and it's anybodies guess which button is going to work and which isn't.
Here are example 1[^] and example 2[^] of the Access UI.
Last modified: 51hrs 13mins after originally posted --
|
|
|
|
|
LOL, SABS = SA Bureau of Standards???
|
|
|
|
|
Yes!
|
|
|
|
|
I can't resist. "Standards are slipping!"
|
|
|
|
|
Brad (can I call you Brad?), forget about the code. That is not an UI, it is 'test bed button box from hell' gone mad. With cream.
My advice is to use the force. If you can't use the force, use a sledgehammer.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
My brief is to add the Access functionality to their intranet app. Mine looks prettier, but I've had to forego data integrity checks etc. just to get it to work. I have another brief to actually revise the whole web app, where I have the opportunity to introduce some modicum of sense.
|
|
|
|
|
Not much of a horror, but it still made me chuckle...
int x = 1 + y - 1;
Dybs
|
|
|
|
|
...if you replace the "magic numbers" with variables, this will make sense to do this way...in a readability sort of way.
|
|
|
|
|
Well. Not if it's the SAME variable!
int x = z + y - z;
|
|
|
|
|
What if z is volatile?
This would mean that the value of z could change between the add and the subtraction.
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|