Its always good to check for nothing.....
-
foreach (var thisObjective in objectivesLst)
{
if (thisObjective.EndDate != null)
{}
else
{}
}And this beauty lies inside one of the wonderful projects i came across. I have not removed any code from the above snippet. This is part of the code which i found in completed project. This developer should really be awarded... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
-
foreach (var thisObjective in objectivesLst)
{
if (thisObjective.EndDate != null)
{}
else
{}
}And this beauty lies inside one of the wonderful projects i came across. I have not removed any code from the above snippet. This is part of the code which i found in completed project. This developer should really be awarded... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
Is
EndDate
defined as a "DateTime?
" (aka "Nullable<DateTime>
")?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Is
EndDate
defined as a "DateTime?
" (aka "Nullable<DateTime>
")?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Richard Deeming wrote:
Is
EndDate
defined as a "DateTime?
"Whether it is or not, i loved the way this code was written... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
-
foreach (var thisObjective in objectivesLst)
{
if (thisObjective.EndDate != null)
{}
else
{}
}And this beauty lies inside one of the wonderful projects i came across. I have not removed any code from the above snippet. This is part of the code which i found in completed project. This developer should really be awarded... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
FUD* rules! You don't want to take it out, because it MAY do something. What if in it's nothingness it does a something? Hahaha - :D Besides, who cares? No one pays me to remove code. Do they? :D I'm trolling for people who think I'm serious. Are you one of them? *FUD - Fear, Uncertainty, Doubt
-
Richard Deeming wrote:
Is
EndDate
defined as a "DateTime?
"Whether it is or not, i loved the way this code was written... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
-
foreach (var thisObjective in objectivesLst)
{
if (thisObjective.EndDate != null)
{}
else
{}
}And this beauty lies inside one of the wonderful projects i came across. I have not removed any code from the above snippet. This is part of the code which i found in completed project. This developer should really be awarded... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
Indeed, get rid of the
var
and replace it with the actual type.You'll never get very far if all you do is follow instructions.
-
foreach (var thisObjective in objectivesLst)
{
if (thisObjective.EndDate != null)
{}
else
{}
}And this beauty lies inside one of the wonderful projects i came across. I have not removed any code from the above snippet. This is part of the code which i found in completed project. This developer should really be awarded... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
If an objective does not have a defined end-date Process accordingly else Process the objective with a defined time range And that is weird and wonderful how? Assuming of course that you have stripped out the processing logic...
-
If an objective does not have a defined end-date Process accordingly else Process the objective with a defined time range And that is weird and wonderful how? Assuming of course that you have stripped out the processing logic...
Tim Carmichael wrote:
Assuming of course that you have stripped out the processing logic
And thats the place you were wrong. Now you understand why this is in weird and wonderful.... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
-
I have just copy pasted what was there and thats the reason this is in weird and wonderful... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
-
foreach (var thisObjective in objectivesLst)
{
if (thisObjective.EndDate != null)
{}
else
{}
}And this beauty lies inside one of the wonderful projects i came across. I have not removed any code from the above snippet. This is part of the code which i found in completed project. This developer should really be awarded... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
-
foreach (var thisObjective in objectivesLst)
{
if (thisObjective.EndDate != null)
{}
else
{}
}And this beauty lies inside one of the wonderful projects i came across. I have not removed any code from the above snippet. This is part of the code which i found in completed project. This developer should really be awarded... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
And as soon as you remove the obviously-meaningless loop, you'll learn two things: 1) objectivesLst is actually an IEnumerable that, when enumerated, writes pieces of its contents to ten different parts of the application for later use. Suddenly, you have NullReferenceExceptions coming out of your ears... 2) Accessing the EndDate property sets a global variable that's later used to prevent the application from reformatting your hard drive. Unfortunately, you'll learn these too late to save yourself, and will instead begin an epic journey to find whoever wrote the code and beat him to a pulp :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
And as soon as you remove the obviously-meaningless loop, you'll learn two things: 1) objectivesLst is actually an IEnumerable that, when enumerated, writes pieces of its contents to ten different parts of the application for later use. Suddenly, you have NullReferenceExceptions coming out of your ears... 2) Accessing the EndDate property sets a global variable that's later used to prevent the application from reformatting your hard drive. Unfortunately, you'll learn these too late to save yourself, and will instead begin an epic journey to find whoever wrote the code and beat him to a pulp :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
And as soon as you remove the obviously-meaningless loop, you'll learn two things: 1) objectivesLst is actually an IEnumerable that, when enumerated, writes pieces of its contents to ten different parts of the application for later use. Suddenly, you have NullReferenceExceptions coming out of your ears... 2) Accessing the EndDate property sets a global variable that's later used to prevent the application from reformatting your hard drive. Unfortunately, you'll learn these too late to save yourself, and will instead begin an epic journey to find whoever wrote the code and beat him to a pulp :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Alas, that reminds me of some code I work with now wherein a User object has a Save method to persist it to the database -- with the result that when a user "logs in" to the app the last login date is set on the object and then we call Save. OK. Buuuut the Save also goes out and hits Active Directory to see whether or not other things have changed. :sigh: So every once in a while, we have to iterate all the User records from the database, make them User objects, and call Save. :doh: Add to that that it used to work just fine and took a few minutes to process 4000 or so Users. But then the main developer decided to become clever and use Reflection to populate the User objects, and now it takes a half hour. :mad:
You'll never get very far if all you do is follow instructions.
-
Alas, that reminds me of some code I work with now wherein a User object has a Save method to persist it to the database -- with the result that when a user "logs in" to the app the last login date is set on the object and then we call Save. OK. Buuuut the Save also goes out and hits Active Directory to see whether or not other things have changed. :sigh: So every once in a while, we have to iterate all the User records from the database, make them User objects, and call Save. :doh: Add to that that it used to work just fine and took a few minutes to process 4000 or so Users. But then the main developer decided to become clever and use Reflection to populate the User objects, and now it takes a half hour. :mad:
You'll never get very far if all you do is follow instructions.
PIEBALDconsult wrote:
But then the main developer decided to become clever and use Reflection to populate the User objects, and now it takes a half hour.
- Reflect once to get the property list 2) Use LINQ Expressions to compile mutators in memory 3) ??? 4) Profit!
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
PIEBALDconsult wrote:
But then the main developer decided to become clever and use Reflection to populate the User objects, and now it takes a half hour.
- Reflect once to get the property list 2) Use LINQ Expressions to compile mutators in memory 3) ??? 4) Profit!
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)- Yes, if I had known what he was doing I would have suggested it, but I didn't know until after he left. He probbaly wouldn't have taken my advice though because "it works". It's that he removed good code and replaced it with bad code that really gets me.
You'll never get very far if all you do is follow instructions.
-
PIEBALDconsult wrote:
But then the main developer decided to become clever and use Reflection to populate the User objects, and now it takes a half hour.
- Reflect once to get the property list 2) Use LINQ Expressions to compile mutators in memory 3) ??? 4) Profit!
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
foreach (var thisObjective in objectivesLst)
{
if (thisObjective.EndDate != null)
{}
else
{}
}And this beauty lies inside one of the wonderful projects i came across. I have not removed any code from the above snippet. This is part of the code which i found in completed project. This developer should really be awarded... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
No, no, no. You got it all wrong. The EndDate property does actually important part of work here and the if{..}else{..} is there to prevent that pesky optimizer from removing useful code :D But if by any chance it really is that way, you better start to look for a good gun and a good lawyer...
-- "My software never has bugs. It just develops random features."
-
Eddy Vluggen wrote:
it'd be three steps
Gimme three steps. Gimme three steps, mister...
You'll never get very far if all you do is follow instructions.
-
foreach (var thisObjective in objectivesLst)
{
if (thisObjective.EndDate != null)
{}
else
{}
}And this beauty lies inside one of the wonderful projects i came across. I have not removed any code from the above snippet. This is part of the code which i found in completed project. This developer should really be awarded... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
-
foreach (var thisObjective in objectivesLst)
{
if (thisObjective.EndDate != null)
{}
else
{}
}And this beauty lies inside one of the wonderful projects i came across. I have not removed any code from the above snippet. This is part of the code which i found in completed project. This developer should really be awarded... :laugh:
"When you don't know what you're doing it's best to do it quickly"- SoMad
Did the guy face some problems with lazy loading? The optimizer might remove an empty foreach, hence he accesses a property of every item. Why not create a ForceLoad function in the list, and call it? - Well, obfuscating the intent of some code is such a great idea.