Skip to content

Commit b789e6e

Browse files
committed
W5: clean up, mention encapsulation and abstraction
1 parent aec2b01 commit b789e6e

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

week5/w5.ipynb

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"In this lecture we will aim to cover:\n",
18+
"In this lecture we aim to cover:\n",
1919
"- OOP\n",
2020
"- Decorators"
2121
]
@@ -307,7 +307,6 @@
307307
"my_person = Person(\"donald knuth\", 84, \"computer scientist\")\n",
308308
"my_person.introduce()\n",
309309
"\n",
310-
"\n",
311310
"# DO NOT MODIFY\n",
312311
"assert my_person.eat(\"pasta\") == \"donald knuth is eating pasta\", \"Test failed: Something went wrong, expected 'donald knuth is eating pasta'\""
313312
]
@@ -316,7 +315,10 @@
316315
"cell_type": "markdown",
317316
"metadata": {},
318317
"source": [
319-
"We can now represent a person with attributes name, age, and profession. We can introduce a person, and a person can eat."
318+
"We can now represent a person with attributes name, age, and profession. We can introduce a person, and a person can eat.\n",
319+
"This brings us to one of the core principles associated with OOP, **encapsulation**: the object's methods and attributes\n",
320+
"are bundled as a single-unit. We also **abstract** away the implementation details of each method. As a programmer you can invoke `eat`\n",
321+
"or `introduce` without having to worry about what's going on in the background."
320322
]
321323
},
322324
{
@@ -465,8 +467,8 @@
465467
"cell_type": "markdown",
466468
"metadata": {},
467469
"source": [
468-
"### Intermission: Decorators\n",
469-
"Before we continue exploring object-oriented programming, let's have a look at decorators.\n",
470+
"# Decorators\n",
471+
"Finally, let's have a look at decorators.\n",
470472
"\n",
471473
"Congratulations, you've just been hired by the *National X-Soc Co-op Bank Ltd* to develop their ATM system!\n",
472474
"\n",
@@ -600,28 +602,6 @@
600602
"For now, you don't need to worry about the implementation details. The important part is understanding what decorators do: modify the behavior of an existing function."
601603
]
602604
},
603-
{
604-
"cell_type": "markdown",
605-
"metadata": {},
606-
"source": [
607-
"**[INSERT diagram for class vs object]**"
608-
]
609-
},
610-
{
611-
"cell_type": "markdown",
612-
"metadata": {},
613-
"source": [
614-
"TBD:\n",
615-
"- polymorphism/abstraction/encapsulation a little bit\n",
616-
"- then intermission on anotations\n",
617-
"- static and class methods"
618-
]
619-
},
620-
{
621-
"cell_type": "markdown",
622-
"metadata": {},
623-
"source": []
624-
},
625605
{
626606
"cell_type": "markdown",
627607
"metadata": {},

0 commit comments

Comments
 (0)