mardi 17 mai 2016

What is this anti-pattern called?

Let's say I have a function called send_welcome_email() and a class called User (implemented in Python but hopefully easy to understand for non-Python devs):

class User:
    email = TextField()
    first_name = TextField()
    last_name = TextField()


def send_welcome_email(user):
    msg = EmailMessage(recipient=user.email)
    msg.send()

In this case, it would have been better to define the function interface as:

def send_welcome_email(email)

so that the function is not coupled with the User class.

I know this is a known anti-pattern but I cannot find it. Anyone know what it's called?

Aucun commentaire:

Enregistrer un commentaire