ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
C# Best Practices
Charlin Agramonte &
Rendy Del Rosario
Rendy Del Rosario
charlin@crossgeeks.com
@chard003
xamgirl.com
rendy@crossgeeks.com
@rdelrosario
xamboy.com
Charlin Agramonte
C# Best Practices
Standardization Simplification
Exposure
Readability
Performance
Standardization
C# Best Practices
TIP 1
Use language conventions
https://github.com/ktaranov/naming-convention/blob/master/C%23%20Coding%20Standards%20and%20Naming%20Conventions.md
TIP 2
Establish coding standards
Or
Or
Or
TIP 3
No spanglish POR FAVOR!
C# Best Practices
TIP 4
Watch out with the TYPOS!
C# Best Practices
Simplification
C# Best Practices
TIP 1
Why do more if you can
do less
Example 1
Example 2
Example 3
Example 4
Example 5
Example 6
TIP 2
Avoid nesting too deeply
and return early
C# Best Practices
TIP 3
Avoid redundant code
Example 1
Example 2
TIP 4
Don¡¯t reinvent the wheel
embrace the framework
C# Best Practices
TIP 5
Avoid conditionals when
polymorphism can do the job
C# Best Practices
Readability
C# Best Practices
TIP 1
Use clear and meaningful
names
C# Best Practices
TIP 2
Don¡¯t use abbreviations
C# Best Practices
TIP 3
No magic values
PLEASE DON¡¯T USE SCREAMING CAPS!
TIP 4
Avoid having too many
parameters
C# Best Practices
TIP 5
Don¡¯t add unneeded
context
C# Best Practices
TIP 6
Keep your methods small
C# Best Practices
TIP 7
Use String Interpolation
C# Best Practices
Exposure
C# Best Practices
TIP 1
Specify the correct access level for
the variables, methods, properties,
classes based on the context
C# Best Practices
Expectation
Reality
TIP 2
Immutability is your friend
C# Best Practices
TIP 3
Mark as readonly what¡¯s readonly :V
C# Best Practices
TIP 4
Mark classes that shouldn¡¯t
be extended as sealed
C# Best Practices
Performance
C# Best Practices
TIP 1
Always use StringBuilder for heavy
String concatenation operations
C# Best Practices
TIP 2
Throw Fewer Exceptions
C# Best Practices
TIP 3
Relieve the pressure on the
garbage collector
C# Best Practices
TIP 4
Async void is evil
C# Best Practices
TIP 5
Use the right Loop
C# Best Practices
TIP 6
Stay tuned to the evolution of C#
charlin@crossgeeks.com
@chard003
xamgirl.com
rendy@crossgeeks.com
@rdelrosario
xamboy.com
Thanks!!!
- 35% Off
NOSPAGUETTI
Rifa time!!!

More Related Content

C# Best Practices