Skip to content

Long term: rewrite code to be more obvious #58

@changyang-liu

Description

@changyang-liu

This is a long term task and will likely require more than 1 PR to complete. A lot of previously written code is written in a very clever but very hard to read way e.g.

  • ImageUtils is passed as a kwarg so it's hard to find where it's actually being used
  • Confusing ways of overloading functions e.g.
@classmethod
def from_json(cls, serialized: dict) -> "GoogleDriveFile":
    return {
        GoogleDriveTextFile._code: GoogleDriveTextFile.from_json,
        GoogleDriveImageFile._code: GoogleDriveImageFile.from_json,
    }.get(serialized["_code"], lambda x: GoogleDriveFile(x, from_serialized=True))(
        serialized
    )
    
    # it's much more obvious just to use an if else statement

Though this is readable to an experienced Python developer, it makes it very difficult for new Daily Bruin contributors to understand the code. We should this code (mostly in kerckhoff.packages) so that it is more readable to the average person

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions