Class names

The name of a class has to be concise, precise, so that it is sufficient to understand from it what the class does. A common practice is to use a suffix that informs about its type or nature, for example:

  • SQLEngine
  • MimeTypes
  • StringWidget
  • TestCase

For base or abstract classes, a Base or Abstract prefix can be used as follows:

  • BaseCookie
  • AbstractFormatter

The most important thing is to be consistent with the class attributes. For example, try to avoid redundancy between the class and its attributes' names:

>>> SMTP.smtp_send()  # redundant information in the namespace
>>> SMTP.send()       # more readable and mnemonic           
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset