<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttp://mvark.blogspot.com/\x26vt\x3d-5147029996388199615', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

Search from over a hundred HOW TO articles, Tips and Tricks


Scott Allen's 10 favorite C# rules for developing software


From Scott Allen's C# Fundamentals Part 2 course on Pluralsight -

Rule #10: Avoid Regions - as they are typically used to hide ugly code or classes that've exploded in size or responsibility. Think if you should break the regions into seperate classes
Rule #9: Use exceptions for errors..instead of status code or booleans...but not for control flow
Rule #8: Avoid boolean parameters
Rule #7: Avoid too many parameters - beyond 4, consider grouping
Rule #6: Warnings are errors - Go to a Project's Properties and in the Build tab of the dialog box that opens up, change "Treat warnings as errors" to All from the default None
Rule #5: Encapsulate complex expressions - Instant recognition is good
Rule #4: Try to avoid multiple exits - have just one
Rule #3: Try to avoid comments - A meaningful method name is more effective than comments. Triple slash comments in VS are ok as they help in documentation of an API. Other developers can see your comments through Intellisense when they reference your assembly.
Rule #2: Keep methods short - general rule of thumb: 1 to 10 lines
Rule #1: Keep classes small

+ The foundation for most C# coding standards is Microsoft's "Design Guidelines for Developing Class Libraries"
+ ReSharper VS Plugin & StyleCop can help you enforce naming conventions
+ Names contain meaning & adding meaning to code is what readability is all about - use meanigful names
+ Embedding type in the name of a variable is not a good idea especially for primitive types. Name should indicate what an variable or object can do & what it represents.
+ How to improve readability of your code - read other people's code to figure what is good & what is bad. Be introspective.

Labels:

Tweet this | Google+ it | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »

»

Post a Comment