The before code lacks clear naming, encapsulation, and type hints. The after code applies checklist items like naming conventions, encapsulation, and SOLID principles to improve design clarity and maintainability.
### Before: No checklist, ad-hoc review
class User:
def __init__(self, name, age):
self.name = name
self.age = age
def getdata(self):
return self.name + str(self.age)
### After: Review guided by checklist enforcing SOLID and naming
class User:
def __init__(self, name: str, age: int):
self._name = name
self._age = age
def get_data(self) -> str:
return f"{self._name} {self._age}"
# Checklist applied:
# - Method names are clear and follow naming conventions
# - Encapsulation by prefixing attributes with underscore
# - Type hints added for clarity
# - Single Responsibility Principle maintained