|
My sympathies! Good thing for intellisense!
"Go forth into the source" - Neal Morse
|
|
|
|
|
I'm scared, people still use SEDOL?!?!
veni bibi saltavi
|
|
|
|
|
Not in MY systems, but in third-party ones... Ugh... Yes.
|
|
|
|
|
Just noticed that in the Unit Tests I've written, someone as taken a novel approach to refactoring. When refactoring causes a test to fail, his approach is simply to comment out the lines that cause the failure.
I now need to go and check nothing has broken in the process - which seems unlikely.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
What is wrong with problem elimination?
This is a joke in case you miss the icon
|
|
|
|
|
d@nish wrote: What is wrong with problem elimination?
Tell that a heart surgeon.
You: "Dr. I'm having problems with my heart lately."
Dr: "Ok son, don't you fear, I'll cut that heart out and you'll no longer have any problems with your heart"
You: "Wow Doc, that sounds reasonable. Slice away!"
I'd appreciate it if you would let me watch and video the procedure.
After the operation I've planned in a small interview with the patient, to see how he liked the procedure.
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
And that's how Ironman is made.
|
|
|
|
|
No, no, no! There was no mention of replacing your heart with something that works to the same effect.
Just a little heartectomy, Inka style if you'd prefer that.
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
I wouldn't mind that after next 50 years.
|
|
|
|
|
It's like Taste Failing.
|
|
|
|
|
The only thing more useless than a test that always fails is a test that always succeeds.
|
|
|
|
|
if LEN(@accountnumber) >= 4
begin
select * from dbo.Departments where accountnumber = @accountnumber order by deptname;
end
else
begin
select * from dbo.departments where catid = @catid order by deptname;
end
I want to NEVER work with the guy (and I know his name, BTW) who wrote this crap.
Marc
|
|
|
|
|
select *
from dbo.Departments
where (accountnumber = @accountnumber and LEN(@accountnumber) >= 4)
or catid = @catid
order by deptname
Better?
I'm wondering what the problem is exactly... Except for the weird IF statement, use of * in production code and horrible formatting.
My blog[ ^]
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
Sander Rossel wrote: I'm wondering what the problem is exactly...
The problem is that he's looking up the department by either account number or category ID. This is just bad practice and made worse by the fact (which I forgot to mention) that the PROC's name is "GetClientDepartments" which implies the list is being filtered by clients, not my accounts or categories.
There should be at least two PROC's, one called "GetDepartmentsByAccountNumber" and the other "GetDepartmentsByCategory". It's just plain laziness that he put the functionality for two very different things into one proc.
Now get this -- on the client side, he's always populating the department and catid values!
Marc
|
|
|
|
|
Well in that case it's A BIT weird.
I've worked with such procedures a lot. They usually were part of some bigger procedure. This, for example, could be part of getting a product, but depending on the department and available data and some customer setting and lots of other stuff you would ultimately get 1 out of maybe 10 possible outcomes.
Anyway, if you worked where I worked (notice past tense!) this wouldn't bother you as much as it does
My blog[ ^]
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
|
manchanx wrote: Hopefully not your new client/employer?
No, thankfully. Haven't heard from them yet, this is code I'm cleaning up before (hopefully) I come on board with the other client.
Marc
|
|
|
|
|
Yeah, needs a CASE . IF has no place in SQL. He must not have been trained in set-based thinking.
|
|
|
|
|
I'd like to propose a simple extra switch to test Sanders code, while still be able to switch back to the old one.
if (select COUNT(*) from tblSettings where 'test' = 'true') = 0
begin
if LEN(@accountnumber) >= 4
begin
select * from dbo.Departments where accountnumber = @accountnumber order by deptname;
end
else
begin
select * from dbo.departments where catid = @catid order by deptname;
end
end
else
begin
select *
from dbo.Departments
where (accountnumber = @accountnumber and LEN(@accountnumber) >= 4)
or catid = @catid
order by deptname
end; You should replace the "4" with a value that you get from a settings-table ofcourse. You don't want to recompile your sproc simply because the length of catids' change. Better yet, replace it with the MIN(LEN(accountnumber)).
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Well, having one stored procedure for each possible search parameter would be a REAL horror, IMHO. You can get to the hundreds of procedures really fast.
I would likely have more than one parameter in the sproc, and default values, so I could write:
EXEC GetClientDepartments @accountNumber = 'xxxxxxxx';
-- or...
EXEC GetClientDepartments @catId = 'xxxx';
t-SQL code can get really, really messy if you don't pay attention.
But, other than that, the code is not really an horror (t-SQL code quality is a lot lower than what you're expecting).
My 2c.
|
|
|
|
|
I was having a code review session and found out that the password is just being hashed and stored in the db. The db had a field for salt when i designed it and I specifically asked to use the salted hashes. So i suggested the developer to use the salted hash and he agreed. Later i asked him and he said he implemented it.
Now 3 months later I am working on some query optimization and during this i run a query on the user table and to my surprise the salt field contains "mmmmmm Salty passwords..." for all the records. And when i checked the code, the code contains this hard coded string in register action method (asp.net MVC).
Good thing is that the developer left the organization otherwise I would have been serving a life sentence for killing him.
|
|
|
|
|
Nothing's worse than a programmer with a sense of humour!
My blog[ ^]
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
..in the case of humor the salt would be randomly pulled from a pre-seeded table, also containing Bacon and CListCtrl.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
No comment needed...
If (InputBox("Access is highly restricted. Please enter the password: ") = "nooneneedstoseethisscreensokeepoutyoumonkey.") Then
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
On a positive note, they've got enough characters and included punctuation
How do you know so much about swallows? Well, you have to know these things when you're a king, you know.
modified 31-Aug-21 21:01pm.
|
|
|
|