Yuri Trukhin - Software developement best practices

  • Published on
    27-May-2015

  • View
    658

  • Download
    2

Transcript

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

Recommended

View more >