Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring - Part 3 #53

Open
stefpiatek opened this issue Dec 1, 2022 · 0 comments
Open

Refactoring - Part 3 #53

stefpiatek opened this issue Dec 1, 2022 · 0 comments
Labels
preparation Exercises to do before the class week09 Structure and design

Comments

@stefpiatek
Copy link

stefpiatek commented Dec 1, 2022

This follows on from #52.

Stage 3: Object-oriented structure

We will now look at at how to represent and manipulate this data using our own user-defined objects.

Instead of a dictionary, we will define two classes, which will represent a single person and the whole group. We will restructure our code so that group functions apply directly to the group, instead of the person having all of the methods.
Again, you may also wish to refer to the course notes on object-oriented design.

Take a look at the file initial_two_classes.py to see one possible way in which the code could be structured.

Internally, the Group class still uses a dictionary to track connections, but someone using the class does not need to be aware of that. We have implemented some methods for these classes, but not everything that is required (the remaining methods have pass instead of actual code).

Your task:

  1. You should have the files from the previous parts of the exercise.
  2. Fill in the remaining method definitions.
  3. Update the section at the end of the file so that it creates the same group as in the previous example, but using the new classes you have defined.
  4. Run the file to make sure it gives the same results as before (that is, the assertions still pass).
  5. Commit your changes.
  6. Create a pull request from your branch to the original friend-group repository and use the text in the description to link your PR to this issue Answers UCL-COMP0233-22-23/RSE-Classwork#53
  7. Think of the benefits and drawbacks of the object-oriented structure compared to the original approach (collection of functions).
  8. If you have time, think of other changes you consider useful and try them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preparation Exercises to do before the class week09 Structure and design
Projects
None yet
Development

No branches or pull requests

1 participant