T
Thomas Lotze
Hi,
I've two questions concerning organizing and naming things when writing
a Python package.
- Naming of classes: I'm writing a library that reads PDF files. I have
a data structure that represents the large-scale structure of a PDF
file (header, trailer, incremental updates etc), and I'll have others,
e.g. one that represents the document as a collection of logical
objects (page descriptions, images etc).
Assume I have a package called PDF. Should the classes then be called
simply File and Objects, as it is clear what they do as they are
imported from PDF? Or should they be called PDFFile and PDFObjects, as
the names would be too undescriptive otherwise?
- Organizing subpackages and interfaces: I'm using the zope.interface
package in order to define interface classes. In a small package
called foo, one might define interfaces IReadableFoo and IWritableFoo
in foo.interfaces.
However, in a large package foo with subpackages bar and baz,
interface definitions might either sit in foo.bar.interfaces and
foo.baz.interfaces, or in foo.interfaces.bar and foo.interfaces.baz.
Which is preferable?
Thanks for any thought on this.
I've two questions concerning organizing and naming things when writing
a Python package.
- Naming of classes: I'm writing a library that reads PDF files. I have
a data structure that represents the large-scale structure of a PDF
file (header, trailer, incremental updates etc), and I'll have others,
e.g. one that represents the document as a collection of logical
objects (page descriptions, images etc).
Assume I have a package called PDF. Should the classes then be called
simply File and Objects, as it is clear what they do as they are
imported from PDF? Or should they be called PDFFile and PDFObjects, as
the names would be too undescriptive otherwise?
- Organizing subpackages and interfaces: I'm using the zope.interface
package in order to define interface classes. In a small package
called foo, one might define interfaces IReadableFoo and IWritableFoo
in foo.interfaces.
However, in a large package foo with subpackages bar and baz,
interface definitions might either sit in foo.bar.interfaces and
foo.baz.interfaces, or in foo.interfaces.bar and foo.interfaces.baz.
Which is preferable?
Thanks for any thought on this.