Top Banner
@elbruno How To Code Efficiently Bruno Capuano @elbruno #MSFTHacks
53

2017 03 25 Microsoft Hacks, How to code efficiently

Apr 05, 2017

Download

Technology

Bruno Capuano
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

How To Code Efficiently

Bruno Capuano@elbruno

#MSFTHacks

Page 2: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Bruno CapuanoInnovation Manager@elbruno

http://www.elbruno.com

Page 3: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Learn to Unlearn0#

How To Code EfficientlyMSFTHacks201

7

Page 4: 2017 03 25 Microsoft Hacks, How to code efficiently
Page 5: 2017 03 25 Microsoft Hacks, How to code efficiently
Page 6: 2017 03 25 Microsoft Hacks, How to code efficiently
Page 7: 2017 03 25 Microsoft Hacks, How to code efficiently
Page 8: 2017 03 25 Microsoft Hacks, How to code efficiently

“Your wife is always right. Even when she is wrong,

after some time you realize you are wrong and

she is right.“

Dr. House

Page 9: 2017 03 25 Microsoft Hacks, How to code efficiently

You probably don’t know how to tie

laces

Page 10: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Visual Studio 2017 & Visual Studio Code

1#How To Code EfficientlyMSFTHacks201

7

Page 11: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Most popular technologies

http://stackoverflow.com/research/developer-survey-2016#technology-most-popular-technologies

Page 12: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Most loved technologies

http://stackoverflow.com/research/developer-survey-2016#technology-most-loved-dreaded-and-wanted

Page 13: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Changing our tune…

Run on Windows.NET as system componentRun on VM (CLR)Black box compilersEdit in Visual StudioProprietary

Run everywhereDeploy with appCompile to nativeOpen compiler APIsUse your favorite editorOpen source

Page 14: 2017 03 25 Microsoft Hacks, How to code efficiently

Get the Tools https://www.visualstudio.com/

Page 15: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Code>Build>Debug

We have new tools !

2#How To Code EfficientlyMSFTHacks201

7

Page 16: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Code process flow … :D

BUILDDEBUGEDIT

Developer does this #40 times a day (Linker)

Page 17: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Demo

Page 18: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Augment Visual Studio 2017

3#How To Code EfficientlyMSFTHacks201

7

Page 19: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Stay in the zoneHeads up display for codeLightbulbs provide quick actions in the editor for suggested code fixes, refactoringSee elapsed time while debugging to identify slow running code using PefTips. Get details by clicking directly into the diagnostic toolsRenaming highlights words to be updated with all words updating at the same time

Setting customization and roamingUsing your Microsoft account enables you to access your settings across editions and versions so that it always feels familiar

Page 20: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Code process flow … :D

BUILDDEBUGEDIT

Developer does this #40 times a day (Linker)

http://roslyn.io@roslyn

Page 21: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Page 22: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Write new features faster

1

Page 23: 2017 03 25 Microsoft Hacks, How to code efficiently

TuplesEasily pass around groups of values

Page 24: 2017 03 25 Microsoft Hacks, How to code efficiently

Pattern matchingTest the shape and content of expressions

Page 25: 2017 03 25 Microsoft Hacks, How to code efficiently

Local functionsClean up classes by nesting helpers

Page 26: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Provide open source API

2

Page 27: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Analyzers identify errors and provide fixes in your

code as you type, i.e. without having to wait for a

build.

Page 28: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

VSIX NUGET

Page 29: 2017 03 25 Microsoft Hacks, How to code efficiently

Teach new language features/concepts

Introduce best practices for SDK

Enforce code style rules

Identify errors before build

Page 30: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Analyzer EcosystemFxCopAnalyzers (MSFT):

https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers/

SonarLint http://www.sonarlint.org/visualstudio/rules/index.htmlStyleCopAnalyzers:

https://github.com/DotNetAnalyzers/StyleCopAnalyzersCodeCracker https://github.com/code-cracker/code-crackerRoslynator https://github.com/JosefPihrt/RoslynatorVS Refactoring Essentials:

http://vsrefactoringessentials.com/GCop: https://visualstudiogallery.msdn.microsoft.com/f082f20e-

5123-4c0d-975a-0a17995d858b

Page 31: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Productivity

Refactoring supportNavigation/searchStyle enforcement

Testing

Better IntelliSense

Page 32: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Demo

Page 33: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Don’t go for “Yet Another …”

4#How To Code EfficientlyMSFTHacks201

7

Page 34: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

“Yet another” defintion …Among programmers, yet another (often abbreviated ya, Ya or YA in the initial part of an acronym) is an idiomatic qualifier in the name of a computer program, organisation, or event that is confessedly unoriginal.[1]

Stephen C. Johnson is credited with establishing the naming convention in the late 1970s when he named his compiler-compiler yacc (Yet Another Compiler-Compiler), since he felt there were already numerous compiler-compilers in circulation at the time.https://en.wikipedia.org/wiki/Yet_another

As in "Yet Another AI Group" or "Yet Another Simulated Annealing Algorithm". If used of others' work, it describes something of which there are already far too many. In hackish acronyms the "YA" prefix almost invariably expands to Yet Another, e.g. YABA, YAUN.http://www.dictionary.com/browse/yet-another

YAAF – Yet Another Application FrameworkYabasic – Yet Another BASICYabause – Yet Another Broken and Uncomplete Saturn EmulatorYacc – Yet another compiler compilerYacas – Yet another computer algebra systemYACT – Yet another capture the flag teamYACTA – Yet Another CT AnalyzerYaDICs – Yet another Digital Image Correlation SoftwareYADIFA – Yet Another DNS Implementation For AllYafaRay – Yet another free Ray tracerYafc – Yet another FTP clientYAFFS – Yet Another Flash File SystemYafra – Yet Another FrameworkYAGO – Yet Another Great OntologyYahoo! – Yet another hierarchical, officious oracle[2]

Yakuake – Yet Another KuakeYAM – Yet Another Mailer, an email clientYAML – Yet Another Markup Language. Later redefined to YAML Ain't Markup Language, making a recursive acronymYandex – Yet another indexer,[3] a web search engine and indexYA-NewsWatcher – a Usenet client for classic Mac OSYANG – Yet Another Next GenerationYaourt – Yet AnOther User Repository ToolYAP – Yet Another Previewer, document previewerYAP – Yet Another Prolog, an implementation of the Prolog programming languageYAPC – Yet Another Perl ConferenceOperator YAPO – Yet Another Portable OperaYARN – Yet Another Resource NegotiatorYARP – Yet Another Robot PlatformYARV – Yet Another Ruby VMYasara – Yet Another Scientific Artificial Reality Application, a molecular modeling programYasca – Yet Another Source Code AnalyzerYaST – Yet another Setup Tool, an operating system installation and configuration wizard for SUSE Linux distributionsY.A.S.U. – Yet Another SecuROM UtilityYate – Yet Another Telephony Engine, VoIP softwareYAWC – Yet Another Wersion of CitadelYAWL – Yet Another Workflow Language, a business process modeling language for diagramming workflow patternsYaws – Yet another web serverYAZ – Yet Another Z39.50 Toolkit

Page 35: 2017 03 25 Microsoft Hacks, How to code efficiently

Demo UWP Community Toolkit 1.3

Page 36: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Thinks on DevOps5#

How To Code EfficientlyMSFTHacks201

7

Page 37: 2017 03 25 Microsoft Hacks, How to code efficiently

Plan1 Monitor +

Learn

Release

Develop + Test2

Development

Production

4

3

DevOps

Page 38: 2017 03 25 Microsoft Hacks, How to code efficiently

It starts with an idea – and a plan how to turn this idea into reality …

Manage work

Develop + Test

1

PlanProject starts

PlanTrack progress

Page 39: 2017 03 25 Microsoft Hacks, How to code efficiently

Write Code

Unit Testing

2

Build

Version Control

Build Verification

Release

Once the iteration starts, developers turn great ideas into features …

Develop + Test

Page 40: 2017 03 25 Microsoft Hacks, How to code efficiently

Source Build

Continuous Integration

Value• Accelerate Delivery• Repeatability • Optimized Resources

Measure• More frequent releases• MTTR• MTTD

cspkg

Test

DEV OPSOPS

Page 41: 2017 03 25 Microsoft Hacks, How to code efficiently

CloudLoad

TestingIntegration testing

environment

Automated functional testing environment

3

Pre-production environment

Stagingenvironment

Monitor + Learn

When all tests pass, the build is deployed to testing environments for each stage in the release process

Release

Page 42: 2017 03 25 Microsoft Hacks, How to code efficiently

SOURCE REPO DEV

Release Management

Value• Optimized Resources• Accelerate Delivery

Measure• Deployment Rate• MTTR• Availability

STAGE

PRODUCTIONDEV OPS

Page 43: 2017 03 25 Microsoft Hacks, How to code efficiently

Learn and understand how users use your app, how it reacts and quickly fix issues and bugs

Monitor + Learn

4

Monitor

Feedback

Plan the next iteration

Page 44: 2017 03 25 Microsoft Hacks, How to code efficiently

Monitor and LearnTesting in Production

PRODUCTION A PRODUCTION B

90% 10%

TelemetryPRODUCTIO

N

Fault Injection

X

X X

X

Page 45: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbrunoMICROSOFT CONF IDENT IAL – INTERNAL ONLY

TFS

01

Deve

lop Developer Workstation

Team Collaboration

02

Build

& Te

st Build/CI

Test

Release Management for Visual Studio

Microsoft Test Manager

03

Depl

oy

Release Management for Visual Studio

Release

Automation Service

Azure Resource Management

PowerShell | WAML

xPlat Command Line

04

Mon

itor &

Le

arnMonitor

MicrosoftEcosystem

Application Insights

People | Process | Tools

Workstations - On-Premises | Hybrid | Cloud Monitoring - On-Premises | Hybrid | CloudALM Services - On-Premises | Hybrid | Cloud

DEV TEST QA

Environments - On-Premises | Hybrid | Cloud

TFS / VSTS

TFS / VSTS

TFS / VSTS

VSTS

Page 46: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

01

Deve

lop Developer Workstation

Team Collaboration

02

Build

& Te

st Build/CI

Test

03

Depl

oy Configuration 04

Mon

itor &

Le

arnMonitor

This graphic shows OSS and partner products that are integrated with the Microsoft DevOps solution

MixedEcosystem

Release

People | Process | Tools

Page 47: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Hackathon Continuous Integration

It’s just a simple ASP.NET or Node.js web api!

Considerations:• CI for dependent services that you own

that are called by the bot• LUIS, Databases, external APIs• Put bot configs in Environment Variables or

Release definition to share the same build

Build

cspkg

Page 48: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Hackathon Testing

How do you test a bot? Considerations, forget about:• Auth• Mocking connector, mocking LUIS calls• Unit/Functional/Load testing https://www.microsoft.com/developerblog/real-life-code/2017/01/20/Bot-Framework-Unit-Testing.html https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Tests/Microsoft.Bot.Sample.Tests/AlarmBotTests.cs#L91 https://github.com/Microsoft/BotBuilder/tree/master/CSharp/Tests/Microsoft.Bot.Builder.Tests/Scripts

Test

Page 49: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Hackathon Cont. Deployment

It’s just an ASP.NET or Node.js web api! Considerations:• CD for dependent services that you own that

are called by the bot• Updates and retraining of LUIS models and

other intelligent systems• Bot state• Functional/performance tests

Deploy

X

Page 50: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Online demoThiago Almeida & Donovan Brown(18 min video on Channel 9)https://channel9.msdn.com/Series/DevOps-for-the-Bot-Framework/Continuous-Deployment-and-Release-Management-for-the-Bot-Framework

Page 51: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Code Efficiently1. Visual Studio 2017 & Visual Studio Code2. Interactive Window3. Get the most of Visual Studio 2017! 4. Don’t do a “Yet another …” 5. Think on DevOps for Bots

Page 52: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Q&A

Page 53: 2017 03 25 Microsoft Hacks, How to code efficiently

@elbruno

Bruno CapuanoInnovation Manager@elbruno

http://www.elbruno.com