欄位名稱很重要,它們幫助人們了解程式。
隨著經驗增加,對資料的了解也增加時,將新見解植入程式就非常重要。

Rename Field
# Before
class Book:
def __init__(self, title, author, numPages):
self.title = title
self.author = author
self.numPages = numPages
def print_book_details(self):
print(f"Title: {self.title}, Author: {self.author}, Number of Pages: {self.numPages}")
# After
class Book:
def __init__(self, title, author, number_of_pages):
self.title = title
self.author = author
self.number_of_pages = number_of_pages
def print_book_details(self):
print(f"Title: {self.title}, Author: {self.author}, Number of Pages: {self.number_of_pages}")