In my new ongoing quest to read source code to be a better developer, I now present the tenth in an infinite number of a weekly series called "The Weekly Source Code." Here's some source I'm reading this week that I enjoyed.
Our theme this week is "Patterns Considered Harmful" with examples of source doing things we're "not supposed to do."
public static string XOR(string input, string strKey) { if (IsEmpty(input)) return input; string strEncoded = string.Empty; int nKeyIndex = 0; for (int i = 0; i < input.Length; i++) { strEncoded += Convert.ToChar(input[i] ^ strKey[nKeyIndex]); nKeyIndex++; if (nKeyIndex == strKey.Length) nKeyIndex = 0; } return strEncoded; } public static string ToTitleCase(string Input) { return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(Input); }
Import-CSv File.csv | Select File,Hits | Group { $_.File -replace '/hanselminutes_(\d+).*','$1' } | Select Name,{ ($_.Group | Measure-Object -Sum Hits).Sum }
Feel free to send me links to cool source that you find hasn't been given a good read.
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.
"Patterns Considered Harmful" with examples of source doing things we're "not supposed to do."
Edsger Dijkstra's letter "Go To Statement Considered Harmful",[1] published in the March 1968 Communications of the ACM (CACM), in which he criticized the excessive use of the GOTO statement in programming languages of the day and advocated structured programming instead.[2] The original title of the letter, as submitted to CACM, was "A Case Against the Goto Statement," but CACM editor Niklaus Wirth changed the title to the now immortalized "Go To Statement Considered Harmful."
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.