Early in life, we learn to grab the food and then put in in our mouths. Later, it's grab the ball and then roll it. In general, you must have something before you can attempt to do something with it.

...Or so you'd think.

While trudging through the migration of their code from one SharePoint solution to another, S. T. encountered this soul-sucking comment about the code that follows:

 // Comment to this idiotic code:
 // This code will never work. It tries to delete the lists if they DON'T exist, 
 // but since they exist it will never try to delete them. I have to leave it here, 
 // even though it hurts my soul. Time is scarce and I don't have the luxury to 
 // make sure it works. I hate everything.
 
 web.AllowUnsafeUpdates = true;
 
 if (ListAlreadyExists(web, "Title") == false) {
    this.DeleteList(web, "Title");
 }

 if (ListAlreadyExists(web, "Self service") == false) {
    this.DeleteList(web, "Self service");
 }

 if (ListAlreadyExists(web, "Links") == false) {
    this.DeleteList(web, "Links");
 }

 if (ListAlreadyExists(web, "Self service links") == false) {
    this.DeleteList(web, "Self service links");
 }
[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today!