Yuri Trukhin - Software developement best practices slide 0

Yuri Trukhin - Software developement best practices

  • Published on
    27-May-2015

  • View
    658

  • Download
    2

Transcript

  • 1.


    senior developer, CNIPGIS LLC
    Microsoft Student Partner Guru

2.



senior developer, CNIPGIS LLC
Microsoft 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)

Rectangle
GeometricRectangle


+draw()
+area() : double
GUI
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
+Store
Persistense System
- -> !
, !
( , , ).
25. -
: . , ,
The American Heritage Dictionary of English language, 2000
26. -
(, , ) .
- .
27. -
, -:
( , ).
( ).
?
28. -
?
!
, .
, .
.
29. -
:
Client
Server
Client .
30. -
:
interface
Client Interface
Client
Server
Client .
31. -
:
policy , Client ( , policy, C# , policy).
, policy, .
Policy
Implementation
+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;
// , // OCP
void DrawAllShapes(ShapePointer list[], int n)
{
int i;
for (i=0; i{
struct Shape* s = list[i];
switch (s->itsType)
{
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 >