SlideShare a Scribd company logo
1 of 77
Download to read offline
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
Standardization Simplification
Exposure
Readability
Performance
Standardization
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!
TIP 4
Watch out with the TYPOS!
Simplification
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
TIP 3
Avoid redundant code
Example 1
Example 2
TIP 4
Don’t reinvent the wheel
embrace the framework
TIP 5
Avoid conditionals when
polymorphism can do the job
Readability
TIP 1
Use clear and meaningful
names
TIP 2
Don’t use abbreviations
TIP 3
No magic values
PLEASE DON’T USE SCREAMING CAPS!
TIP 4
Avoid having too many
parameters
TIP 5
Don’t add unneeded
context
TIP 6
Keep your methods small
TIP 7
Use String Interpolation
Exposure
TIP 1
Specify the correct access level for
the variables, methods, properties,
classes based on the context
Expectation
Reality
TIP 2
Immutability is your friend
TIP 3
Mark as readonly what’s readonly :V
TIP 4
Mark classes that shouldn’t
be extended as sealed
Performance
TIP 1
Always use StringBuilder for heavy
String concatenation operations
TIP 2
Throw Fewer Exceptions
TIP 3
Relieve the pressure on the
garbage collector
TIP 4
Async void is evil
TIP 5
Use the right Loop
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

More from Charlin Agramonte

Improving the ux of our xamarin forms apps
Improving the ux of our xamarin forms appsImproving the ux of our xamarin forms apps
Improving the ux of our xamarin forms appsCharlin Agramonte
 
Integrando un rest api con refit
Integrando un rest api con refitIntegrando un rest api con refit
Integrando un rest api con refitCharlin Agramonte
 
Mejorando el UX de nuestras aplicaciones móviles en Xamarin Forms
Mejorando el UX de nuestras aplicaciones móviles en Xamarin FormsMejorando el UX de nuestras aplicaciones móviles en Xamarin Forms
Mejorando el UX de nuestras aplicaciones móviles en Xamarin FormsCharlin Agramonte
 
Desenvolvendo Aplicações SOLID
Desenvolvendo Aplicações SOLIDDesenvolvendo Aplicações SOLID
Desenvolvendo Aplicações SOLIDCharlin Agramonte
 
Mastering XAML in Xamarin Forms
Mastering XAML in Xamarin Forms Mastering XAML in Xamarin Forms
Mastering XAML in Xamarin Forms Charlin Agramonte
 
Como prepararse y conseguir trabajo como Mobile Developer
Como prepararse y conseguir trabajo como Mobile DeveloperComo prepararse y conseguir trabajo como Mobile Developer
Como prepararse y conseguir trabajo como Mobile DeveloperCharlin Agramonte
 
Desarrollando apps multi plataformas con xamarin forms
Desarrollando apps multi plataformas con xamarin formsDesarrollando apps multi plataformas con xamarin forms
Desarrollando apps multi plataformas con xamarin formsCharlin Agramonte
 
C#good practices in 10 minutes
C#good practices in 10 minutesC#good practices in 10 minutes
C#good practices in 10 minutesCharlin Agramonte
 
Xamarin Forms Best Practices
Xamarin Forms Best PracticesXamarin Forms Best Practices
Xamarin Forms Best PracticesCharlin Agramonte
 
Why xamarin forms is awesome
Why xamarin forms is awesomeWhy xamarin forms is awesome
Why xamarin forms is awesomeCharlin Agramonte
 
Prism in xamarin forms from zero to hero
Prism in xamarin forms from zero to hero Prism in xamarin forms from zero to hero
Prism in xamarin forms from zero to hero Charlin Agramonte
 
Xamarin forms from zero to hero
Xamarin forms from zero to heroXamarin forms from zero to hero
Xamarin forms from zero to heroCharlin Agramonte
 
Getting started with xamarin forms
Getting started with xamarin formsGetting started with xamarin forms
Getting started with xamarin formsCharlin Agramonte
 
Xamarin Workshop Noob to Master – Week 6
Xamarin Workshop Noob to Master – Week 6Xamarin Workshop Noob to Master – Week 6
Xamarin Workshop Noob to Master – Week 6Charlin Agramonte
 

More from Charlin Agramonte (20)

Improving the ux of our xamarin forms apps
Improving the ux of our xamarin forms appsImproving the ux of our xamarin forms apps
Improving the ux of our xamarin forms apps
 
Integrando un rest api con refit
Integrando un rest api con refitIntegrando un rest api con refit
Integrando un rest api con refit
 
Mejorando el UX de nuestras aplicaciones móviles en Xamarin Forms
Mejorando el UX de nuestras aplicaciones móviles en Xamarin FormsMejorando el UX de nuestras aplicaciones móviles en Xamarin Forms
Mejorando el UX de nuestras aplicaciones móviles en Xamarin Forms
 
Desenvolvendo Aplicações SOLID
Desenvolvendo Aplicações SOLIDDesenvolvendo Aplicações SOLID
Desenvolvendo Aplicações SOLID
 
Mastering XAML in Xamarin Forms
Mastering XAML in Xamarin Forms Mastering XAML in Xamarin Forms
Mastering XAML in Xamarin Forms
 
C# Good practices
C# Good practicesC# Good practices
C# Good practices
 
Starting my blog
Starting my blogStarting my blog
Starting my blog
 
Como prepararse y conseguir trabajo como Mobile Developer
Como prepararse y conseguir trabajo como Mobile DeveloperComo prepararse y conseguir trabajo como Mobile Developer
Como prepararse y conseguir trabajo como Mobile Developer
 
Desarrollando apps multi plataformas con xamarin forms
Desarrollando apps multi plataformas con xamarin formsDesarrollando apps multi plataformas con xamarin forms
Desarrollando apps multi plataformas con xamarin forms
 
C#good practices in 10 minutes
C#good practices in 10 minutesC#good practices in 10 minutes
C#good practices in 10 minutes
 
Xamarin Forms Best Practices
Xamarin Forms Best PracticesXamarin Forms Best Practices
Xamarin Forms Best Practices
 
Xamarin Forms Evolution
Xamarin Forms EvolutionXamarin Forms Evolution
Xamarin Forms Evolution
 
Why xamarin forms is awesome
Why xamarin forms is awesomeWhy xamarin forms is awesome
Why xamarin forms is awesome
 
Visual studio 2019 launch
Visual studio 2019 launch Visual studio 2019 launch
Visual studio 2019 launch
 
Prism in xamarin forms from zero to hero
Prism in xamarin forms from zero to hero Prism in xamarin forms from zero to hero
Prism in xamarin forms from zero to hero
 
Xamarin forms - overcloud
Xamarin forms - overcloudXamarin forms - overcloud
Xamarin forms - overcloud
 
Xamarin forms from zero to hero
Xamarin forms from zero to heroXamarin forms from zero to hero
Xamarin forms from zero to hero
 
Xaml tips and tricks
Xaml tips and tricksXaml tips and tricks
Xaml tips and tricks
 
Getting started with xamarin forms
Getting started with xamarin formsGetting started with xamarin forms
Getting started with xamarin forms
 
Xamarin Workshop Noob to Master – Week 6
Xamarin Workshop Noob to Master – Week 6Xamarin Workshop Noob to Master – Week 6
Xamarin Workshop Noob to Master – Week 6
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
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
 
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
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
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
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
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
 
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
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"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
 
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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

C# Best Practices for Standardization, Simplification, Readability & Performance