Challenge 38– What’s Wrong with This Program?
Challenge #38 involved figuring out both of the following regarding the following Program Code:
- What, if anything is wrong with the program.
- What is the final value of z in the program. Please feel free to fix the program to accurately compute z, if necessary.
The following is program (Program) and a class (Challenge38) used to compute a few numbers.
- Identify what is wrong, if anything, with above program
- What is the value of z in the above program
The following is a great response as submitted by Matt Kent.
Winners (out of approximately 29 respondents)
Thanks to everybody for your responses to SCS Coding Challenge #38!!!
Congratulations to Matt Kent for his fine effort to identify the most errors in the above program.
|Name||Prize Winner||Good Answer|
Monthly Programming Tidbits
Pay attention to the name of your identifiers
Name of your identifiers is as important as the name of your children. I’m dead serious. No one wants to read someone else’s code with the following identifiers:
- od: What is od? Oh Damn? Obsessive Disorder? Overdue Days?
- Button1_Click(): What is Button1? How is it different from Button2?
- thisAs: What’s that even supposed to mean?!
Use a name that clearly communicates the intent as shown below:
- OverdueDays instead of od
- SubmitButton_Click() instead of Button1_Click()
- FoodObject instead of thisAs
Reference: 5 Tips for Junior C# Developers to Write Cleaner C# Code
Coding Challenge #39
Please stay tuned, SCS Coding Challenge #39 will be published early next week. Details will follow. The winner will be awarded based upon the best approach.