|
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.
|
|
|
|
|
What if z is volatile?
If Z is volatile, then the code would go from being an idiosyncrasy to a horror, since the two reads would not be equivalent but there would be no sequence point to guarantee which would happen first.
In some cases, it's fine to read a volatile variable twice without an intervening sequence point (e.g. using something like while (*mem != *mem); to determine whether a flash chip is busy). If the order in which the reads take place won't matter, then it won't matter if the compiler rearranges them. On the other hand, in an expression like foo = vol + something - vol, the effect on foo if vol changes will be indeterminate. Far better would be something like foo = vol + something; foo -= vol;. Under that scenario, the semantics if vol changes would be clear.
|
|
|
|
|
In this case, it was for setting the position for modifying a string, so it could certain make sense for clarifying exactly where the update is inserted/replaced. But still, the "magic numbers" were there, not variables.
|
|
|
|
|
This may be a code signature
|
|
|
|
|
SELECT @ValueList = ''''+REPLACE(ISNULL(CAST([Amount] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([ActualCost] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([Notes] as varchar(8000)),'Null'),'''','''''') + ''',''' + REPLACE(ISNULL(CAST([Qty1] as varchar(8000)),'Null'),'''','''''') + ''' FROM Documents
I'm supposed to edit this, then place it in an update statement - it's the contents of a table field, not a literal query! I would rather write a quote doubler/divider than take my chances, but I was crafty and pasted my edit back into the field in Management Studio, now I just script the data of the table using the Publishing Wizard.
|
|
|
|
|
Why kind of monster can write such SQL?
|
|
|
|
|
It gets worse. When I escape the quotes to script an update of that field, I get the SQL below. The reason for all the casts is historical, and the reason for all the quotes is that the SQL gets passed through several layers of stored proc before actually being executed.
UPDATE [csForm] SET [CopyCommand] = N'SELECT @ValueList = ''''''''+REPLACE(ISNULL(CAST([Amount] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([DocTitle] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''' FROM Documents WHERE DocID =|SELECT ''''''&IDENTITY&'''','''''' + REPLACE(ISNULL(CAST([WorkType] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([WorkTypeID] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([Amount] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([Notes] as varchar(8000)),''Null''),'''''''','''''''''''') + '''''','''''' + REPLACE(ISNULL(CAST([LineType] as varchar(8000)),''Null''),'''''''','''''''''''')+'''''''' AS ValueList FROM DocItems WHERE DocID =|'
|
|
|
|
|