Skip to content

Commit ec05456

Browse files
committed
Merge branch 'issue/7'
2 parents d1de9b7 + 14a8872 commit ec05456

File tree

4 files changed

+155
-106
lines changed

4 files changed

+155
-106
lines changed

notebooks/00-TableOfContents.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
"\n",
1616
"### [Coding Best Practices](CodingBestPractices.ipynb)\n",
1717
"\n",
18-
"### [Object-Oriented Design](ObjectOrientedDesign.ipynb)\n",
19-
"\n",
2018
"### [Python Objects](PythonObjects.ipynb)\n",
2119
"\n",
20+
"### [UML](UML.ipynb)\n",
21+
"\n",
22+
"### [Object-Oriented Design](ObjectOrientedDesign.ipynb)\n",
23+
"\n",
2224
"### [When to Use Object-Oriented Programming](WhenToUseOOP.ipynb)\n",
2325
"\n",
2426
"### [Expecting the Unexpected](ExpectingTheUnexpected.ipynb)\n",

notebooks/ObjectOrientedDesign.ipynb

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -44,70 +44,7 @@
4444
"## Objects and Classes\n",
4545
"- *object* is a collection of data with associated behaviors\n",
4646
"- *class* is a kind or *type* of object\n",
47-
"- Unified Modeling Language (UML) is commonly used to design the classes and their interactions\n",
48-
"\n",
49-
"\n",
50-
"## Unified Modeling Language (UML)\n",
51-
"\n",
52-
"- used while explaining classes and their relationships\n",
53-
"- can help us examine a problem from various angles\n",
54-
" - understand and describe the problem diagrammatically\n",
55-
"- can be used as the document for the design phase\n",
56-
" - can be cumbersome to update UML if you use *agile/iterative* software engineering model instead of *waterfall/cascading* model\n",
57-
"- provides a common language to talk among developers, managers, designers, clients, etc.\n",
58-
" - fairly intuitive to visually understand the big picture of the project\n",
59-
"- this resource provides a good overview of UML - [https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-uml/](https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-uml/)\n",
60-
"- this resource provides a tool to generate UML diagrams: https://plantuml.com/ automatically\n",
61-
" - textbook authors used **plantuml** to generate all the UML diagrams\n",
62-
"\n",
63-
"## 4+1 Views\n",
64-
"\n",
65-
"- we can create a collection of diagrams using UML to help depict and summarize the software we're going to build\n",
66-
"- provides high-level views of the complete architecture of a software product\n",
67-
"- the views are used to describe the system from the viewpoint of different stakeholders, such as end-users, developers, system engineers, and project managers, project owners, etc.\n",
68-
"\n",
69-
"### Logical View\n",
70-
"\n",
71-
"- a logical view of the data entities, their static attributes, and their relationships\n",
72-
"- the heart of object-oriented design\n",
73-
"- concerned with the functionalities the software provides to the end users\n",
74-
"\n",
75-
"### Process View\n",
76-
"\n",
77-
"- describes how the data is processed\n",
78-
"- can be of a variety of forms: state models, activity diagrams, and sequence diagrams\n",
79-
"- addresses concurrency, distribution, integrator, performance, and scalability, etc.\n",
80-
"\n",
81-
"### Development View\n",
82-
"\n",
83-
"- shows relationships among software components\n",
84-
"- can be used to show how class definitions are gathered into modules and packages\n",
85-
"- aka **implementation view** illustrates the programmer's perspective and is concerned with software management\n",
86-
"\n",
87-
"### Physical View\n",
88-
"\n",
89-
"- view of the application to be integrated and deployed\n",
90-
"- if the application follows a well-known common design pattern, a sophisticated physical view diagram isn't necessary\n",
91-
"- otherwise, a diagram is essential to show how a collection of components is integrated and deployed\n",
92-
"- depicts the software from the system engineer's point of view\n",
93-
"\n",
94-
"### Context View\n",
95-
"\n",
96-
"- provides a unifying context for the previous four views\n",
97-
"- often describes the actors that use (or interact) with the system to be built\n",
98-
"- can involve human actors as well as automated interfaces outside the system\n",
99-
"- the system must respond to these external actors\n",
100-
"- can also be called **scenarios or use case view** or system design view (a big picture view)\n",
101-
"\n",
102-
"\n",
103-
"### Example UML diagrams show OOD for Fruit Inventory\n",
104-
"![](resources/UML-class.png)\n",
105-
"- rectangular box represents a class\n",
106-
"- line shows the *association* between two classes\n",
107-
"- the following is a better UML diagram\n",
108-
"- shows the proper relationships\n",
109-
" \n",
110-
"![](resources/UML-relationship.png)"
47+
"- Unified Modeling Language (UML) is commonly used to design the classes and their interactions"
11148
]
11249
},
11350
{

notebooks/PythonObjects.ipynb

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@
13151315
},
13161316
{
13171317
"cell_type": "code",
1318-
"execution_count": null,
1318+
"execution_count": 2,
13191319
"id": "4e8f863a",
13201320
"metadata": {},
13211321
"outputs": [],
@@ -1346,7 +1346,7 @@
13461346
},
13471347
{
13481348
"cell_type": "code",
1349-
"execution_count": 52,
1349+
"execution_count": 3,
13501350
"id": "a764ca44",
13511351
"metadata": {},
13521352
"outputs": [],
@@ -1357,7 +1357,7 @@
13571357
},
13581358
{
13591359
"cell_type": "code",
1360-
"execution_count": 53,
1360+
"execution_count": 4,
13611361
"id": "b9b63da3",
13621362
"metadata": {},
13631363
"outputs": [
@@ -1367,7 +1367,7 @@
13671367
"True"
13681368
]
13691369
},
1370-
"execution_count": 53,
1370+
"execution_count": 4,
13711371
"metadata": {},
13721372
"output_type": "execute_result"
13731373
}
@@ -1378,7 +1378,7 @@
13781378
},
13791379
{
13801380
"cell_type": "code",
1381-
"execution_count": 54,
1381+
"execution_count": 5,
13821382
"id": "b302bf1f",
13831383
"metadata": {},
13841384
"outputs": [
@@ -1398,7 +1398,7 @@
13981398
},
13991399
{
14001400
"cell_type": "code",
1401-
"execution_count": 55,
1401+
"execution_count": 6,
14021402
"id": "ad9b3855",
14031403
"metadata": {},
14041404
"outputs": [
@@ -1408,7 +1408,7 @@
14081408
"True"
14091409
]
14101410
},
1411-
"execution_count": 55,
1411+
"execution_count": 6,
14121412
"metadata": {},
14131413
"output_type": "execute_result"
14141414
}
@@ -1418,41 +1418,27 @@
14181418
]
14191419
},
14201420
{
1421-
"cell_type": "markdown",
1422-
"id": "bb3b269c",
1421+
"cell_type": "code",
1422+
"execution_count": 7,
1423+
"id": "230d3650",
14231424
"metadata": {},
1425+
"outputs": [],
14241426
"source": [
1425-
"## UML Diagrams\n",
1426-
"\n",
1427-
"- use plantuml - https://plantuml.com/\n",
1428-
"- must create description file\n",
1429-
" - see guide for syntax - https://plantuml.com/guide\n",
1430-
" - shows how to create plantuml description files\n",
1431-
"- can use plantuml from local Terminal to generate diagrams or VS Code extension\n",
1432-
"\n",
1433-
"### VS Code Extension\n",
1434-
"\n",
1435-
"- install VS Code extension by jebbs - https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml\n",
1436-
"- allows to preview UML diagrams using local or remote render\n",
1437-
"- install recommended libraries following the extension documentation\n",
1438-
"- configure the extension\n",
1439-
"- on VS Code, create .plantuml file and enter `option+D` (Mac) or `alt+D` (Win)\n",
1440-
"- to save image file:\n",
1441-
" - enter command+P and > PlantUML: Export Current Diagram and pick image type\n",
1442-
" \n",
1443-
"### Local System and Makefile\n",
1444-
"\n",
1445-
"- to render UML images locally, must install **Java** runtime and **Graphviz** library\n",
1446-
"- follow the instruction for your platform here - https://plantuml.com/starting\n",
1447-
"- on a local Terminal type the following command\n",
1448-
"- you must also download plantuml.jar file\n",
1449-
"\n",
1450-
"```bash\n",
1451-
"java -jar <path_to_plantuml.jar> <folder/file.plantuml>\n",
1452-
"```\n",
1453-
"- it automatically creates file.png in the same folder where .plantuml file is\n",
1454-
"\n",
1455-
"- see Makefile for for demo: https://github.com/rambasnet/Kattis-Demos-Testing/tree/main/hello/python3/OOP"
1427+
"def test_singleton():\n",
1428+
" obj1 = MySingletonClass(2, 3)\n",
1429+
" obj2 = MySingletonClass(30, 40)\n",
1430+
" assert obj1 is obj2\n",
1431+
" assert obj1 == obj2"
1432+
]
1433+
},
1434+
{
1435+
"cell_type": "code",
1436+
"execution_count": 8,
1437+
"id": "fdb8bf6c",
1438+
"metadata": {},
1439+
"outputs": [],
1440+
"source": [
1441+
"test_singleton()"
14561442
]
14571443
},
14581444
{

notebooks/UML.ipynb

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## Unified Modeling Language (UML)\n",
8+
"\n",
9+
"- used while explaining classes and their relationships\n",
10+
"- can help us examine a problem from various angles\n",
11+
" - understand and describe the problem diagrammatically\n",
12+
"- can be used as the document for the design phase\n",
13+
" - can be cumbersome to update UML if you use *agile/iterative* software engineering model instead of *waterfall/cascading* model\n",
14+
"- provides a common language to talk among developers, managers, designers, clients, etc.\n",
15+
" - fairly intuitive to visually understand the big picture of the project\n",
16+
"- this resource provides a good overview of UML - [https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-uml/](https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-uml/)\n",
17+
"- this resource provides a tool to generate UML diagrams: https://plantuml.com/ automatically\n",
18+
" - textbook authors used **plantuml** to generate all the UML diagrams\n",
19+
"\n",
20+
"## 4+1 Views\n",
21+
"\n",
22+
"- we can create a collection of diagrams using UML to help depict and summarize the software we're going to build\n",
23+
"- provides high-level views of the complete architecture of a software product\n",
24+
"- the views are used to describe the system from the viewpoint of different stakeholders, such as end-users, developers, system engineers, and project managers, project owners, etc.\n",
25+
"\n",
26+
"### Logical View\n",
27+
"\n",
28+
"- a logical view of the data entities, their static attributes, and their relationships\n",
29+
"- the heart of object-oriented design\n",
30+
"- concerned with the functionalities the software provides to the end users\n",
31+
"\n",
32+
"### Process View\n",
33+
"\n",
34+
"- describes how the data is processed or essentially describes the runtime behavior of the system \n",
35+
"- can be of a variety of forms: state models, activity diagrams, and sequence diagrams\n",
36+
"- addresses concurrency, distribution, integrator, performance, and scalability, etc.\n",
37+
"\n",
38+
"### Development View\n",
39+
"\n",
40+
"- shows relationships among software components\n",
41+
"- can be used to show how class definitions are gathered into modules and packages\n",
42+
"- aka **implementation view** illustrates the programmer's perspective and is concerned with software management\n",
43+
"\n",
44+
"### Physical View\n",
45+
"\n",
46+
"- view of the application to be integrated and deployed\n",
47+
"- if the application follows a well-known common design pattern, a sophisticated physical view diagram isn't necessary\n",
48+
"- otherwise, a diagram is essential to show how a collection of components is integrated and deployed\n",
49+
"- depicts the software from the system engineer's point of view\n",
50+
"\n",
51+
"### Context View\n",
52+
"\n",
53+
"- provides a unifying context for the previous four views\n",
54+
"- often describes the actors that use (or interact) with the system to be built\n",
55+
"- can involve human actors as well as automated interfaces outside the system\n",
56+
"- the system must respond to these external actors\n",
57+
"- can also be called **scenarios or use case view** or system design view (a big picture view)\n",
58+
"\n",
59+
"\n",
60+
"## Example UML diagrams show OOD for Fruit Inventory\n",
61+
"![](resources/UML-class.png)\n",
62+
"- rectangular box represents a class\n",
63+
"- line shows the *association* between two classes\n",
64+
"- the following is a better UML diagram\n",
65+
"- shows the proper relationships\n",
66+
" \n",
67+
"![](resources/UML-relationship.png)\n",
68+
"\n",
69+
"- use plantuml - https://plantuml.com/\n",
70+
"- must create description file\n",
71+
" - see guide for syntax - https://plantuml.com/guide\n",
72+
" - shows how to create plantuml description files\n",
73+
"- can use plantuml from local Terminal to generate diagrams or VS Code extension\n",
74+
"\n",
75+
"### VS Code Extension\n",
76+
"\n",
77+
"- install VS Code extension by jebbs - https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml\n",
78+
"- allows to preview UML diagrams using local or remote render\n",
79+
"- install recommended libraries following the extension documentation\n",
80+
"- configure the extension\n",
81+
" - search for `PlantUML` in Extensions and click on `Settings` menu\n",
82+
" - click `Workspace` tab set PlantUML: Render to `Remote`\n",
83+
" - click `Workspace` tab set PlantUML: Output Format to `png`\n",
84+
" - enter server URL: `http://www.plantuml.com/plantuml/png/` in PlantUML: Server\n",
85+
"- to render UML diagrams:\n",
86+
"- on VS Code, create .plantuml file and enter `option+D` (Mac) or `alt+D` (Win)\n",
87+
"- to save image file:\n",
88+
" - enter command+P and > PlantUML: Export Current Diagram and pick image type\n",
89+
" \n",
90+
"### Local System and Makefile\n",
91+
"\n",
92+
"- to render UML images locally, must install **Java** runtime and **Graphviz** library\n",
93+
"- follow the instruction for your platform here - https://plantuml.com/starting\n",
94+
"- on a local Terminal type the following command\n",
95+
"- you must also download plantuml.jar file\n",
96+
"\n",
97+
"```bash\n",
98+
"java -jar <path_to_plantuml.jar> <folder/file.plantuml>\n",
99+
"```\n",
100+
"- it automatically creates <file_name>.png in the same folder where <file_name>.plantuml file is\n",
101+
"\n",
102+
"- see Makefile for demo: `demo-assignments/A1-OOP/Makefile`\n",
103+
"- to render UML diagrams run the following commands from the Terminal\n",
104+
"\n",
105+
"```bash\n",
106+
"cd demo-assignments/A1-OOP/Makefile\n",
107+
"make create-uml\n",
108+
"```"
109+
]
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"metadata": {},
114+
"source": []
115+
}
116+
],
117+
"metadata": {
118+
"language_info": {
119+
"name": "python"
120+
}
121+
},
122+
"nbformat": 4,
123+
"nbformat_minor": 2
124+
}

0 commit comments

Comments
 (0)