Search code examples
pythonobjectoopinheritanceclass-diagram

using Class diagram to create baseclass in object oriented programming in python


I am new to object-oriented programming I need to write a BankDataWriterBase base class in the following program using the class diagram given in below to the code. I cannot understand the complete thing that the class diagram has, anybody here to know & explain to me what they actually saying using the class diagram

import pandas as pd

class ExcelParser:
    def __init__(self):
        self.config = []       
    
    def extract(self, file_name):
        ra

here is the class diagram for the BankDataWriterBase class, i have completed the EXcelParser class but i dont know how to approach the BankDataWriterBase class 

[![enter image description her



Solution

  • Since you already have an ExcelParser we'll start from there, But first perhaps take a look at this

    ExcelParser will have an attribute config which is a List[str] and the function extract which you already have. You will need to store an instance of a BankDataWriterImpl.

    BankDataWriterBase will be the base of BankDataWriterImpl(<-- needs to inherit from the base class) and will have some attributes: input_path, output_path and bank_identifier And a function write_file.

    BankDataWriterImpl will have an extract_json function with a string argument and no return. BankDataWriterImpl will also store between 1 and n Tasks(so a list of tasks).

    Each Task will have a run function that has no arguments and returns nothing.

    Finally if you want to denote types in python take a look at the typing module