loading...

re: Code Smell — Too Many Parameters VIEW POST

FULL DISCUSSION
 

In different languages, you can use the same way. Let me show you a few examples.

This is an example for C#

class Student
{
    public int Age { get; set; }
    public string Name { get; set; }
}

public void SaveStudent(Student student)
{
    Console.WriteLine($"{student.Age} and {student.Name}");
}

And it should be written in Python like that;

class Student:
    def __init__(self):
        self.Age = None
        self.Name = None


def save_student(student: Student):
    print(f"Age {student.Age} and Name {student.Name}")


student = Student()

student.Age = 27
student.Name = "Ali"

save_student(student)
Code of Conduct Report abuse