You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2a9c5c5
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: source/exercises/oo_intro/oo_intro.rst
+20-10Lines changed: 20 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
.. _oo_intro:
2
2
3
-
########################
3
+
#######################
4
4
OO Intro - Report Class
5
-
########################
5
+
#######################
6
6
7
7
This assignment uses Object Oriented Programming to design a class that can be used to manage data reporting.
8
8
@@ -14,18 +14,28 @@ We will explore here how one can utilize OO to improve and enhance reporting cap
14
14
Procedure
15
15
=========
16
16
17
-
You will use :download:`report.py` and :download:`test_report.py` file as a starting point for your code.
17
+
Use the :download:`report.py` and :download:`test_report.py` files as a starting point for your code.
18
18
19
-
You will notice that ``Report`` class will have attributes and methods defined for you, including input parameters (and their types) as well as expected output.
20
-
You will need to fill out the code for each defined method and docstrings containing additional information on what is expected.
19
+
Notice that the ``Report`` class has attributes and methods defined for you, including input parameters as well as expected output.
20
+
21
+
You will need to fill out the code and docstrings for each defined method containing additional information on what is expected.
22
+
23
+
There is also some example code in the ``__main__`` block, to see how it's used.
24
+
25
+
Use TDD: write a test for each method before you add that functionality. There is a test file started for you -- it has one (failing) test for one of the methods.
26
+
27
+
The Row class
28
+
-------------
29
+
30
+
The ``Report`` class uses another class, ``Row``, that is fully defined (and tested) for you. This class represents a single row in your report, and the report class will hold a list of the row instances.
31
+
32
+
There are big advantages to using a class like ``Row`` rather than a simple dictionary. This design creates a clear contract about what is part of a row, whereas with a dictionary you can put anything in it, so it is harder to catch when a key is misspelled or missing.
21
33
22
-
The ``Report`` class uses another class that is fully defined for you,
23
-
the ``Row`` class. This class represents a single row in your report, and the report class will hold a list of the row instances.
24
-
There are big advantages to using a class like ``Row`` in contrast to a simple dictionary, this design creates a clear contract on what's expected to be as part of a row, where with a dictionary it is easy to misspell or miss a key.
25
34
A class like ``Row`` is often called a "data class" (since it only holds "data" and doesn't actually have any logic to it).
26
35
27
-
This is such a popular pattern that python introduced ``dataclasses`` in
28
-
`version 3.7 <https://www.python.org/dev/peps/pep-0557>`_ to make this even simpler. You do not use them in this assignment but you should know that they exist and why.
36
+
This is such a popular pattern that Python introduced ``dataclasses`` in
37
+
`version 3.7 <https://www.python.org/dev/peps/pep-0557>`_ to make this even simpler.
38
+
You do not use them in this assignment but you should know that they exist and why.
29
39
30
40
You can read more about ``dataclasses`` in the Python docs here:
0 commit comments