Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Tips and Tricks To Improve Code Readability in C#
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Jaime
June 10, 2012
Programming
5
1.1k
Tips and Tricks To Improve Code Readability in C#
Jaime
June 10, 2012
Tweet
Share
More Decks by Jaime
See All by Jaime
Mastering the Arcane Art of JavaScriptmancy @ DevSum
vintharas
1
930
From Angular 1 to Angular 2
vintharas
0
2.2k
Mastering The Arcane Art of JavaScriptmancy - Swetugg Edition
vintharas
1
1.6k
Mastering the Arcane Art of JavaScript-mancy
vintharas
0
3.9k
Level-Up Your Code-Fu With Chuck Norris (and ReSharper, VsVim and NCrunch)
vintharas
0
1.4k
The Web Of The Future - Knockout Components
vintharas
1
1.3k
Introduction to RavenDB
vintharas
0
1.4k
The Path to Jedi Text Editing With VIM - Padawan Edition
vintharas
0
1.9k
TypeScript
vintharas
3
390
Other Decks in Programming
See All in Programming
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
2
640
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
330
AIプロダクト時代のQAエンジニアに求められること
imtnd
2
700
あなたはユーザーではない #PdENight
kajitack
4
300
15年目のiOSアプリを1から作り直す技術
teakun
1
600
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
7.5k
AI駆動開発の本音 〜Claude Code並列開発で見えたエンジニアの新しい役割〜
hisuzuya
4
480
オブザーバビリティ駆動開発って実際どうなの?
yohfee
3
690
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
4
390
猫の手も借りたい!ので AIエージェント猫を作って社内に放した話 Claude Code × Container Lambda の Slack Bot "DevNeko"
naramomi7
0
240
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
230
New in Go 1.26 Implementing go fix in product development
sunecosuri
0
330
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
The Language of Interfaces
destraynor
162
26k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
460
Chasing Engaging Ingredients in Design
codingconduct
0
130
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.4k
Documentation Writing (for coders)
carmenintech
77
5.3k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
810
The Mindset for Success: Future Career Progression
greggifford
PRO
0
270
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
140
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
330
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
300
Transcript
P2P Code Academy Becoming a C# Warrior-Poet or Tips and
Tricks To Improve Code Readability in C# 4 30th March
C#
Outline • Object Initializers • Named Arguments • Extension Methods
• LINQ
Ye Olde Classic Constructor
Object Initializers vs Constructors
Object Initializers Uses Default Constructor!
Object Initializers. Benefits • Improved Readability • Less boiler-plate code
– Don’t even need a constructor!
DEMO OBJECT INITIALIZERS
Collection Initializers
Named Arguments • Explicitly name method arguments
Named Arguments. Benefits What the heck is true?
Named Arguments. Benefits
Extension Methods Add methods to existing types: • No need
to create derived type • No need to re-compile existing type • No need to modify original type • Just static methods in disguise!
Extension Methods. Syntax Special use of keyword this Look like
instance methods!
Extension Methods Add a method to a primitive type Adding
this method to the string class
Extension Methods Add a method to a primitive type Before
After
DEMO EXTENSION METHODS
Extension Methods Add a method to a compiled custom type
LINQ Query language within C# and VB.NET • Very Expressive
• Extensible • Integrated – LINQ to Objects – LINQ to SQL – LINQ to XML – LINQ to Entities
LINQ. Example Filtering a collection (People older than 30)
LINQ. Example Query Syntax Method Chain Syntax
DEMO LINQ
Summary • Object Initializers • Named Arguments • Extension Methods
• LINQ
If you put it all together... Sonnet 138. The Passionate
Pilgrim C# version while (myLove.Swears(that: ”She is made of truth”)) { do I.Believe(her); while (she.Lies()) she.Might(s => s.Think(I == ”some untutored youth”)); she.Might(s => s.Think(I == ”unskillful”)); ... }
C#
If you want to know more…
References • Object and Collection Initializers http://bit.ly/csharp-object-collection-initializer • Named Arguments
http://bit.ly/csharp-named-arguments • Extension Methods http://bit.ly/csharp-extension-methods • LINQ http://bit.ly/linq-language-integrated-query
Thank you