SlideShare une entreprise Scribd logo
1  sur  38
Back-2-Basics: .NET Coding Standards For The Real World
Check Out Your Local User Groups! San Diego Cloud Computing User Group www.azureusergroup.com/group/sandiegoazureusergroup San Diego .NET Developers Group www.sddotnetdg.org San Diego .NET User Group www.sandiegodotnet.com San Diego SQL Server User Group www.sdsqlug.org
Win Free Software! Rules Provide your business card (or email and name)* Indicate on the back what software you are interested in Otherwise I will pick  Winners will be picked next week *Yes, most likely I’m going to send you and email about my user group (sddotnetdg.org) and or web site (dotNetTips.com) Prizes CodeRush and Refactor Pro from DevExpress (4) SecondCopy (automatic backup software) (5) * CodeIt.Right Standard from SubMain (4) *Requires mailing address and phone number
Agenda 5
Overview
Why Do You Need Standards? First, you might not agree witheverything I say… that’s okay! Pick a standard for your company Every programmer on the same page Easier to read and understand code Easier to maintain code Produces more stable, reliable code Stick to the standard!!!
After Selecting a Standard Make sure it’s easily available to each programmer Print or electronically Enforce via code reviews Provide programs to make it easier for programmers to maintain: StyleCop – Free for C# programmers. CodeIt.Right – Enterprise edition shares profiles. Can create custom profiles for your company.
Real World Analysis Example Scenario: In production Client Server Application with millions in sales Nine projects of 183,177 lines of .NET code written by multiple programmers (junior to principal) StyleCop Analyze Code.It Right 7,076 < 1,100 6,216 < 2,527 5,091 < 1,837 This is why you need to follow good coding practices throughout the lifecycle of the project!
Code.It Right Stats All Important
Assembly Layout
General Assembly Tips Never hardcode strings that might change based on deployment such as connection strings Best place to put them are in user or application level Settings in your application. Remember to save on exit and load on start! Automatic in VB.NET  Other locations can include: Registration Database, Databases and more…  DEMO
General Assembly Tips Sign (strong name) your assemblies, including the client applications.  Also, sign interop assemblies with the project’s .snk file Name assemblies in the following format: <Company>.<Component>.dll Project names should be named the same. Microsoft.VisualBasic.dll dotNetTips.Utility.dll Acme.Services.References.dll
Mark as CLS Compliant Forces your assembly to be compliant with the Common Language Specification (CLS).  Assemblies, modules, and types can be CLS-compliant even if some parts of the assembly, module, or type are not CLS-compliant, as long as these two conditions are met:  If the element is marked as CLS-compliant, the parts that are not CLS-compliant must be marked using CLSCompliantAttribute with its argument set to false.  A comparable CLS-compliant alternative member must be supplied for each member that is not CLS-compliant. DEMO
Element Order
Elements of the Same Type Should appear in this order: public elements protected elements internal elements private elements Use #region/ #endregion to group namespace-level and class-level elements Use separate regions to organize the private, protected, and internal members.
Namespaces The general rule for naming namespaces is to use the company name followed by the technology name and optionally the feature and design CompanyName.TechnologyName[.Feature][.Design]
Enums Use abbreviations sparingly for Enums and their values Do not use an Enum suffix on Enum type names Use a singular name for most Enum types, but use a plural name for Enum types that are bit fields
Enums Always add the FlagsAttribute to a bit field Enum type Avoid providing explicit values for Enums (unless necessary) Avoid specifying a type for an Enum Public Enum WebServiceAction   GetCurrentMode   PauseService   ResumeService   StartService   StopService End Enum
Interfaces Prefix interface names with the letter “I” Do not use the underscore character. Use abbreviations sparingly. Challenging to version over releases The smaller, more focused the interface the better public interface IDisposable {     // Methods
    void Dispose(); }
Classes Use a noun or noun phrase to name a class. Avoid putting multiple classes in a single file. A file name should reflect the class it contains.  Provide a default private constructor if there are only static methods and properties on a class.  Use Static Class in C# or a Module in VB.NET
Events Use Pascal case Use an EventHandler suffix on event handler names.  Name an event argument class with the EventArgs suffix. Use EventHandler<> to declare handlers. Be careful with non-UI threads calling back to the UI! Use the BackgroundWorker Control in Windows Forms DEMO
Member Variables (Fields) Use camel case as a rule, or uppercase for very small words Prefix private variables with a "_” Member variables should not be declared public Use a Property instead Const member variables may be declared public
Properties Use Pascal case Use a noun or noun phrase to name properties Properties that return arrays or collections should be methods.  Do not use write-only properties  Consider providing events that are raised when certain properties are changed.  Name them <Property>Changed
Properties Properties should not have dependencies on each other Setting one property should not affect other properties Properties should be settable in any order. DEMO
Constructors Do not call code from a constructor! Can cause Exceptions. Capture parameters only. Provide a constructor for every class.  Do not use the this./ Me. reference unless invoking another constructor from within a constructor. Provide a protected constructor that can be used by types in a derived class.
Destructors Avoid using destructors! It is not possible to predict when garbage collection will occur. The garbage collector has no knowledge of unmanaged resources such as window handles, or open files and streams.  Implement IDisposible if you do! Use the try/finally (or Using) to make sure that unmanaged resources are disposed of even if an exception interrupts your application.  DEMO
Methods Use Pascal case Use verbs, verb phrases or verb-object pair to name methods Always mark public and protected methods as virtual/Overridable  in a non-sealed class.  Methods with return values should have a name describing the value returned DEMO
Method Overloading Use method overloading to provide different methods that do semantically the same thing.  Use method overloading instead of allowing default arguments.  Overloaded methods should call the most complete method If you provide the ability to override a method, make only the most complete overload virtual and define the other operations in terms of it DEMO
Do Not Expose Generic List List is a generic collection designed for performance not inheritance and Applies to public API’s Does not contain any virtual members Can not tell when updated Use Instead: System.Collections.ObjectModel.Collection System.Collections.ObjectModel.ReadOnlyCollection System.Collections.ObjectModel.KeyedCollection Use Interfaces: IDictionary DEMO
Stop Exceptions BEFORE They Happen! Defensive Programming
Prevent Exceptions Practice Defensive Programming! Any code that might cause an exception (accessing files, using objects like DataSets etc.) should check the object (depending on the type) so an Exception is not thrown For example, call File.Exists to avoid a FileNotFoundException Check and object for null Check a DataSet for rows Check an Array for bounds Check String for null or empty DEMO
Parameters Always check for valid parameter arguments Perform argument validation for every public or protected method Throw meaningful exceptions to the developer for invalid parameter arguments Use the System.ArgumentException class Or your own class derived from System.ArgumentException  DEMO
Enums Never assume that Enum arguments will be in the defined range. Enums are just an Int32, so any valid number in that range could be sent in! Always use Enum.IsDefined to verify value before using! DEMO
Exceptions When doing any operation that could cause an exception, wrap in Try - Catch block Use System.Environment.FailFast instead if unsafe for further execution Do not catch non-specific exceptions (for common API’s) Use Finally for cleanup code When throwing Exceptions try using from System instead of creating custom Exceptions Use MyApplication_UnhandledException event in VB.NET WinForm apps Use Application_Error event in ASP.NET apps
TryParse Use the .TryParse method on value types when assigning from a string. WILL NOT cause an exception! Returns result of True/False DEMO
Code Style
Variables Avoid single character variable names i, t etc. Do not abbreviate variable words (such as num, instead of number) Unless they are well known like Xml, Html or IO If deriving from a core type, add the suffix of the identify type.  ArgumentException or FileStream Use camel case for local variables firstName

Contenu connexe

Tendances

Commenting Best Practices
Commenting Best PracticesCommenting Best Practices
Commenting Best Practicesmh_azad
 
Refactoring legacy code driven by tests - ENG
Refactoring legacy code driven by tests - ENGRefactoring legacy code driven by tests - ENG
Refactoring legacy code driven by tests - ENGLuca Minudel
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated TestingLee Englestone
 
OCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 ExceptionsOCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 Exceptionsİbrahim Kürce
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)David McCarter
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010Stefano Paluello
 
OCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class DesignOCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class Designİbrahim Kürce
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testingalessiopace
 
C# conventions & good practices
C# conventions & good practicesC# conventions & good practices
C# conventions & good practicesTan Tran
 
Testing Java applications with Maveryx
Testing Java applications with MaveryxTesting Java applications with Maveryx
Testing Java applications with MaveryxMaveryx
 
11 advance inheritance_concepts
11 advance inheritance_concepts11 advance inheritance_concepts
11 advance inheritance_conceptsArriz San Juan
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 

Tendances (20)

Commenting Best Practices
Commenting Best PracticesCommenting Best Practices
Commenting Best Practices
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Refactoring legacy code driven by tests - ENG
Refactoring legacy code driven by tests - ENGRefactoring legacy code driven by tests - ENG
Refactoring legacy code driven by tests - ENG
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
 
Unit Tests And Automated Testing
Unit Tests And Automated TestingUnit Tests And Automated Testing
Unit Tests And Automated Testing
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
OCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 ExceptionsOCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 Exceptions
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
 
Unit Testing 101
Unit Testing 101Unit Testing 101
Unit Testing 101
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010
 
OCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class DesignOCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class Design
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testing
 
C# conventions & good practices
C# conventions & good practicesC# conventions & good practices
C# conventions & good practices
 
Testing Java applications with Maveryx
Testing Java applications with MaveryxTesting Java applications with Maveryx
Testing Java applications with Maveryx
 
C#/.NET Little Pitfalls
C#/.NET Little PitfallsC#/.NET Little Pitfalls
C#/.NET Little Pitfalls
 
11 advance inheritance_concepts
11 advance inheritance_concepts11 advance inheritance_concepts
11 advance inheritance_concepts
 
Unit 5 Java
Unit 5 JavaUnit 5 Java
Unit 5 Java
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
J Unit
J UnitJ Unit
J Unit
 

Similaire à Back-2-Basics Coding Standards Real World

Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applicationsChandra Sekhar Saripaka
 
Best Practices of Software Development
Best Practices of Software DevelopmentBest Practices of Software Development
Best Practices of Software DevelopmentFolio3 Software
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for javamaheshm1206
 
Android coding standard
Android coding standard Android coding standard
Android coding standard Rakesh Jha
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to JavaSMIJava
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#Pascal Laurin
 
Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#Svetlin Nakov
 
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISPMCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISPAli Shah
 
Best Coding Practices For Android Application Development
Best Coding Practices For Android Application DevelopmentBest Coding Practices For Android Application Development
Best Coding Practices For Android Application DevelopmentKetan Raval
 
C# interview-questions
C# interview-questionsC# interview-questions
C# interview-questionsnicolbiden
 
Introduction
IntroductionIntroduction
Introductionrichsoden
 

Similaire à Back-2-Basics Coding Standards Real World (20)

Bb Tequila Coding Style (Draft)
Bb Tequila Coding Style (Draft)Bb Tequila Coding Style (Draft)
Bb Tequila Coding Style (Draft)
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applications
 
Best Practices of Software Development
Best Practices of Software DevelopmentBest Practices of Software Development
Best Practices of Software Development
 
Generics
GenericsGenerics
Generics
 
Code Quality Management iOS
Code Quality Management iOSCode Quality Management iOS
Code Quality Management iOS
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for java
 
Code quality
Code qualityCode quality
Code quality
 
Code Quality
Code QualityCode Quality
Code Quality
 
Android coding standard
Android coding standard Android coding standard
Android coding standard
 
Codings Standards
Codings StandardsCodings Standards
Codings Standards
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
Automation tips
Automation tipsAutomation tips
Automation tips
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
Code Metrics
Code MetricsCode Metrics
Code Metrics
 
Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#
 
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISPMCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
 
Best Coding Practices For Android Application Development
Best Coding Practices For Android Application DevelopmentBest Coding Practices For Android Application Development
Best Coding Practices For Android Application Development
 
C# interview-questions
C# interview-questionsC# interview-questions
C# interview-questions
 
Introduction
IntroductionIntroduction
Introduction
 

Plus de David McCarter

Röck Yoür Technical Interview - V3
Röck Yoür Technical Interview - V3Röck Yoür Technical Interview - V3
Röck Yoür Technical Interview - V3David McCarter
 
Rock Your Code With Code Contracts -2013
Rock Your Code With Code Contracts -2013Rock Your Code With Code Contracts -2013
Rock Your Code With Code Contracts -2013David McCarter
 
Rock Your Code with Code Contracts
Rock Your Code with Code ContractsRock Your Code with Code Contracts
Rock Your Code with Code ContractsDavid McCarter
 
.NET Coding Standards For The Real World (2012)
.NET Coding Standards For The Real World (2012).NET Coding Standards For The Real World (2012)
.NET Coding Standards For The Real World (2012)David McCarter
 
Back-2-Basics: Code Contracts
Back-2-Basics: Code ContractsBack-2-Basics: Code Contracts
Back-2-Basics: Code ContractsDavid McCarter
 
How To Survive The Technical Interview
How To Survive The Technical InterviewHow To Survive The Technical Interview
How To Survive The Technical InterviewDavid McCarter
 
Real World API Design Using The Entity Framework Services
Real World API Design Using The Entity Framework ServicesReal World API Design Using The Entity Framework Services
Real World API Design Using The Entity Framework ServicesDavid McCarter
 
Building nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework ServicesBuilding nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework ServicesDavid McCarter
 
Code Easier With Visual Studio 2010 & Extensions
Code Easier With Visual Studio 2010 & ExtensionsCode Easier With Visual Studio 2010 & Extensions
Code Easier With Visual Studio 2010 & ExtensionsDavid McCarter
 
Back-2-Basics: Exception & Event Instrumentation in .NET
Back-2-Basics: Exception & Event Instrumentation in .NETBack-2-Basics: Exception & Event Instrumentation in .NET
Back-2-Basics: Exception & Event Instrumentation in .NETDavid McCarter
 
Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)David McCarter
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)David McCarter
 
Back-2-Basics: Exception & Event Instrumentation in .NET
Back-2-Basics: Exception & Event Instrumentation in .NETBack-2-Basics: Exception & Event Instrumentation in .NET
Back-2-Basics: Exception & Event Instrumentation in .NETDavid McCarter
 
Back-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldBack-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldDavid McCarter
 
Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)David McCarter
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)David McCarter
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010David McCarter
 

Plus de David McCarter (17)

Röck Yoür Technical Interview - V3
Röck Yoür Technical Interview - V3Röck Yoür Technical Interview - V3
Röck Yoür Technical Interview - V3
 
Rock Your Code With Code Contracts -2013
Rock Your Code With Code Contracts -2013Rock Your Code With Code Contracts -2013
Rock Your Code With Code Contracts -2013
 
Rock Your Code with Code Contracts
Rock Your Code with Code ContractsRock Your Code with Code Contracts
Rock Your Code with Code Contracts
 
.NET Coding Standards For The Real World (2012)
.NET Coding Standards For The Real World (2012).NET Coding Standards For The Real World (2012)
.NET Coding Standards For The Real World (2012)
 
Back-2-Basics: Code Contracts
Back-2-Basics: Code ContractsBack-2-Basics: Code Contracts
Back-2-Basics: Code Contracts
 
How To Survive The Technical Interview
How To Survive The Technical InterviewHow To Survive The Technical Interview
How To Survive The Technical Interview
 
Real World API Design Using The Entity Framework Services
Real World API Design Using The Entity Framework ServicesReal World API Design Using The Entity Framework Services
Real World API Design Using The Entity Framework Services
 
Building nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework ServicesBuilding nTier Applications with Entity Framework Services
Building nTier Applications with Entity Framework Services
 
Code Easier With Visual Studio 2010 & Extensions
Code Easier With Visual Studio 2010 & ExtensionsCode Easier With Visual Studio 2010 & Extensions
Code Easier With Visual Studio 2010 & Extensions
 
Back-2-Basics: Exception & Event Instrumentation in .NET
Back-2-Basics: Exception & Event Instrumentation in .NETBack-2-Basics: Exception & Event Instrumentation in .NET
Back-2-Basics: Exception & Event Instrumentation in .NET
 
Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Back-2-Basics: Exception & Event Instrumentation in .NET
Back-2-Basics: Exception & Event Instrumentation in .NETBack-2-Basics: Exception & Event Instrumentation in .NET
Back-2-Basics: Exception & Event Instrumentation in .NET
 
Back-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldBack-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real World
 
Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010
 

Dernier

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Dernier (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

Back-2-Basics Coding Standards Real World

  • 1. Back-2-Basics: .NET Coding Standards For The Real World
  • 2.
  • 3. Check Out Your Local User Groups! San Diego Cloud Computing User Group www.azureusergroup.com/group/sandiegoazureusergroup San Diego .NET Developers Group www.sddotnetdg.org San Diego .NET User Group www.sandiegodotnet.com San Diego SQL Server User Group www.sdsqlug.org
  • 4. Win Free Software! Rules Provide your business card (or email and name)* Indicate on the back what software you are interested in Otherwise I will pick  Winners will be picked next week *Yes, most likely I’m going to send you and email about my user group (sddotnetdg.org) and or web site (dotNetTips.com) Prizes CodeRush and Refactor Pro from DevExpress (4) SecondCopy (automatic backup software) (5) * CodeIt.Right Standard from SubMain (4) *Requires mailing address and phone number
  • 7. Why Do You Need Standards? First, you might not agree witheverything I say… that’s okay! Pick a standard for your company Every programmer on the same page Easier to read and understand code Easier to maintain code Produces more stable, reliable code Stick to the standard!!!
  • 8. After Selecting a Standard Make sure it’s easily available to each programmer Print or electronically Enforce via code reviews Provide programs to make it easier for programmers to maintain: StyleCop – Free for C# programmers. CodeIt.Right – Enterprise edition shares profiles. Can create custom profiles for your company.
  • 9. Real World Analysis Example Scenario: In production Client Server Application with millions in sales Nine projects of 183,177 lines of .NET code written by multiple programmers (junior to principal) StyleCop Analyze Code.It Right 7,076 < 1,100 6,216 < 2,527 5,091 < 1,837 This is why you need to follow good coding practices throughout the lifecycle of the project!
  • 10. Code.It Right Stats All Important
  • 12. General Assembly Tips Never hardcode strings that might change based on deployment such as connection strings Best place to put them are in user or application level Settings in your application. Remember to save on exit and load on start! Automatic in VB.NET  Other locations can include: Registration Database, Databases and more… DEMO
  • 13. General Assembly Tips Sign (strong name) your assemblies, including the client applications. Also, sign interop assemblies with the project’s .snk file Name assemblies in the following format: <Company>.<Component>.dll Project names should be named the same. Microsoft.VisualBasic.dll dotNetTips.Utility.dll Acme.Services.References.dll
  • 14. Mark as CLS Compliant Forces your assembly to be compliant with the Common Language Specification (CLS). Assemblies, modules, and types can be CLS-compliant even if some parts of the assembly, module, or type are not CLS-compliant, as long as these two conditions are met: If the element is marked as CLS-compliant, the parts that are not CLS-compliant must be marked using CLSCompliantAttribute with its argument set to false. A comparable CLS-compliant alternative member must be supplied for each member that is not CLS-compliant. DEMO
  • 16. Elements of the Same Type Should appear in this order: public elements protected elements internal elements private elements Use #region/ #endregion to group namespace-level and class-level elements Use separate regions to organize the private, protected, and internal members.
  • 17. Namespaces The general rule for naming namespaces is to use the company name followed by the technology name and optionally the feature and design CompanyName.TechnologyName[.Feature][.Design]
  • 18. Enums Use abbreviations sparingly for Enums and their values Do not use an Enum suffix on Enum type names Use a singular name for most Enum types, but use a plural name for Enum types that are bit fields
  • 19. Enums Always add the FlagsAttribute to a bit field Enum type Avoid providing explicit values for Enums (unless necessary) Avoid specifying a type for an Enum Public Enum WebServiceAction GetCurrentMode PauseService ResumeService StartService StopService End Enum
  • 20. Interfaces Prefix interface names with the letter “I” Do not use the underscore character. Use abbreviations sparingly. Challenging to version over releases The smaller, more focused the interface the better public interface IDisposable { // Methods void Dispose(); }
  • 21. Classes Use a noun or noun phrase to name a class. Avoid putting multiple classes in a single file. A file name should reflect the class it contains. Provide a default private constructor if there are only static methods and properties on a class. Use Static Class in C# or a Module in VB.NET
  • 22. Events Use Pascal case Use an EventHandler suffix on event handler names. Name an event argument class with the EventArgs suffix. Use EventHandler<> to declare handlers. Be careful with non-UI threads calling back to the UI! Use the BackgroundWorker Control in Windows Forms DEMO
  • 23. Member Variables (Fields) Use camel case as a rule, or uppercase for very small words Prefix private variables with a "_” Member variables should not be declared public Use a Property instead Const member variables may be declared public
  • 24. Properties Use Pascal case Use a noun or noun phrase to name properties Properties that return arrays or collections should be methods. Do not use write-only properties Consider providing events that are raised when certain properties are changed. Name them <Property>Changed
  • 25. Properties Properties should not have dependencies on each other Setting one property should not affect other properties Properties should be settable in any order. DEMO
  • 26. Constructors Do not call code from a constructor! Can cause Exceptions. Capture parameters only. Provide a constructor for every class. Do not use the this./ Me. reference unless invoking another constructor from within a constructor. Provide a protected constructor that can be used by types in a derived class.
  • 27. Destructors Avoid using destructors! It is not possible to predict when garbage collection will occur. The garbage collector has no knowledge of unmanaged resources such as window handles, or open files and streams. Implement IDisposible if you do! Use the try/finally (or Using) to make sure that unmanaged resources are disposed of even if an exception interrupts your application. DEMO
  • 28. Methods Use Pascal case Use verbs, verb phrases or verb-object pair to name methods Always mark public and protected methods as virtual/Overridable in a non-sealed class. Methods with return values should have a name describing the value returned DEMO
  • 29. Method Overloading Use method overloading to provide different methods that do semantically the same thing. Use method overloading instead of allowing default arguments. Overloaded methods should call the most complete method If you provide the ability to override a method, make only the most complete overload virtual and define the other operations in terms of it DEMO
  • 30. Do Not Expose Generic List List is a generic collection designed for performance not inheritance and Applies to public API’s Does not contain any virtual members Can not tell when updated Use Instead: System.Collections.ObjectModel.Collection System.Collections.ObjectModel.ReadOnlyCollection System.Collections.ObjectModel.KeyedCollection Use Interfaces: IDictionary DEMO
  • 31. Stop Exceptions BEFORE They Happen! Defensive Programming
  • 32. Prevent Exceptions Practice Defensive Programming! Any code that might cause an exception (accessing files, using objects like DataSets etc.) should check the object (depending on the type) so an Exception is not thrown For example, call File.Exists to avoid a FileNotFoundException Check and object for null Check a DataSet for rows Check an Array for bounds Check String for null or empty DEMO
  • 33. Parameters Always check for valid parameter arguments Perform argument validation for every public or protected method Throw meaningful exceptions to the developer for invalid parameter arguments Use the System.ArgumentException class Or your own class derived from System.ArgumentException DEMO
  • 34. Enums Never assume that Enum arguments will be in the defined range. Enums are just an Int32, so any valid number in that range could be sent in! Always use Enum.IsDefined to verify value before using! DEMO
  • 35. Exceptions When doing any operation that could cause an exception, wrap in Try - Catch block Use System.Environment.FailFast instead if unsafe for further execution Do not catch non-specific exceptions (for common API’s) Use Finally for cleanup code When throwing Exceptions try using from System instead of creating custom Exceptions Use MyApplication_UnhandledException event in VB.NET WinForm apps Use Application_Error event in ASP.NET apps
  • 36. TryParse Use the .TryParse method on value types when assigning from a string. WILL NOT cause an exception! Returns result of True/False DEMO
  • 38. Variables Avoid single character variable names i, t etc. Do not abbreviate variable words (such as num, instead of number) Unless they are well known like Xml, Html or IO If deriving from a core type, add the suffix of the identify type. ArgumentException or FileStream Use camel case for local variables firstName
  • 39. Accessing Class Member Variables Preface all calls to class members with this./Me., and place base./MyBase. before calls to all members of a base class Class BaseClass Public Sub ProcessData() End Sub End Class Class MainClass Inherits BaseClass Public Sub AnalyzeData() End Sub 'Correct usage of this. and base. Public Sub Good() Me.AnalyzeData() MyBase.ProcessData() End Sub 'Incorrect usage. Public Sub Bad() AnalyzeData() ProcessData() End Sub End Class
  • 40. Strings When building a long string, always (almost) use StringBuilder, not string! C# StringBuilder builder = new StringBuilder("The error "); builder.Append(errorMessage); // errorMessage is defined elsewhere builder.Append("occurred at "); builder.Append(DateTime.Now); Console.WriteLine(builder.ToString()); VB Dim builder As New StringBuilder("The error ") builder.Append(errorMessage) 'errorMessage is defined elsewhere builder.Append("occurred at ") builder.Append(DateTime.Now) Console.WriteLine(builder.ToString())
  • 41. Parameters Use descriptive parameter names Parameter names should be descriptive enough such that the name of the parameter and its value can be used to determine its meaning in most scenarios Do not prefix parameter names with Hungarian type notation Public Function ManageIIs(ByVal server As String, ByVal userName As String, ByVal password As System.Security.SecureString, ByVal domain As String, ByVal instance As String, ByVal action As IIsWebServiceAction) As Int32 End Function
  • 42. Generic Type Parameters If possible use descriptive type parameters for generic parameters Prefix with T Use only T, K etc if is self-explanatory C# public static string ConvertArrayToString<TArray>(TArray[] array) where TArray : IEnumerable { } VB Public Shared Function ConvertArrayToString(Of TArray As {IEnumerable})(ByVal array As TArray()) As String End Function DEMO
  • 43. Commenting Comment your code! While coding or before Keep it short and understandable Mark changes with explanation, who changed it and the date (if that is your company standard) NEVER WAIT UNTIL AFTER YOU ARE DONE CODING!
  • 44. Xml Commenting Now supported by VB.NET and C#! Comment all public classes and methods! XML can be turned into help docs, help html with applications like Sandcastle http://sandcastle.notlong.com Very useful for teams and documentation for users. Make this easy by using GhostDoc http://ghostdoc.notlong.com DEMO
  • 45. Let’s See What We Have Learned/ Know What’s Wrong With This Code?
  • 46. Constructor public class FileCache { public FileCache(string tempPath)   {    var appData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),Global.UserDataFolder); var cacheDir = Path.Combine(appData, tempPath);    if (Directory.Exists(cacheDir) == false) {      Directory.CreateDirectory(cacheDir);   }    } } public class FileCache { public FileCache(string tempPath)   {    this.TempPath = tempPath;   } } 46
  • 47. Method public static string SQLValue(string parameter, string value) {   if (String.IsNullOrEmpty(parameter))   {   throw new ArgumentNullException("parameter");   }     if (string.IsNullOrEmpty(value))     return (parameter + " = NULL");   else     return (parameter + " = '" + value.Trim() + "'"); } public static string SQLValue(string parameter, string value) { if (String.IsNullOrEmpty(parameter))    {      throw new ArgumentNullException("parameter");     }     if (string.IsNullOrEmpty(value))    return (String.Format("{0} = NULL", parameter));   else     return (String.Format("{0} = '{1}'", parameter, value.Trim())); } public static string CreateSQLParameter(string name, string value) { if (String.IsNullOrEmpty(name))   {    throw new ArgumentNullException(”name");   }     return string.IsNullOrEmpty(value) ? (String.Format("{0} = NULL", name)) : (String.Format("{0} = '{1}'", name, value.Trim())); } public static string SQLValue(string name, string value) { if (string.IsNullOrEmpty(value))    return (name + " = NULL");   else    return (name + " = '" + value.Trim() + "'"); }
  • 48. Exception private void UpdateVendor() { try { //Code that causes and exception } catch (ValidationException ex) { //Clean up code throw ex; } catch (Exception ex) { LogWriter.WriteException(ex, System.Diagnostics.TraceEventType.Error, this.Name); } }
  • 49. Structure Public Structure UserInfo Private _contactName As String Public Property ContactName() As String Get Return _contactName End Get Set(ByVal value As String) _contactName = value End Set End Property Private _email As String Public Property Email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property Public Overrides Function ToString() As String Return Me.ContactName End Function Public Overloads Overrides Function GetHashCode() As Integer Return Me.ContactName.GetHashCode Or Me.Email.GetHashCode End Function Public Overloads Overrides Function Equals(ByVal obj As [Object]) As Boolean Dim testObject As UserInfo = CType(obj, UserInfo) If Me.ContactName = testObject.ContactName AndAlso Me.Email = testObject.Email Return True Else Return False End If End Function End Structure Public Structure UserInfo Private _contactName As String Public Property ContactName() As String Get Return _contactName End Get Set(ByVal value As String) _contactName = value End Set End Property Private _email As String Public Property Email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property Public Overrides Function ToString() As String Return Me.ContactName End Function Public Overloads Overrides Function GetHashCode() As Integer Return Me.ContactName.GetHashCode Or Me.Email.GetHashCode End Function End Structure Public Structure UserInfo Private _contactName As String Public Property ContactName() As String Get Return _contactName End Get Set(ByVal value As String) _contactName = value End Set End Property Private _email As String Public Property Email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property Public Overrides Function ToString() As String Return Me.ContactName End Function End Structure Public Structure UserInfo Private _contactName As String Public Property ContactName() As String Get Return _contactName End Get Set(ByVal value As String) _contactName = value End Set End Property Private _email As String Public Property Email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property End Structure
  • 50. Enum public enum MergeTypes { InsCo = 1, Agents = 2, Vendors = 3 } public enum MergeType { InsuranceCompanies, Agents, Vendors } public enum MergeType { None, InsuranceCompanies, Agents, Vendors }
  • 51. Fields public class Contact { protected string mNamePrefix = ""; protected string mFirstName = ""; protected string mLastName = ""; protected string mPhone1 = ""; protected string mExtension1 = ""; protected string mEmailAddress = ""; //Code } public class Contact { private string _namePrefix = string.Empty; protected string NamePrefix { get { return _namePrefix; } set { _namePrefix = value; } } //Code }
  • 52. Events public delegate void ReportListEventHandler(object sender, ReportListEventArgs e); public event ReportListEventHandler ReportSelected; public event EventHandler<ReportListEventArgs> ReportSelected;
  • 54. Products To Help Out StyleCop http://stylecop.notlong.com CodeIt.Right http://codeitright.notlong.com FXCop http://fxcop.notlong.com Or Use Analyze in VS Team Systems Refactor Pro! For Visual Studio http://refactorpro.notlong.com I Use All 4! 54
  • 55. Resourses (Besides My Book) Design Guidelines for Class Library Developers http://DGForClassLibrary.notlong.com .NET Framework General Reference Naming Guidelines http://namingguide.notlong.com

Notes de l'éditeur

  1. C# Use Style Cope to enforce.
  2. DEMO: DefensiveProgramming.vb - SafeIntegerSet
  3. The original exception object should not be re-throwed explicitly. Violation of this rule will complicate debugging and ruin the exception&apos;s stack trace.
  4. ToStringGetHashCodeEquals
  5. Or use an automatic property!