Solid Principles, Python.
employee object? We choose simplest solution. We pass it when we call the save_as_json function. class Employee: json_filename = "emp.json" def save_as_json(self): with open(self.json_filename, "w") as file: file.write(f"name: {self.name}, salary: {self.salary}") One thing is immediately clear.