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
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