Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Programming course
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
courses
Programming course
Commits
12fac270
Commit
12fac270
authored
7 years ago
by
jkvis
Browse files
Options
Downloads
Patches
Plain Diff
Updated oop lecture: link to classroom and some small textual things
parent
b06c20b5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
oop/oop.pdf
+0
-0
0 additions, 0 deletions
oop/oop.pdf
oop/oop.tex
+20
-10
20 additions, 10 deletions
oop/oop.tex
with
20 additions
and
10 deletions
oop/oop.pdf
+
0
−
0
View file @
12fac270
No preview for this file type
This diff is collapsed.
Click to expand it.
oop/oop.tex
+
20
−
10
View file @
12fac270
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
\begin{minted}
{
python
}
\begin{minted}
{
python
}
vectors
_
x = [0, 1, 2]
vectors
_
x = [0, 1, 2]
vectors
_
y = [0, 1, 1]
vectors
_
y = [0, 1, 1]
>>> (vectors
_
x[2], vectors
_
y[
1
])
>>> (vectors
_
x[2], vectors
_
y[
2
])
(2, 1)
(2, 1)
\end{minted}
\end{minted}
...
@@ -89,7 +89,7 @@ interaction.
...
@@ -89,7 +89,7 @@ interaction.
\item
\mintinline
{
python
}{
42
}
is an instance of type
\item
\mintinline
{
python
}{
42
}
is an instance of type
\mintinline
{
python
}{
int
}
;
\mintinline
{
python
}{
int
}
;
\item
\mintinline
{
python
}{
'Hello World!'
}
is an instance of type
\item
\mintinline
{
python
}{
'Hello World!'
}
is an instance of type
\mintinline
{
python
}{
str
ing
}
.
\mintinline
{
python
}{
str
}
.
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{frame}
\end{frame}
...
@@ -161,15 +161,21 @@ Data and procedures (functions) that ``belong'' to the class:
...
@@ -161,15 +161,21 @@ Data and procedures (functions) that ``belong'' to the class:
\begin{itemize}
\begin{itemize}
\item
\textcolor
{
pms280
_
compl
}{
Data
}
attributes: the objects that make up
\item
\textcolor
{
pms280
_
compl
}{
Data
}
attributes: the objects that make up
the class;
the class:
\begin{itemize}
\item
a 2d vector is made up of two numbers (
\mintinline
{
python
}{
x
}
and
\item
a 2d vector is made up of two numbers (
\mintinline
{
python
}{
x
}
and
\mintinline
{
python
}{
y
}
).
\mintinline
{
python
}{
y
}
).
\item
\textcolor
{
pms280
_
compl
}{
Methods
}
(procedures);
\end{itemize}
\item
\textcolor
{
pms280
_
compl
}{
Methods
}
(procedures):
\begin{itemize}
\item
functions that
\emph
{
only
}
work with this class;
\item
functions that
\emph
{
only
}
work with this class;
\item
how to interact with the object;
\item
how to interact with the object;
\item
e.g., calculate the length of a vector.
\item
e.g., calculate the length of a vector.
\end{itemize}
\end{itemize}
\end{itemize}
\bigskip
\bigskip
\mintinline
{
python
}{
self
}
is the current instance of a class.
\mintinline
{
python
}{
self
}
is the current instance of a class.
...
@@ -198,7 +204,7 @@ instance;
...
@@ -198,7 +204,7 @@ instance;
\end{itemize}
\end{itemize}
\end{frame}
\end{frame}
\begin{frame}
[fragile]
{
Hiding information --- separation of concern
}
\begin{frame}
[fragile]
{
Hiding information --- separation of concern
s
}
\begin{itemize}
\begin{itemize}
\item
Sometimes we would like to
\textcolor
{
pms280
_
compl
}{
hide
}
\item
Sometimes we would like to
\textcolor
{
pms280
_
compl
}{
hide
}
attributes to the outside world, i.e., only usable inside the class.
attributes to the outside world, i.e., only usable inside the class.
...
@@ -210,13 +216,13 @@ class Vector(object):
...
@@ -210,13 +216,13 @@ class Vector(object):
def
__
init
__
(self, x=0, y=0):
def
__
init
__
(self, x=0, y=0):
self.x = x
self.x = x
self.y = y
self.y = y
self.
_
secret = 42
self.
_
secret = 42
# this is allowed
\end{minted}
\end{minted}
\item
we agree not to access this attribute directly:
\item
we agree not to access this attribute directly:
\begin{minted}
{
python
}
\begin{minted}
{
python
}
>>> v1 = Vector(1, 2)
>>> v1 = Vector(1, 2)
>>> print v1.
_
secret # this is forbidden
>>> print v1.
_
secret
# this is forbidden
\end{minted}
\end{minted}
\end{itemize}
\end{itemize}
...
@@ -290,8 +296,11 @@ class Vector(object):
...
@@ -290,8 +296,11 @@ class Vector(object):
\begin{minted}
{
python
}
\begin{minted}
{
python
}
>>> v1 = Vector(4, 3)
>>> v1 = Vector(4, 3)
>>> print type(v1)
>>> print type(v1)
<class '
__
main
__
.Vector'>
\end{minted}
\end{minted}
%% start minted fix
\vspace
{
-.08cm
}
\mintinline
{
python
}{
<class
}
\mintinline
{
python
}{
'
__
main
__
.Vector'>
}
%% end minted fix
\item
that also works for the class:
\item
that also works for the class:
\begin{minted}
{
python
}
\begin{minted}
{
python
}
...
@@ -396,7 +405,7 @@ containing two integers: \mintinline{python}{numerator} and
...
@@ -396,7 +405,7 @@ containing two integers: \mintinline{python}{numerator} and
\mintinline
{
python
}{
denominator
}
.
\mintinline
{
python
}{
denominator
}
.
\begin{itemize}
\begin{itemize}
\item
add, subtract;
\item
add, subtract
, e.g.,
$
\frac
{
1
}{
2
}
+
\frac
{
2
}{
3
}
=
\frac
{
7
}{
6
}$
;
\item
print representation, convert to
\mintinline
{
python
}{
float
}
;
\item
print representation, convert to
\mintinline
{
python
}{
float
}
;
\item
invert a fraction;
\item
invert a fraction;
\item
$
\ldots
$
\item
$
\ldots
$
...
@@ -404,7 +413,8 @@ containing two integers: \mintinline{python}{numerator} and
...
@@ -404,7 +413,8 @@ containing two integers: \mintinline{python}{numerator} and
\bigskip
\bigskip
see:
\path
{
https://github.com/lumc-python/oop
}
see:
\path
{
https://github.com/lumc-python/oop
}
\\
or go directly to:
\textcolor
{
pms280
_
compl
}{
\path
{
https://classroom.github.com/a/8BnbL9fD
}}
\end{frame}
\end{frame}
\end{document}
\end{document}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment