Billy Gao
                               gaoxiang@5173.com




*All rights reserved by 5173
                              ...
1.


                2.


                3.




*All rights reserved by 5173
                               2
1.


                2.

                3.

                          1)

                          2)



*All rights res...
*All rights reserved by 5173
                               4
…




*All rights reserved by 5173
                                   5
…

                1.


                2.

                          1)

                          2)

                  ...
…




*All rights reserved by 5173
                                   7
…




*All rights reserved by 5173
                                   7
…




*All rights reserved by 5173
                                   7
…




                               “       ”



*All rights reserved by 5173
                                           7
*All rights reserved by 5173
                               8
*All rights reserved by 5173
                               8
*All rights reserved by 5173
                               8
…




*All rights reserved by 5173
                                   9
…




*All rights reserved by 5173
                                   9
…




*All rights reserved by 5173
                                   9
…




*All rights reserved by 5173
                                   9
*All rights reserved by 5173
                               10
Polymorphism



                                              ——




*All rights reserved by 5173
                        ...
Polymorphism



                                                    ——




                      a.              overload
...
*All rights reserved by 5173
                               11
public abstract class Animal
                     {
                       public abstract string Bark();
                ...
public abstract class Animal       public interface IBarkable
                     {                                  {
  ...
*All rights reserved by 5173
                               12
is a




*All rights reserved by 5173
                                      12
is a



                                is an animal.




*All rights reserved by 5173
                                   ...
is a



                                is an animal.




*All rights reserved by 5173
                                   ...
is a



                                is an animal.




                                can bark.




*All rights reserv...
is a



                                is an animal.




                                can bark.


                    ...
•
                      •
                      •
                      •




*All rights reserved by 5173
               ...
•
                      •
                      •
                      •


                          public class Cargo
 ...
•
                      •
                      •
                      •


                          public class Cargo  ...
*All rights reserved by 5173
                               14
…




                                   2000 300.




*All rights reserved by 5173
                                      ...
*All rights reserved by 5173
                               16
public class Cargo
                         {
                           public string Id { get; set; }
                  ...
public class Cargo
                         {
                           public string Id { get; set; }
                  ...
…




*All rights reserved by 5173
                                   17
…


                                    PaymentService
                                   Cargo




*All rights reserved b...
…


                                    PaymentService
                                   Cargo




                      ...
…




*All rights reserved by 5173
                                   18
…

                               Cargo




*All rights reserved by 5173
                                       18
…

                                                  Cargo

                               public interface IChargable
   ...
…

                                                    Cargo

                               public interface IChargable
 ...
…




*All rights reserved by 5173
                                   19
…

                               Cargo




*All rights reserved by 5173
                                       19
…

                                      Cargo

                               public class Book : Cargo
                 ...
…

                                      Cargo

                               public class Book : Cargo
                 ...
…

                                      Cargo

                               public class Book : Cargo
                 ...
•
                      •
                      •

                      •




*All rights reserved by 5173
              ...
•
                      •
                      •

                      •




*All rights reserved by 5173
              ...
User.Sit(Chair	
  chair)	
  
                               Chair.Sit(User	
  user)	
  




*All rights reserved by 5173
 ...
User.Sit(Chair	
  chair)	
  
                               Chair.Sit(User	
  user)	
  




*All rights reserved by 5173
 ...
OOAD




*All rights reserved by 5173
                               22
OOAD




*All rights reserved by 5173
                               22
OOAD




*All rights reserved by 5173
                               22
OOAD




*All rights reserved by 5173
                               22
*All rights reserved by 5173
                               23
*All rights reserved by 5173
                               23
*All rights reserved by 5173
                               24
*All rights reserved by 5173
                               24
*All rights reserved by 5173
                               24
…




*All rights reserved by 5173
                               25
…



                               24*7




*All rights reserved by 5173
                                      25
1.


                2.


                3.




*All rights reserved by 5173
                               26
…




*All rights reserved by 5173
                                   27
…


                               Y




                                   X



                           Z




*All rig...
…


                               Y




                                   X



                           Z




*All rig...
…


                               Y




                                   X



                           Z




*All rig...
*All rights reserved by 5173
                               28
*All rights reserved by 5173
                               28
*All rights reserved by 5173
                               28
Hibernate




*All rights reserved by 5173
                                           28
*All rights reserved by 5173
                               29
*All rights reserved by 5173
                               29
*All rights reserved by 5173
                               29
*All rights reserved by 5173
                               29
*All rights reserved by 5173
                               29
*All rights reserved by 5173
                               30
*All rights reserved by 5173
                               30
*All rights reserved by 5173
                               30
*All rights reserved by 5173
                               30
Time




*All rights reserved by 5173
                                      31
cargo.Pay();




                                              Time




*All rights reserved by 5173
                     ...
cargo.Pay();




                               Paying

                                                       Time




*A...
cargo.Pay();




                               Paying                  Paid
                                             ...
cargo.Pay();




                               Paying                  Paid
                                             ...
I.
                               C#




                   II. C#


                   III.




*All rights reserved by 5...
I.
                               C#




                   II. C#


                   III.




*All rights reserved by 5...
I.
                               C#




                   II. C#


                   III.




*All rights reserved by 5...
IV.




*All rights reserved by 5173
                               33
IV.




*All rights reserved by 5173
                               33
IV.




*All rights reserved by 5173
                               33
IV.




*All rights reserved by 5173
                               33
IV.




                           Design Patterns Explained




*All rights reserved by 5173
                            ...
*All rights reserved by 5173
                               34
•




*All rights reserved by 5173
                               34
•

                      




*All rights reserved by 5173
                               34
•

                      




                      •




*All rights reserved by 5173
                               34
•

                      




                      •

                      




*All rights reserved by 5173
         ...
1.


                2.


                3.




*All rights reserved by 5173
                               35
“            ”




*All rights reserved by 5173
                                   36
“            ”




*All rights reserved by 5173
                                   36
*All rights reserved by 5173
                               37
*All rights reserved by 5173
                               37
…




*All rights reserved by 5173
                                   37
…




                                   …




*All rights reserved by 5173
                                       37
…




                                   …




*All rights reserved by 5173
                                       37
Level0   Level1   Level2   Level3   …


*All rights reserved by 5173
                                                     ...
…




*All rights reserved by 5173
                                   39
…




*All rights reserved by 5173
                                   39
…




                                   …




*All rights reserved by 5173
                                       39
…




                                   …




*All rights reserved by 5173
                                       39
*All rights reserved by 5173
                               40
a1 = F(a0);

                     an+1 = F’(an) (n > 0);




*All rights reserved by 5173
                                ...
a1 = F(a0);

                     an+1 = F’(an) (n > 0);



                     a1 = F(a0);




*All rights reserved by 5...
a1 = F(a0);

                     an+1 = F’(an) (n > 0);



                     a1 = F(a0);


                     an+1 =...
*All rights reserved by 5173
                               41
Level 0




*All rights reserved by 5173
                                         41
Level 0


                               Level 1




*All rights reserved by 5173
                                        ...
Level 0


                               Level 1




                               Level 2




*All rights reserved by 51...
Level 0


                                        Level 1




                                        Level 2




        ...
Level 0


                                         Level 1




                                         Level 2




      ...
Level 0


                                                              Level 1




                                      ...
Level 0


                                                              Level 1




                                      ...
Level 0


                                                              Level 1




                                      ...
Level 0


                                                              Level 1




                                      ...
Level 0


                                                              Level 1




                                      ...
Level 0


                                                                         Level 1




                           ...
*All rights reserved by 5173
                               42
Upcoming SlideShare
Loading in...5
×

面向对象与生活

1,788

Published on

Published in: Technology
1 Comment
6 Likes
Statistics
Notes
  • 还不错
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
1,788
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
98
Comments
1
Likes
6
Embeds 0
No embeds

No notes for slide

面向对象与生活

  1. 1. Billy Gao gaoxiang@5173.com *All rights reserved by 5173 1
  2. 2. 1. 2. 3. *All rights reserved by 5173 2
  3. 3. 1. 2. 3. 1) 2) *All rights reserved by 5173 3
  4. 4. *All rights reserved by 5173 4
  5. 5. … *All rights reserved by 5173 5
  6. 6. … 1. 2. 1) 2) 3) *All rights reserved by 5173 6
  7. 7. … *All rights reserved by 5173 7
  8. 8. … *All rights reserved by 5173 7
  9. 9. … *All rights reserved by 5173 7
  10. 10. … “ ” *All rights reserved by 5173 7
  11. 11. *All rights reserved by 5173 8
  12. 12. *All rights reserved by 5173 8
  13. 13. *All rights reserved by 5173 8
  14. 14. … *All rights reserved by 5173 9
  15. 15. … *All rights reserved by 5173 9
  16. 16. … *All rights reserved by 5173 9
  17. 17. … *All rights reserved by 5173 9
  18. 18. *All rights reserved by 5173 10
  19. 19. Polymorphism —— *All rights reserved by 5173 10
  20. 20. Polymorphism —— a. overload b. override override *All rights reserved by 5173 10
  21. 21. *All rights reserved by 5173 11
  22. 22. public abstract class Animal { public abstract string Bark(); } public class Cat : Animal { public override string Bark() { return “ ”} } public class Dog : Animal { public override string Bark() { return “ ”} } *All rights reserved by 5173 11
  23. 23. public abstract class Animal public interface IBarkable { { public abstract string Bark(); string Bark(); } } public class Cat : Animal public class Cat : IBarkable { { public override string Bark() public string Bark() { return “ ”} { return “ ”} } } public class Dog : Animal public class Dog : IBarkable { { public override string Bark() public string Bark() { return “ ”} { return “ ”} } } *All rights reserved by 5173 11
  24. 24. *All rights reserved by 5173 12
  25. 25. is a *All rights reserved by 5173 12
  26. 26. is a is an animal. *All rights reserved by 5173 12
  27. 27. is a is an animal. *All rights reserved by 5173 12
  28. 28. is a is an animal. can bark. *All rights reserved by 5173 12
  29. 29. is a is an animal. can bark. “ ” *All rights reserved by 5173 12
  30. 30. • • • • *All rights reserved by 5173 13
  31. 31. • • • • public class Cargo { public string Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } } *All rights reserved by 5173 13
  32. 32. • • • • public class Cargo public class PaymentService { { public string Id { get; set; } public void Pay(Cargo cargo) public string Name { get; set; } { public decimal Price { get; set; } // } } } *All rights reserved by 5173 13
  33. 33. *All rights reserved by 5173 14
  34. 34. … 2000 300. *All rights reserved by 5173 15
  35. 35. *All rights reserved by 5173 16
  36. 36. public class Cargo { public string Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } public enum CargoType { get; set; } // public double Discount { get; set; } // } *All rights reserved by 5173 16
  37. 37. public class Cargo { public string Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } public enum CargoType { get; set; } // public double Discount { get; set; } // } public class PaymentService { public void Pay(Cargo cargo) { // CargoType Discount } } *All rights reserved by 5173 16
  38. 38. … *All rights reserved by 5173 17
  39. 39. … PaymentService Cargo *All rights reserved by 5173 17
  40. 40. … PaymentService Cargo Cargo *All rights reserved by 5173 17
  41. 41. … *All rights reserved by 5173 18
  42. 42. … Cargo *All rights reserved by 5173 18
  43. 43. … Cargo public interface IChargable { void Pay(); } *All rights reserved by 5173 18
  44. 44. … Cargo public interface IChargable { void Pay(); } public abstract class Cargo : IChargable { public string Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } public enum CargoType { get; set; } public double Discount { get; set; } public abstract void Pay(); } *All rights reserved by 5173 18
  45. 45. … *All rights reserved by 5173 19
  46. 46. … Cargo *All rights reserved by 5173 19
  47. 47. … Cargo public class Book : Cargo { public override void Pay() { // 8 } } *All rights reserved by 5173 19
  48. 48. … Cargo public class Book : Cargo { public override void Pay() { // 8 } } public class ElecEquip : Cargo { public override void Pay() { // 2000 300 } } *All rights reserved by 5173 19
  49. 49. … Cargo public class Book : Cargo { public override void Pay() { // 8 } } public class ElecEquip : Cargo { public override void Pay() { // 2000 300 } } *All rights reserved by 5173 19
  50. 50. • • • • *All rights reserved by 5173 20
  51. 51. • • • • *All rights reserved by 5173 20
  52. 52. User.Sit(Chair  chair)   Chair.Sit(User  user)   *All rights reserved by 5173 21
  53. 53. User.Sit(Chair  chair)   Chair.Sit(User  user)   *All rights reserved by 5173 21
  54. 54. OOAD *All rights reserved by 5173 22
  55. 55. OOAD *All rights reserved by 5173 22
  56. 56. OOAD *All rights reserved by 5173 22
  57. 57. OOAD *All rights reserved by 5173 22
  58. 58. *All rights reserved by 5173 23
  59. 59. *All rights reserved by 5173 23
  60. 60. *All rights reserved by 5173 24
  61. 61. *All rights reserved by 5173 24
  62. 62. *All rights reserved by 5173 24
  63. 63. … *All rights reserved by 5173 25
  64. 64. … 24*7 *All rights reserved by 5173 25
  65. 65. 1. 2. 3. *All rights reserved by 5173 26
  66. 66. … *All rights reserved by 5173 27
  67. 67. … Y X Z *All rights reserved by 5173 27
  68. 68. … Y X Z *All rights reserved by 5173 27
  69. 69. … Y X Z *All rights reserved by 5173 27
  70. 70. *All rights reserved by 5173 28
  71. 71. *All rights reserved by 5173 28
  72. 72. *All rights reserved by 5173 28
  73. 73. Hibernate *All rights reserved by 5173 28
  74. 74. *All rights reserved by 5173 29
  75. 75. *All rights reserved by 5173 29
  76. 76. *All rights reserved by 5173 29
  77. 77. *All rights reserved by 5173 29
  78. 78. *All rights reserved by 5173 29
  79. 79. *All rights reserved by 5173 30
  80. 80. *All rights reserved by 5173 30
  81. 81. *All rights reserved by 5173 30
  82. 82. *All rights reserved by 5173 30
  83. 83. Time *All rights reserved by 5173 31
  84. 84. cargo.Pay(); Time *All rights reserved by 5173 31
  85. 85. cargo.Pay(); Paying Time *All rights reserved by 5173 31
  86. 86. cargo.Pay(); Paying Paid Time *All rights reserved by 5173 31
  87. 87. cargo.Pay(); Paying Paid Time *All rights reserved by 5173 31
  88. 88. I. C# II. C# III. *All rights reserved by 5173 32
  89. 89. I. C# II. C# III. *All rights reserved by 5173 32
  90. 90. I. C# II. C# III. *All rights reserved by 5173 32
  91. 91. IV. *All rights reserved by 5173 33
  92. 92. IV. *All rights reserved by 5173 33
  93. 93. IV. *All rights reserved by 5173 33
  94. 94. IV. *All rights reserved by 5173 33
  95. 95. IV. Design Patterns Explained *All rights reserved by 5173 33
  96. 96. *All rights reserved by 5173 34
  97. 97. • *All rights reserved by 5173 34
  98. 98. •  *All rights reserved by 5173 34
  99. 99. •  • *All rights reserved by 5173 34
  100. 100. •  •  *All rights reserved by 5173 34
  101. 101. 1. 2. 3. *All rights reserved by 5173 35
  102. 102. “ ” *All rights reserved by 5173 36
  103. 103. “ ” *All rights reserved by 5173 36
  104. 104. *All rights reserved by 5173 37
  105. 105. *All rights reserved by 5173 37
  106. 106. … *All rights reserved by 5173 37
  107. 107. … … *All rights reserved by 5173 37
  108. 108. … … *All rights reserved by 5173 37
  109. 109. Level0 Level1 Level2 Level3 … *All rights reserved by 5173 38
  110. 110. … *All rights reserved by 5173 39
  111. 111. … *All rights reserved by 5173 39
  112. 112. … … *All rights reserved by 5173 39
  113. 113. … … *All rights reserved by 5173 39
  114. 114. *All rights reserved by 5173 40
  115. 115. a1 = F(a0); an+1 = F’(an) (n > 0); *All rights reserved by 5173 40
  116. 116. a1 = F(a0); an+1 = F’(an) (n > 0); a1 = F(a0); *All rights reserved by 5173 40
  117. 117. a1 = F(a0); an+1 = F’(an) (n > 0); a1 = F(a0); an+1 = F’(an) (n > 0); *All rights reserved by 5173 40
  118. 118. *All rights reserved by 5173 41
  119. 119. Level 0 *All rights reserved by 5173 41
  120. 120. Level 0 Level 1 *All rights reserved by 5173 41
  121. 121. Level 0 Level 1 Level 2 *All rights reserved by 5173 41
  122. 122. Level 0 Level 1 Level 2 Object Level N *All rights reserved by 5173 41
  123. 123. Level 0 Level 1 Level 2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  124. 124. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  125. 125. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  126. 126. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  127. 127. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  128. 128. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  129. 129. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 OOP a1 Object Level N *All rights reserved by 5173 41
  130. 130. *All rights reserved by 5173 42
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×