SlideShare a Scribd company logo
1 of 12
Elizabeth Szabo
Senior ASP.NET and SharePoint Developer
at rmsource, inc.
@lizascript
szaboe23@yahoo.com
TRINUG presentation - Lightning talks - December of 2012
• Based on a true experience
• Not without lessons learned
Once upon a time….
TRINUG presentation - Lightning talks - December of 2012
Once upon a time there was a princess. A Brave Ninja
Programmer Princess. She liked writing code, as she liked a lot
of other things too, like growing tomatoes and peppers, trying
new recipes and driving to work (just kidding).
It was the last day of Iteration 27. She already resolved all the
bug tickets by yesterday. Finally she can switch back to her
SharePoint Development.
Sat down at her desk, had her coffee and vitamins, checked her
emails, newsletters and twitter. She was ready to Rock and Roll.
She opened Visual Studio and waited for the SharePoint solution
to load. She was so excited!
Suddenly, an email popped up. A new bug fix ticket. A new
ticket? For iteration 27? On the last day? A same day ticket?
What happened? The customer clicked on a button, and
something really bad happened. The numbers on the screen were
wrong.
TRINUG presentation - Lightning talks - December of 2012
She read the ticket twice, tried to reproduce the issue. She
succeeded. Darn it. The customer was correct, the code was not.
Alright. Closed the SharePoint solution and opened the .Net one.
It was a nice one .NET 3.5, Linq to SQL, N-tier, custom
controls, code behinds, data access layer, business layer, Unity.
Fairly organized.
Quickly located the file she needed to check out. Button click
event handler, nice and lean. If the form is valid, save the data
and show the result. Can’t be an issue. Jumped to the form
validation code and started to read it.
Validating input, checking business rules. Piece of cake. Additional
business rules, per customer – the comment says. Duh, who else?
She read on. She scrolled. And read and scrolled and paged up
and paged down and paged up and down.
TRINUG presentation - Lightning talks - December of 2012
The Brave Ninja Princess felt lost in the code. 123 lines of code
in this one function? Are you kidding? No wonder she could not
remember at the last if statement what happened in the 2nd
one!
She tried to find the conditions, skip the irrelevant ones, but it
was just so difficult to spot them on the screen.
“Oh, those darn ifs!” – she cried out loud.
“How can I remember all that code? I can’t memorize it all. I am
not a magical princess, just a programmer one.”
“What to do? What to do?
“What if I put comments and focus on them?”
“What if I mark the conditions with bookmarks or breakpoints
and just read the marked lines?”
“What if I add regions and collapse them?”
“What if I copy the code to NotePad++? At least I could see the
guides! Now that just stupid. ”
TRINUG presentation - Lightning talks - December of 2012
“A function should fit on the screen” - she
remembered.
“That’s the key. If I could see the whole function at
once, I could find the right spot! But how can I make
it to fit?”
“Well, I can change the font … my glasses are not
strong enough.”
“Maybe I can re-factor the code. That’s the right
thing to do! Too bad, that it is already lunch time,
and it is a same-day ticket and anyway who will pay
8 hours of refactoring for 2 lines of new code?”
“I need a better solution. I have spaghetti code, that’s
what I have, I need to deal with it as is.”
“Well, I am not a magical princess, but I am a Ninja.
I am a Google Ninja. I can find any solution with
Google!”
TRINUG presentation - Lightning talks - December of 2012
She opened a browser and started to type.
Within five minutes she found two Visual Studio
Extensions. Indent Guides and C# outline.
One draws indentation guides and colors it for
the current block. Also, it puts a comment after
the closing bracket, so you know what ended
there.
The other one collapses any block that is
surrounded by curly brackets. All ifs and else-s,
foreach-es and switches!
TRINUG presentation - Lightning talks - December of 2012
TRINUG presentation - Lightning talks - December of 2012
C# outline extension, Indent Guides
•Collapsible blocks (if, for each, switch etc.)
•Outline guides visual aid
•See what block you are in
•Know what the closing bracket closes
TRINUG presentation - Lightning talks - December of 2012
She downloaded and installed the extensions. She
collapsed all ifs.
“Hey my function fits on the screen now! I can
read it, I can understand it! I can fix it!”
Within an hour the code was fixed and the client
was happy.
The Brave Ninja Programmer Princess smiled
and coded happily ever after.
The end.
TRINUG presentation - Lightning talks - December of 2012
Visual Studio Extensions are your friend
Resources:
C# outline extension,
Indent Guides
in
http://visualstudiogallery.msdn.microsoft.com
Bonus shortcuts:
Collapse to definition: Ctrl+M, Ctrl+O
Hide commented out block: Ctrl+M, Ctrl+H
TRINUG presentation - Lightning talks - December of 2012

More Related Content

Viewers also liked (10)

Adult education and employment
Adult education and employmentAdult education and employment
Adult education and employment
 
Imc
ImcImc
Imc
 
Cuadro de investigación
Cuadro de investigaciónCuadro de investigación
Cuadro de investigación
 
Calculadoras online
Calculadoras onlineCalculadoras online
Calculadoras online
 
Atelier5 les enfants
Atelier5 les enfantsAtelier5 les enfants
Atelier5 les enfants
 
Escale santé n°2
Escale santé n°2Escale santé n°2
Escale santé n°2
 
Sistemas de ecuaciones ii
Sistemas de ecuaciones iiSistemas de ecuaciones ii
Sistemas de ecuaciones ii
 
Atelier1 apéro dinatoire
Atelier1 apéro dinatoireAtelier1 apéro dinatoire
Atelier1 apéro dinatoire
 
Presentación cierre iniciativa marzo 1
Presentación cierre iniciativa marzo 1Presentación cierre iniciativa marzo 1
Presentación cierre iniciativa marzo 1
 
Zev yochanan berkowitz nature
Zev yochanan berkowitz natureZev yochanan berkowitz nature
Zev yochanan berkowitz nature
 

Similar to If(s){} Bedtime Story to Programmers

Tips on how to break down a programming problem
Tips on how to break down a programming problemTips on how to break down a programming problem
Tips on how to break down a programming problemRona Chong
 
Unplugged programming
Unplugged programmingUnplugged programming
Unplugged programmingDoug Taylor
 
My solution to malware.lu HackGyver's challenges.
My solution to malware.lu HackGyver's challenges.My solution to malware.lu HackGyver's challenges.
My solution to malware.lu HackGyver's challenges.Aodrulez
 
Legacy code rehab.
Legacy code rehab.Legacy code rehab.
Legacy code rehab.johnnonolan
 
Idea stickies green bar - Wroclaw edition
Idea stickies green bar - Wroclaw editionIdea stickies green bar - Wroclaw edition
Idea stickies green bar - Wroclaw editionAlberto Brandolini
 
[Game] Programming I Didn't Learn in School
[Game] Programming I Didn't Learn in School[Game] Programming I Didn't Learn in School
[Game] Programming I Didn't Learn in School💻 Anton Gerdelan
 
Building Social Software for the Anti-Social: Part I
Building Social Software for the Anti-Social: Part IBuilding Social Software for the Anti-Social: Part I
Building Social Software for the Anti-Social: Part Icodinghorror
 
Hilary Weaver - He Doesn't Like You
Hilary Weaver  - He Doesn't Like YouHilary Weaver  - He Doesn't Like You
Hilary Weaver - He Doesn't Like YouQA or the Highway
 
Pair Programming - Be the best pair you can be.
Pair Programming - Be the best pair you can be.Pair Programming - Be the best pair you can be.
Pair Programming - Be the best pair you can be.David Morgantini
 
Introduction to frameworks
Introduction to frameworksIntroduction to frameworks
Introduction to frameworksb164739
 
04. introduction to frameworks
04. introduction to frameworks04. introduction to frameworks
04. introduction to frameworksdipalsoul
 
Good Qualities of a developer
Good Qualities of a developerGood Qualities of a developer
Good Qualities of a developerSophia Dagli
 
Scratch To Flex Your Creativity Workshop
Scratch To Flex Your Creativity WorkshopScratch To Flex Your Creativity Workshop
Scratch To Flex Your Creativity WorkshopKaren VItek
 
How To Be A Real Developer In Two Easy Steps
How To Be A Real Developer In Two Easy StepsHow To Be A Real Developer In Two Easy Steps
How To Be A Real Developer In Two Easy Stepsnorthofnormal
 
From Web to Game Development
From Web to Game DevelopmentFrom Web to Game Development
From Web to Game DevelopmentPietro Polsinelli
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair ProgrammingSteven Smith
 
Git Makes Me Angry Inside - DrupalCon Prague
Git Makes Me Angry Inside - DrupalCon PragueGit Makes Me Angry Inside - DrupalCon Prague
Git Makes Me Angry Inside - DrupalCon PragueEmma Jane Hogbin Westby
 
30% faster coder on-boarding when you have a code cookbook
30% faster coder on-boarding when you have a code cookbook30% faster coder on-boarding when you have a code cookbook
30% faster coder on-boarding when you have a code cookbookGabriel Paunescu 🤖
 
I'm Not Trying to Piss You Off – Or Why Designers Insist on Costly Features
I'm Not Trying to Piss You Off – Or Why Designers Insist on Costly FeaturesI'm Not Trying to Piss You Off – Or Why Designers Insist on Costly Features
I'm Not Trying to Piss You Off – Or Why Designers Insist on Costly FeaturesMagdalena Zadara
 

Similar to If(s){} Bedtime Story to Programmers (20)

Tips on how to break down a programming problem
Tips on how to break down a programming problemTips on how to break down a programming problem
Tips on how to break down a programming problem
 
Unplugged programming
Unplugged programmingUnplugged programming
Unplugged programming
 
My solution to malware.lu HackGyver's challenges.
My solution to malware.lu HackGyver's challenges.My solution to malware.lu HackGyver's challenges.
My solution to malware.lu HackGyver's challenges.
 
Legacy code rehab.
Legacy code rehab.Legacy code rehab.
Legacy code rehab.
 
Idea stickies green bar - Wroclaw edition
Idea stickies green bar - Wroclaw editionIdea stickies green bar - Wroclaw edition
Idea stickies green bar - Wroclaw edition
 
[Game] Programming I Didn't Learn in School
[Game] Programming I Didn't Learn in School[Game] Programming I Didn't Learn in School
[Game] Programming I Didn't Learn in School
 
Building Social Software for the Anti-Social: Part I
Building Social Software for the Anti-Social: Part IBuilding Social Software for the Anti-Social: Part I
Building Social Software for the Anti-Social: Part I
 
Hilary Weaver - He Doesn't Like You
Hilary Weaver  - He Doesn't Like YouHilary Weaver  - He Doesn't Like You
Hilary Weaver - He Doesn't Like You
 
Pair Programming - Be the best pair you can be.
Pair Programming - Be the best pair you can be.Pair Programming - Be the best pair you can be.
Pair Programming - Be the best pair you can be.
 
Introduction to frameworks
Introduction to frameworksIntroduction to frameworks
Introduction to frameworks
 
04. introduction to frameworks
04. introduction to frameworks04. introduction to frameworks
04. introduction to frameworks
 
Good Qualities of a developer
Good Qualities of a developerGood Qualities of a developer
Good Qualities of a developer
 
Scratch To Flex Your Creativity Workshop
Scratch To Flex Your Creativity WorkshopScratch To Flex Your Creativity Workshop
Scratch To Flex Your Creativity Workshop
 
How To Be A Real Developer In Two Easy Steps
How To Be A Real Developer In Two Easy StepsHow To Be A Real Developer In Two Easy Steps
How To Be A Real Developer In Two Easy Steps
 
Individual Report
Individual ReportIndividual Report
Individual Report
 
From Web to Game Development
From Web to Game DevelopmentFrom Web to Game Development
From Web to Game Development
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair Programming
 
Git Makes Me Angry Inside - DrupalCon Prague
Git Makes Me Angry Inside - DrupalCon PragueGit Makes Me Angry Inside - DrupalCon Prague
Git Makes Me Angry Inside - DrupalCon Prague
 
30% faster coder on-boarding when you have a code cookbook
30% faster coder on-boarding when you have a code cookbook30% faster coder on-boarding when you have a code cookbook
30% faster coder on-boarding when you have a code cookbook
 
I'm Not Trying to Piss You Off – Or Why Designers Insist on Costly Features
I'm Not Trying to Piss You Off – Or Why Designers Insist on Costly FeaturesI'm Not Trying to Piss You Off – Or Why Designers Insist on Costly Features
I'm Not Trying to Piss You Off – Or Why Designers Insist on Costly Features
 

Recently uploaded

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

If(s){} Bedtime Story to Programmers

  • 1.
  • 2. Elizabeth Szabo Senior ASP.NET and SharePoint Developer at rmsource, inc. @lizascript szaboe23@yahoo.com TRINUG presentation - Lightning talks - December of 2012
  • 3. • Based on a true experience • Not without lessons learned Once upon a time…. TRINUG presentation - Lightning talks - December of 2012
  • 4. Once upon a time there was a princess. A Brave Ninja Programmer Princess. She liked writing code, as she liked a lot of other things too, like growing tomatoes and peppers, trying new recipes and driving to work (just kidding). It was the last day of Iteration 27. She already resolved all the bug tickets by yesterday. Finally she can switch back to her SharePoint Development. Sat down at her desk, had her coffee and vitamins, checked her emails, newsletters and twitter. She was ready to Rock and Roll. She opened Visual Studio and waited for the SharePoint solution to load. She was so excited! Suddenly, an email popped up. A new bug fix ticket. A new ticket? For iteration 27? On the last day? A same day ticket? What happened? The customer clicked on a button, and something really bad happened. The numbers on the screen were wrong. TRINUG presentation - Lightning talks - December of 2012
  • 5. She read the ticket twice, tried to reproduce the issue. She succeeded. Darn it. The customer was correct, the code was not. Alright. Closed the SharePoint solution and opened the .Net one. It was a nice one .NET 3.5, Linq to SQL, N-tier, custom controls, code behinds, data access layer, business layer, Unity. Fairly organized. Quickly located the file she needed to check out. Button click event handler, nice and lean. If the form is valid, save the data and show the result. Can’t be an issue. Jumped to the form validation code and started to read it. Validating input, checking business rules. Piece of cake. Additional business rules, per customer – the comment says. Duh, who else? She read on. She scrolled. And read and scrolled and paged up and paged down and paged up and down. TRINUG presentation - Lightning talks - December of 2012
  • 6. The Brave Ninja Princess felt lost in the code. 123 lines of code in this one function? Are you kidding? No wonder she could not remember at the last if statement what happened in the 2nd one! She tried to find the conditions, skip the irrelevant ones, but it was just so difficult to spot them on the screen. “Oh, those darn ifs!” – she cried out loud. “How can I remember all that code? I can’t memorize it all. I am not a magical princess, just a programmer one.” “What to do? What to do? “What if I put comments and focus on them?” “What if I mark the conditions with bookmarks or breakpoints and just read the marked lines?” “What if I add regions and collapse them?” “What if I copy the code to NotePad++? At least I could see the guides! Now that just stupid. ” TRINUG presentation - Lightning talks - December of 2012
  • 7. “A function should fit on the screen” - she remembered. “That’s the key. If I could see the whole function at once, I could find the right spot! But how can I make it to fit?” “Well, I can change the font … my glasses are not strong enough.” “Maybe I can re-factor the code. That’s the right thing to do! Too bad, that it is already lunch time, and it is a same-day ticket and anyway who will pay 8 hours of refactoring for 2 lines of new code?” “I need a better solution. I have spaghetti code, that’s what I have, I need to deal with it as is.” “Well, I am not a magical princess, but I am a Ninja. I am a Google Ninja. I can find any solution with Google!” TRINUG presentation - Lightning talks - December of 2012
  • 8. She opened a browser and started to type. Within five minutes she found two Visual Studio Extensions. Indent Guides and C# outline. One draws indentation guides and colors it for the current block. Also, it puts a comment after the closing bracket, so you know what ended there. The other one collapses any block that is surrounded by curly brackets. All ifs and else-s, foreach-es and switches! TRINUG presentation - Lightning talks - December of 2012
  • 9. TRINUG presentation - Lightning talks - December of 2012
  • 10. C# outline extension, Indent Guides •Collapsible blocks (if, for each, switch etc.) •Outline guides visual aid •See what block you are in •Know what the closing bracket closes TRINUG presentation - Lightning talks - December of 2012
  • 11. She downloaded and installed the extensions. She collapsed all ifs. “Hey my function fits on the screen now! I can read it, I can understand it! I can fix it!” Within an hour the code was fixed and the client was happy. The Brave Ninja Programmer Princess smiled and coded happily ever after. The end. TRINUG presentation - Lightning talks - December of 2012
  • 12. Visual Studio Extensions are your friend Resources: C# outline extension, Indent Guides in http://visualstudiogallery.msdn.microsoft.com Bonus shortcuts: Collapse to definition: Ctrl+M, Ctrl+O Hide commented out block: Ctrl+M, Ctrl+H TRINUG presentation - Lightning talks - December of 2012