jeudi 13 septembre 2018

What is good practice way to separate writer operation from Object in python. Composition or inheritance ?

What is good practice way to separate writer operation from Object. Composition or inheritance ?

For example,

class Person:
  def __init_(self, name, age):
    self._name = name
    self._age = age

  def get_new_age(self):
    ....
  def get_name(self):
    ...

  def write(self): #write to file for example
   ....

Aucun commentaire:

Enregistrer un commentaire