1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Object-oriented programming in Python</title>
<meta name="author" content="Simeon Simeonov">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="dist/reset.css">
<link rel="stylesheet" href="dist/reveal.css">
<link rel="stylesheet" href="dist/theme/statnett.css" id="theme">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="plugin/highlight/monokai.css" id="highlight-theme">
<!-- <link rel="stylesheet" href="plugin/highlight/zenburn.css" id="highlight-theme"> -->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h2>Object-oriented programming in Python</h2>
<h4>Data Engineering @ Statnett</h4>
</br>
<p><small>Simeon Simeonov</small></p>
</section>
<section>
<h2>Goals</h2>
</br>
<ul>
<li><p>Present the Python programming language in a different way than <a href="https://docs.python.org">https://docs.python.org</a></p></li>
<li><p>Avoid information overload</p></li>
<li><p>Use examples and interaction rather than documents and slides</p></li>
</ul>
</section>
<section>
<h2>Preliminary plan</h2>
</br>
<ul>
<li><p>Basics: About the language, the Python eco-system, types, modules, functions, scopes, decorators, string formatting</p></li>
<li><p><b>Object-oriented programming in Python: How Python "really works"</b></p></li>
<li><p>Control flow: if / for / while / try, iterators, "tactical programming" tips</p></li>
<li><p>A brief tour through Python's standard library</p></li>
<li><p>Code design and best practices: How to design your code</p></li>
</ul>
</section>
<section>
<h2>What is object-oriented programming?</h2>
</br>
<p>Object-oriented programming does <b>not</b> mean using an object-oriented programming language.</p>
<p>It is rather a programming paradigm based on the concept of <em>object</em>, as well as on some general principles and best practices aiming at:</p>
<ul>
<li><p>improving readability</p></li>
<li><p>improving re-usability</p></li>
<li><p>improving modularity</p></li>
<li><p>providing foundation for a more intuitive design</p></li>
</ul>
</section>
<section>
<h2>General principles</h2>
</br>
<p>The following four concepts / principles are presented in most object-oriented programming books:</p>
<ul>
<li><p>separate and hide "private" details from the outside world and / or child (inheriting) functionality (encapsulation)</p></li>
<li><p>separate the interface from its implementation (abstraction)</p></li>
<li><p>inherit and extend / adapt existing functionality, through "is-a" relationship hierarchy (inheritance)</p></li>
<li><p>execute different code / functionality based on the object's place in the hierarchy (polymorphism)</p></li>
</ul>
</section>
<section>
<h2>Building blocks and definitions</h2>
</br>
<p><b>Note:</b> "Lacking universally accepted terminology to talk about classes, I will make occasional use of Smalltalk and C++ terms." - The Python tutorial (https://docs.python.org)</p>
<p>When talking about object-oriented programming, the following building blocks are involved:</p>
<ul>
<li><p>class - a blueprint / template for creating objects</p></li>
<li><p>object - an instance of a class that may contain its own attributes as well as references to its class' attributes</p></li>
<li><p>attribute - variable, property, function defined in the class and present in its instances</p></li>
<li><p>class variable - attribute of which a single copy exists, regardless of how many instances of the class exist</p></li>
<li><p>object / instance variable - attribute for which each instantiated object of the class has a separate copy, or instance</p></li>
<li><p>method - member function - function that is an attribute</p></li>
</ul>
</section>
<section>
<h2>The object-oriented world of Python</h2>
</br>
<p>Some additional concepts and definitions are introduced in Python, as well as in some other programming languages:</p>
<ul>
<li><p>metaclass - a class whose instances are classes</p></li>
<li><p>property - attribute that provides a flexible mechanism to read, write, or compute the value of a "private" attribute</p></li>
<li><p>type - old C object-oriented term, now (in Python 3) considered to be the same as class</p></li>
</ul>
<p> As is true for modules, classes partake of the dynamic nature of Python: they are created at runtime, and can be modified further after creation.</p>
</section>
<section>
<h2>The object-oriented world of Python (cont...)</h2>
</br>
<p>The < </p>
<ul>
<li><p>metaclass - a class whose instances are classes</p></li>
<li><p>property - attribute that provides a flexible mechanism to read, write, or compute the value of a "private" attribute</p></li>
<li><p>type - old C object-oriented term, now (in Python 3) considered to be the same as class</p></li>
</ul>
</section>
</div>
</div>
<script src="dist/reveal.js"></script>
<script src="plugin/zoom/zoom.js"></script>
<script src="plugin/notes/notes.js"></script>
<script src="plugin/search/search.js"></script>
<script src="plugin/markdown/markdown.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<script>
// Also available as an ES module, see:
// https://revealjs.netlify.app/initialization/
Reveal.initialize({
controls: true,
progress: true,
center: true,
hash: true,
// Learn about plugins: https://revealjs.netlify.app/plugins/
plugins: [ RevealZoom, RevealNotes, RevealSearch, RevealMarkdown, RevealHighlight ]
});
Reveal.configure({ pdfSeparateFragments: false });
</script>
</body>
</html>
|