Skip to content

Instantly share code, notes, and snippets.

@xb4dc0d3
Created March 19, 2020 07:25
Show Gist options
  • Save xb4dc0d3/0f4789ce33a3abdc2bcf93c8aa54d4a0 to your computer and use it in GitHub Desktop.
Save xb4dc0d3/0f4789ce33a3abdc2bcf93c8aa54d4a0 to your computer and use it in GitHub Desktop.
# Bad
def create_user_mahasiswa(self, name, username, student_no, telephone_num, gender):
self.name = name
self.username = username
self.student_no = student_no
self.telephone_num = telephone_num
self.gender = gender
# Good
class Mahasiswa:
def __init__(self, config: dict):
self.name = config["name"]
self.username = config["username"]
self.student_no = config["student_no"]
self.telephone_num = config["telephone_num"]
self.gender = config["gender"]
mahasiswa = Mahasiswa(
{
"name": "Rudi Sutanto",
"username": "rudi.sutanto",
"student_no": "123456789",
"telephone_num": "081212345678",
"gender": "Male"
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment