What’s wrong with your code?

I’ve gone through all the examples that I was planning on talking about, so I’m looking for more examples. If you have one in mind, please drop me an email.  

0

What’s wrong with this code #7 – Discussion

In this edition, I presented a small chunk of code that attempted to hook the signal handlers, so that we could do something smart when the user hits CTRL-C, rather than just rolling over and dying (rolling over optional). But before I discuss the answers, I’d like to talk about the history of this code….

1

What’s wrong with this code #7?

This time, I’ll present a runnable program. The ConsoleCtrl class is designed to intercept CTRL-C and, for testing purposes, will exit after it gets 10 of them. Or after a little over 27 hours. What’s wrong with this code? using System;using System.Threading;using System.Runtime.InteropServices; public class ConsoleCtrl{  public enum ConsoleEvent {  CTRL_C = 0,  // From wincom.h …

15

What’s wrong with this code #6? (Discussion)

Thanks for all the comments on my recent post. I have one more that I’ll do in the next couple of weeks, and after that, I’m looking for suggestions for future posts. If you have an idea for one, please email me. The answer I was looking for was related to the object that I…

3

C#: What’s wrong with this code #5 – Discussion

Thanks for all the comments. As a refresher, here’s the code that we were looking at: enum ResponseType { ReturnValues, InvalidInput } string CreateWebText(string userInput, ResponseType operation) {   switch (operation) {      case ResponseType.ReturnValues:         userInput = “<h1>Values</h1>” + FilterOutBadStuff(userInput);         break;      case ResponseType.InvalidInput:         userInput = “<h1>Invalid</h1>” + FilterOutBadStuff(userInput);         break;   }   return userInput;} First, there were a few…

19

C#: What’s wrong with this code #5

[Update: I messed up some code. Corrected version now] Greeting from the frigid city of Redmond. Keep in mind, of course, that in the Puget Sound region, “frigid” is any temperature below freezing. Thanks for all the feedback on previous bad code examples. I’ve created a new category for these posts, so you can avoid…

37