Presentation is loading. Please wait.

Presentation is loading. Please wait.

TechEd 2013 11/17/2018 6:14 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered.

Similar presentations


Presentation on theme: "TechEd 2013 11/17/2018 6:14 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered."— Presentation transcript:

1 TechEd 2013 11/17/2018 6:14 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

2 Developer Fundamentals: The Series Calgary. NET User Group Feb
SOLID Creating malleable software through design Simon Timms Microsoft MVP – ASP.net

3 Developer Fundamentals Series
Testing – Nov. 26, 2014 SOLID – Feb. 26, 2015 Dependency Injection – June Source Control – Branching/Merging – July Putting It All Together – TBD

4 Simon Timms Senior .NET Dev – Pacesetter Directional Drilling @stimms
TechEd 2013 11/17/2018 6:14 PM Simon Timms Senior .NET Dev – Pacesetter Directional Drilling In IT for over a decade (+/− few months) Microsoft MVP – ASP.NET/IIS Prolific Speaker and Community Involvement PRDC (many), AzureCamp, Local events Calgary .NET User Group – President Author Loves Development Polyglot Web apps, .NET back ends Visualization and Cloud @stimms © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

5 Dave White Principal Consultant – Depth Consulting @AgileRamblings
In IT for over 15 years Microsoft MVP – Visual Studio ALM Kanban/Agile Evangelist, Speaker PRDC 2011, 2012, LKUK, Local events Program Director – KCP Program - LKU Professional Scrum Master Microsoft Platform Developer (C#, Web, WPF) @AgileRamblings

6 WHY?

7 Let’s take a step back What do we offer that off the shelf software doesn’t Why do any of us even have jobs? Why are companies investing in tools?

8 Because every business is different
TechEd 2013 11/17/2018 6:14 PM Because every business is different © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

9 and every business is changing
TechEd 2013 11/17/2018 6:14 PM and every business is changing LG hygiene and cosmetics Vivendi – water company Nintendo – playing card company © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

10 Software needs to change too
TechEd 2013 11/17/2018 6:14 PM Software needs to change too LG hygiene and cosmetics Vivendi – water company Nintendo – playing card company © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

11 Badly Designed Software
Rigid Unable to adapt to changing needs as a change affects other parts of the system Fragile Changes cause unexpected side effects somewhere else in the software Immobile Code cannot be reused in other parts of the system or in other systems

12 Object oriented programming
TechEd 2013 11/17/2018 6:14 PM Object oriented programming Objects offer encapsulated, reusable functionality Couple data (state) with functionality (behaviour) Programming with objects is jolly hard LG hygiene and cosmetics Vivendi – water company Nintendo – playing card company © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

13 SOLID Principles of class design
TechEd 2013 11/17/2018 6:14 PM SOLID Principles of class design Originally enumerated by Uncle Bob Martin LG hygiene and cosmetics Vivendi – water company Nintendo – playing card company © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

14 SOLID Single Responsibility Principle Open Closed Principle
TechEd 2013 11/17/2018 6:14 PM SOLID Single Responsibility Principle Open Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle LG hygiene and cosmetics Vivendi – water company Nintendo – playing card company © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

15 Single Responsibility Principle
Tom DeMarco Structured Analysis and Systems Specification

16 Single Responsibility Principle
A class should have one, and only one, reason to change Classes that expose large number of external methods are likely to have many reasons to change

17 An example t.Win32.Registry/src/Microsoft/Win32/RegistryKey.cs

18 An example we can fix BugTracker.Web/btnet/bug.cs

19 Open – Closed Principle
TechEd 2013 11/17/2018 6:14 PM Open – Closed Principle Bertrand Meyers Robert C. Martin LG hygiene and cosmetics Vivendi – water company Nintendo – playing card company © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

20 Open – Closed Principle
TechEd 2013 11/17/2018 6:14 PM Open – Closed Principle A class should be open for extension and closed for modification When the business changes a new implementation should extend the existing functionality instead of changing it This limits the number of places in which code must change LG hygiene and cosmetics Vivendi – water company Nintendo – playing card company © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

21 Open – Closed Principle
TechEd 2013 11/17/2018 6:14 PM Open – Closed Principle Base classes should be largely abstract and become more well defined further down the stack LG hygiene and cosmetics Vivendi – water company Nintendo – playing card company © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

22 Example Shape TechEd 2013 11/17/2018 6:14 PM
© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

23 Liskov Substitution Barbra Liskov

24 Liskov Substitution Let q(x) be a property provable about objects x of type T. Then q(y) should be provable for objects y of type S, where S is a subtype of T. That is to say that you should be able to replace a class with its sub-class without changing the correctness of the programme

25 An example A square is a special sort of rectangle, right?

26 Can we substitute square for rectangle?
Seems like a square is just a rectangle that has the same width as height public class Rectangle{ public double getArea{…} public void setHeight(double){…} public void setWidth(double){…} }

27 Now we have duplicate methods
setHeight setWidth

28 So set them to maintain structure
public class Square{ private double _width; private double _height; setHeight(double height){ _height = _width = height; } setWidth(double width){ _width = _height = width;

29 But now… [Fact] public void Area_calculates_properly(){
var rectangle = new Square();//substitute rectangle.setHeight(5); rectangle.setWidth(4); rectangle.getWidth().Should().Be.EqualTo(20)//boom }

30 Not as many things are inherited as you might think
So… Not as many things are inherited as you might think

31 Interface Segregation
Robert C. Martin

32 What is it? Clients should not be forced to depend upon interfaces they do not use Avoids coupling between objects that are largely unrelated Improves cohesion

33 Random Number Generator
Example Strategy pattern – random number generation Random Number Generator Time-based RNG External Entropy RNG

34 Random Number Generator
Example Random Number Generator Time-based RNG External Entropy RNG public interface RandomNumberGenerator{ void SetSeed(double); int NextInt(); double NextDouble(); }

35 Example Random Number Generator External Entropy RNG Time-based RNG
public interface RandomNumberGenerator{ void SetSeed(double); int NextInt(); double NextDouble(); } Isn’t used by time-based RNG

36 Random Number Generator
Example Random Number Generator Time-based RNG External Entropy RNG Seedable public interface RandomNumberGenerator{ int NextInt(); double NextDouble(); } public interface Seedable{ void SetSeed(double);

37 Dependency Inversion Robert C. Martin

38 Dependency Inversion High level classes should not depend on concrete implementations of low level classes Changes to implementation should be bounded inside an abstraction

39 Dependency Inversion High level classes should not depend on concrete implementations of low level classes Changes to implementation should be bounded inside an abstraction Frequently related to dependency injection, but doesn’t have to be (factory, service locator, plugin)

40 An example LoginController UserManager Login()

41 An example LoginController UserManager Login() LoginUser()
EncryptedUser Manager

42 An example LoginController IUserManager Login() EncryptedUser Manager

43 Code public class LoginController{ public ActionResult Login(){
var userManager = new UserManager(); userManager.login(); } public class UserManager{ public bool Login(){}

44 Code public class LoginController{
public LoginController(IUserManager userManager) { _userManager = userManager; } public ActionResult Login(){ _userManager.login(); public interface IUserManager{ bool Login();

45 Code public class UserManager:IUserManager{ public bool Login(){} }
public class EncryptedUserManager{

46 Your classes will be… Small Changed infrequently
Implement multiple interfaces Testable

47 Criticism Places a lot of emphasis on extension over composition
Class hierarchies don’t necessarily exist in business situations

48 These are the MeetUps you’re looking for…
Testing – Nov. 26, 2014 SOLID – Feb. 26, 2015 Dependency Injection – June Source Control – Branching/Merging – July Putting It All Together – TBD

49 ReSharper license to the first person to tell me what DRY stands for
NOW PRIZES!! ReSharper license to the first person to tell me what DRY stands for

50 Further reading

51 Further reading Open Closed Principle
19 ½ things to make you a better OO programmer

52 Further reading Uncle Bob’s Article

53 Thanks Dave White @agileramblings Simon Timms @stimms stimms@gmail.com
TechEd 2013 11/17/2018 6:14 PM Thanks Dave White @agileramblings Simon Timms @stimms © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "TechEd 2013 11/17/2018 6:14 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered."

Similar presentations


Ads by Google