This question should be language agnostic, but for simplicity, I will provide an example in python.
Suppose that I have a pandas dataframe with some columns and I have a getter that gets one of the columns:
def get_dataframe_column(dataframe, column_name):
# should I check that the column exists here
I'm wondering what is best practice. Should the get_data_column
function itself check to make sure the column exists, or should the caller know what they're doing and make sure they're using it correctly?
I feel like when it comes to python, they have more error checking than a language like C++, so maybe the question does become language dependent?
Aucun commentaire:
Enregistrer un commentaire