Yuri Trukhin - Software developement best practices

  • Published on
    27-May-2015

  • View
    658

  • Download
    2

Embed Size (px)

Transcript

<ul><li> 1. <br /><br /><br />senior developer, CNIPGIS LLC<br />Microsoft Student Partner Guru<br /></li></ul> <p> 2. <br /><br /><br /><br />senior developer, CNIPGIS LLC<br />Microsoft Student Partner Guru<br /> 3. <br /> 4. <br />: <br />: <br />: <br />: <br /> : <br /> : <br />: <br /> .<br /> 5. <br /> 6. public partial class Copier<br />{<br />public static void Copy()<br />{<br />int c;<br />while ((c = Keyboard.Read()) != -1)<br />{<br />Printer.Write(c);<br />}<br />}<br />}<br /> 7. public class CopierWithPerfocards<br />{<br />/// <br />/// <br />/// <br />private static boolptFlag = false;<br />public static void Copy()<br />{<br />int c;<br />while ((c = (ptFlag ? PaperTape.Read() : Keyboard.Read())) != -1)<br />Printer.Write(c);<br />} <br />}<br /> 8. public class CopierWithPerfocardsReadAndWrite<br />{<br />// <br />public static boolptFlag = false;<br />public static boolpunchFlag = false;<br />public static void Copy()<br />{<br />int c;<br />while ((c = (ptFlag ? PaperTape.Read() : Keyboard.Read())) != -1)<br />punchFlag ? PaperTape.punchFlag(c) : Printer.Write(c);<br />} <br />}<br /> 9. public interface Reader<br /> {<br /> int Read();<br /> }<br /> public class KeyboardReader : Reader<br /> {<br /> public int Read() { return Keyboard.Read(); };<br /> }<br /> public partial class Copier<br /> {<br /> public static Reader reader = new KeyboardReader();<br /> public static void Copy()<br /> {<br />var c;<br /> while ((c = (reader.Read())) != -1 )<br /> {<br /> Printer.Write(c);<br /> }<br /> }<br /> }<br /> 10. <br /> 11. <br /><br /> /<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> 12. (SRP)<br /><br />. , 1897 <br /> 13. (SRP)<br /> .<br /> . .<br /> , . <br /> .<br /> 14. (SRP)<br /><br />Rectangle<br /><br />+draw()<br />+area() : double<br /><br />GUI<br /> 15. (SRP)<br />:<br /> 16. (SRP)<br />:<br /> Rectangle.<br /> Rectangle, , .<br /><br /> 17. (SRP)<br /><br />Rectangle<br />GeometricRectangle<br /><br /><br />+draw()<br />+area() : double<br />GUI<br /> 18. (SRP)<br /><br /> .<br /> 19. (SRP)<br />:<br />Public interface Modem<br />{<br />public void Dial(string pno);<br />public void Hangup();<br />public void Send (char c);<br />public char Recv(); <br />}<br /> Modem?<br /> 20. (SRP)<br /> ?:<br />Public interface Modem<br />{<br />public void Dial(string pno); // <br />public void Hangup();// <br />public void Send (char c);// <br />public char Recv(); // <br />}<br /> ?<br /> 21. (SRP)<br /> ?:<br />!<br /> , , send receive , .<br /> . DataChannel Connection<br /> 22. (SRP)<br /> ?:<br />!<br /> , , .<br /> . .<br /> 23. (SRP)<br /> ?:<br />!<br /> , , .<br /> . .<br />: , . , .<br /> 24. (SRP)<br /> . .<br />Employee<br />+CalculatePay<br />+Store<br />Persistense System<br /> - -&gt; !<br /> , !<br />( , , ).<br /> 25. -<br /> : . , , <br />The American Heritage Dictionary of English language, 2000<br /> 26. -<br /> (, , ) .<br /> - .<br /> 27. -<br /> , -:<br /> ( , ).<br /> ( ).<br /> ?<br /> 28. -<br /> ?<br /> !<br /> , . <br />, .<br /> . <br /> 29. -<br />:<br />Client<br />Server<br /> Client .<br /> 30. -<br /> :<br />interface<br />Client Interface<br />Client<br />Server<br /> Client .<br /> 31. -<br />: <br /> policy , Client ( , policy, C# , policy).<br />, policy, .<br />Policy<br />Implementation<br />+PolicyFunction()<br />#ServiceFunction()<br />#ServiceFunctiom<br /> 32. -<br /> OCP<br /> 33. -<br />--shape.h--------------------------------------------------------------------<br />enumShareType (circle, square);<br />struct Shape<br />{<br />ShapeTypeitsType;<br />}<br />--circle.h-------------------------------------------------------------------<br />struct Circle<br />{<br />ShapeTypeitsType;<br />double itsRadius;<br />Point itsCenter;<br />};<br />void DrawCircle(struct Circle*);<br />--square.h-------------------------------------------------------------------<br />struct Square<br />{<br />ShapeTypeitsType;<br />double itsSide;<br />Point itsTopLeft;<br />};<br />void DrawSquare(struct Square*);<br /> 34. -<br />--drawAllShapes.cc-----------------------------------------------------------<br />typedefstruct Shape *ShapePointer;<br />// , // OCP<br />void DrawAllShapes(ShapePointer list[], int n)<br />{<br />int i;<br />for (i=0; i{<br />struct Shape* s = list[i];<br />switch (s-&gt;itsType)<br />{<br />case square:<br />DrawSquare((struct Square*)s);<br />break;<br />case circle:<br />DrawCircle((struct Circle*)s);<br />break;<br />}<br />}<br />}<br />///:<br />/// ,<br />/// Triange()<br />/// , <br />///Shape, Square,Circle DrawAllShapes.<br />///<br />/// ,<br />///.. switch/case if/else, .<br />///<br />/// , , <br />/// DrawAllShapes , <br />/// Square Circle, .<br /> 35. -<br />public interface Shape<br />{<br />void Draw();<br />}<br />public class Square : Shape<br />{<br />public void Draw()<br />{<br />// <br />}<br />}<br />public class Circle : Shape<br />{<br />public void Draw()<br />{<br />// <br />}<br />}<br />public void DrawAllShape(IList shapes)<br />{<br />foreach (Shape shape in shapes)<br />shape.Draw();<br />}<br /> 36. -<br />, !<br /> 37. -<br /><br />, .<br /> 38. -<br /> 1<br /> Shape , .<br /> , , .<br /> , !<br /> , .<br />OCP .<br /> 39. -<br /><br /> . . , .<br /><br /> .<br /> , , <br /><br /> , .<br /> 40. -<br /><br /> : , .<br /> , .<br /> 41. <br /><br /> 42. <br /> . .<br /> . .<br /> 43. <br /> , .<br /> 44. <br /> .<br />( , , !)<br /> 45. <br /> . , , .<br /> 46. <br /> . , .<br /> 47. <br /><br /> 48. <br /> ( , )<br /> 49. <br /> , ( ).<br /> 50. ?<br /></p> <ul><li>DI/IOC </li></ul> <p> 51. Prism 52. 53. 54. 55. (codeplex ) 56. ( msdn )</p>