.NET food for the brains!

from Coding Blocks .NET , on 10/17/2016 , played: 848 time(s)

We continue talking our way through Clean Code, taking a deep look at the building blocks of programming in the quest to write the best functions. Oh, and everybody sings. The original version of the show notes can be found at: http://www.codingblocks.net/episode48 Podcast News iTunes Reviews: BrokenDev, Simontheu, Hruncito, TerrenceD, Rich11145, HardCoreRockstar, Bcmsco, FriendofEntropy, Fredstban, Ibankai7, Islander201111, Iamqaz, Adam Hannigan Stitcher Reviews: snapper109, brianplace, veso7, Zelig880, Cube00, joro550, philipLowney, RocketRaccoon Joe made a video: https://www.youtube.com/watch?v=B3C5r7gzidg And don’t forget to subscribe! http://www.youtube.com/codingblocks How to become an engineer at Google from Peter Nelson https://www.google.com/about/careers/students/guide-to-technical-development.html https://www.reddit.com/r/programming/comments/565i1n/google_interview_university_multimonth_study_plan/ https://github.com/jwasham/google-interview-university ATL Code Camp - You can still register?! maybe?! Oct 15th https://atlantacodecamp.com/2016/Register Connect.tech - Oct 20-22nd http://connect.tech/ Your web browser hates your SSD https://www.servethehome.com/firefox-is-eating-your-ssd-here-is-how-to-fix-it/ Allen’s tip from last episode oauthforaspnet.com is not working Allen made MVP…what?! https://mvp.microsoft.com/en-us/ Leave a comment for a chance to win Clean Code! Functions 1st rule - Functions should be small 2nd rule - Functions should be smaller than that! Functions should barely be 20 lines long… Each function should lead you to the next function in a compelling order - like telling a story They should do ONE thing Code within if’s or block statements should be one line long, meaning they should call another function…overkill? The indent levels of a function probably shouldn’t be more than two tabs! (tabs vs spaces) Prepend “TO” to the name of your function and see if you can describe what it should be doing…it may seem like more than one thing “Another way to know that a function is doing more than one thing is if you can extract another function from it with a name that is not a restatement of it’s implementation” Functions that do just one thing can’t be divided into sections…they’re not long enough Keep functionality at the same level of abstraction - interesting…“getHtml()” vs “getPath” vs path.append(“newline”) The StepDown Rule - the code should read like a paragraph of “To do …” - and those should be at the same basic level of abstraction Switch statements - should be created only once and should be used to create polymorphic objects - objects with the same methods but different implementations Use descriptive names - Ward’s Principle “you know you’re working on clean code when each routine turns out to be pretty much what you expected” The ugliest functions I “write” are refactors - they take too many arguments, because the code isn’t separated by concern - mixing data gathering, logic and presentation! The smaller and more focused a function, the easier it is to name Don’t be afraid to make a long name - a long descriptive name is better than a short enigmatic one A long name is better than a long comment Be consistent in your naming - again, it should be like reading a paragraph - easy to follow Function Arguments You should basically never use more than 2 arguments in a function - if so, there’d better be a great reason You do this by making values instance variables and then use the instance methods to work with those arguments Testing with multiple arguments becomes very difficult Niladic - no arguments - absolute best case Monadic - single argument - asking a question about the argument, or transforming and returning Other monadic uses are events output variables can be confusing and probably avoided where possible Immediately tells you that the function is going to do something different based on the valu...



blog comments powered by Disqus