Presentation is loading. Please wait.

Presentation is loading. Please wait.

WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.

Similar presentations


Presentation on theme: "WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010."— Presentation transcript:

1 WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010. They may not show up well on other PowerPoint versions. You can download PowerPoint 2010 viewer from here.here These slides contain a lot of animations. For optimal results, watch in slideshow mode.

2 bar() Main foo()

3 bar() Main foo()

4

5

6

7

8

9

10

11

12 Data, functions

13

14

15

16 How to structure?

17 ……………….. 1. …………………2. ……………….. ……………………… 1234 3. …………..4. …………….. How to structure? ………………………. ……………. …………………………..

18 1234 How to structure?

19

20

21

22 ???? 110010 101001 101110 101010 101010 101010 ???? 110010 101001 101110 101010 101010 101010 ???? MOV AL, 1h MOV CL, 2h MOV DL, 3h ???? MOV AL, 1h MOV CL, 2h MOV DL, 3h ??? int i i=5 ??? int i i=5

23 BINARY 110010 101001 101110 101010 101010 101010 BINARY 110010 101001 101110 101010 101010 101010 ASSEMBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h ASSEMBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h High-Level Languages int i i=5 High-Level Languages int i i=5

24 BINARY 110010 101001 101110 101010 101010 101010 BINARY 110010 101001 101110 101010 101010 101010 ASSEMBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h ASSEMBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h High-Level Languages int i i=5 High-Level Languages int i i=5 [Styles of structuring a solution]

25 BINARY 110010 101001 101110 101010 101010 101010 BINARY 110010 101001 101110 101010 101010 101010 ASSEBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h ASSEBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h High-Level Languages int i i=5 High-Level Languages int i i=5 PROCEDURAL function1 function 2 --------------- array list PROCEDURAL function1 function 2 --------------- array list

26 BINARY 110010 101001 101110 101010 101010 101010 BINARY 110010 101001 101110 101010 101010 101010 ASSEBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h ASSEBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h High-Level Languages int i i=5 High-Level Languages int i i=5 PROCEDURAL function1 function 2 --------------- array list PROCEDURAL function1 function 2 --------------- array list OBJECT- ORIENTED Other paradigms OBJECT- ORIENTED

27

28

29 1234 How to structure? Follow a paradigm Object Oriented Programming OOP

30 Designing component internals using Object-Oriented Programming

31 BINARY 110010 101001 101110 101010 101010 101010 BINARY 110010 101001 101110 101010 101010 101010 ASSEBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h ASSEBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h High-Level Languages int i i=5 High-Level Languages int i i=5 PROCEDURAL function1 function 2 --------------- array list PROCEDURAL function1 function 2 --------------- array list OBJECT- ORIENTED Other paradigms OBJECT- ORIENTED

32 BINARY 110010 101001 101110 101010 101010 101010 BINARY 110010 101001 101110 101010 101010 101010 ASSEBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h ASSEBLY MOV AL, 1h MOV CL, 2h MOV DL, 3h High-Level Languages int i i=5 High-Level Languages int i i=5 PROCEDURAL function1 function 2 --------------- array list PROCEDURAL function1 function 2 --------------- array list OBJECT- ORIENTED Other paradigms OBJECT- ORIENTED

33 Let’s follow real world

34 World = a network of objects collaborating by way of message + response OBJECT- ORIENTED Let’s follow real world

35 OBJECT- ORIENTED Object [ Data + related functions] Structure solution as collaborating objects.  intuitive OBJECT- ORIENTED Let’s follow real world  efficient?

36 OBJECT- ORIENTED Object [ Data + related functions] Structure solution as collaborating objects.

37

38

39 1234 How to structure? Follow a paradigm OOP Collaborating objects

40 1 23 4

41 1 23 4

42 OBJECT- ORIENTED Object [ Data + related functions] Structure solution as collaborating objects.

43 OBJECT- ORIENTED Object [ Data + related functions] Structure solution as collaborating objects.

44 OBJECT- ORIENTED Object [ Data + related functions]

45 OBJECT- ORIENTED Object [ Data + related functions]

46

47 More details Less details Object Data function Data X X

48 Object [ Data + related functions] An object closely-related behavior and data is an of Object Data function Data X X

49 Object [ Data + related functions] An object closely-related behavior and data is an of Object Data function Data X X

50 Object [ Data + related functions] An object closely-related behavior and data is an of Object Data function Data X X

51 Object Data function

52

53

54 1234 How to structure? Follow a paradigm OOP Collaborating objects 1. Abstraction2. ………………….3. …………..4. ……………..

55

56 data1 data2 data1 data2 function3 f2 function1 Object [ Data + related functions]

57 data1 data2 data1 data2 function3 f2 function1

58 data1 data2 data1 data2 function3 f2 function1

59 data1 data2 data1 data2 function3 f2 function1

60 data1 data2 data1 data2 function3 f2 function1 Interface/implementation separation

61 data1 data2 data1 data2 function3 f2 function1

62 An object closely -related behavior and data data1 data2 data1 data2 function3 f2 function1

63

64

65 1234 How to structure? Follow a paradigm OOP Collaborating objects 1. Abstraction3. …………..4. ……………..2. Encapsulation

66

67

68 data1 data2 data1 data2 function3 f2 function1

69 OO program at runtime… data1 data2 data1 data2 function3 f2 function1 data1 data2 data1 data2 function3 f2 function1 data1 data2 data1 data2 function3 f2 function1

70 data1 data2 data1 data2 function3 f2 function1 data1 data2 data1 data2 function3 f2 function1 data1 data2 data1 data2 function3 f2 function1 ProceduralOO function1 function2 -------------------- array list function1 function2 -------------------- array list

71 ProceduralOO Problem: Calculate the average age of students in a class. Assume DoB of each student is known.

72 Procedural Problem: Calculate the average age of students in a class. Assume DoB of each student is known. Functions Data

73 Procedural Functions Data Problem: Calculate the average age of students in a class. Assume DoB of each student is known.

74 OO

75

76

77 Data = DOB Behavior = getAge() Behavior = calculateAvgAge() Data = students

78 OO Data = DOB Behavior = getAge() Behavior = calculateAvgAge() Data = students

79

80

81 At runtime [10100010…]

82 Student -DOB -Name +getAge() +getName()

83 Student -DOB -Name +getAge() +getName()

84 Student -DOB -Name +getAge() +getName()

85 Student -DOB -Name +getAge() +getName()

86 Student -DOB -Name +getAge() +getName() A blueprint for creating objects.

87 Admin -students +calculateAvgAge() Student -DOB -Name +getAge() +getName()

88

89

90 1234 How to structure? Follow a paradigm OOP Collaborating objects 1. Abstraction3. …………..4. ……………..2. Encapsulation Blueprints for objects

91 ProceduralOO Functions Data Student -DOB -Name +getAge() +getName() Admin -students +calculateAvgAge()

92 ProceduralOO Functions Data Student -DOB -Name +getAge() +getName() Admin -students +calculateAvgAge()

93 UILogicStorage

94 UI Logic Storage Example: CityConnect Logic API: addRoute(String city1, String city2, int distance): String getDistance(String city1, String city2): String

95 Example: CityConnect Logic API: addRoute(String city1, String city2, int distance): String getDistance(String city1, String city2): String ? ? ? ? ? ? ? ? ? ?

96 Object behavior Object structureClass structure API: addRoute(String city1, String city2, int distance): String getDistance(String city1, String city2): String ? ? ? ? ? ? ? ? ? ?

97 Object behavior Object structureClass structure

98 Object behavior Object structureClass structure Logic UI Logic UI

99 Object behavior Object structureClass structure Logic UI Logic UI

100 Object behavior Object structureClass structure

101 Object behavior Object structureClass structure

102 Object behavior Object structureClass structure

103 Object behavior Object structureClass structure Object diagramClass diagram

104 Object behavior Object structureClass structure Object diagramClass diagram

105 Object behavior

106

107 object creation

108

109

110 Object behavior Object diagramClass diagram

111

112 CCLogic -routes:Route[] +addRoute(…) +getDistance(…) Route Class diagram

113 CCLogic -routes:Route[] +addRoute(…) +getDistance(…) Route Class diagram

114 CCLogic +addRoute(…) +getDistance(…) Route Class diagram

115 CCLogic +addRoute(…) +getDistance(…) Route Class diagram

116 CCLogic +addRoute(…) +getDistance(…) Route Class diagram

117 CCLogic +addRoute(…) +getDistance(…) Route Class diagram

118 CCLogic +addRoute(…) +getDistance(…) Route Class diagram

119 CCLogic +addRoute(…) +getDistance(…) Route Class diagram

120 CCLogic +addRoute(…) +getDistance(…) Route Class diagram

121 CCLogic +addRoute(…) +getDistance(…) Route

122 Object diagram

123

124 Object behavior

125

126

127 Object diagram

128 Class diagram CCLogic +addRoute(…) +getDistance(…) Route City -name

129 Class diagram CCLogic +addRoute(…) +getDistance(…) Route City -name

130 Class diagram CCLogic +addRoute(…) +getDistance(…) Route City -name

131 Class diagram

132

133 Sequence diagrams Object diagram(s)Class diagram

134 Sequence diagrams Object diagram(s)Class diagram

135 1234 How to structure? Follow a paradigm OOP Collaborating objects 1. Abstraction3. …………..4. ……………..2. Encapsulation Blueprints for objects Object rules Object structure Object behavior Apply OOP in CE2, Project

136 CCLogic +addRoute(…) +getDistance(…) Route City -name What is the multiplicity here? (a) 1 (b) 0..1 (c) 1..* (d) * start {a|b|c|d} e.g. start c 77577 OR tinyurl.com/answerpost feed2103 blah…

137


Download ppt "WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010."

Similar presentations


Ads by Google