Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save photonxp/9808661 to your computer and use it in GitHub Desktop.
Save photonxp/9808661 to your computer and use it in GitHub Desktop.
Design discussions on inheritance and HTTPServer design
python2.6.5
help("BaseHTTPServer")
It seems that HTTPServer become heavy after it inherits many methods from TCPServer.
Through BASEServer to TCPServer to HTTPServer, in my view it's better to be a pipe-lined structure. I hope HTTPServer could be something like a plugin for TCPServer or BASEServer, because I think the registration mechanism seems to be better than inheritance.
Statistically, the model for Parent Classes are probably much stabler than Child classes. Parent Classes are like infrastrcture. Usually, infrastructure tends to change less frequently than Child classes. The Child Classes don't need to get himself bound with the Parent classes too much, which limit their freedom.
class HTTPServer(SocketServer.TCPServer)
| Method resolution order:
| HTTPServer
| SocketServer.TCPServer
| SocketServer.BaseServer
| ----------------------------------------------------------------------
| Methods inherited from SocketServer.TCPServer:
|
| __init__(self, server_address, RequestHandlerClass, bind_and_activate=True)
| Constructor. May be extended, do not override.
|
| close_request(self, request)
| Called to clean up an individual request.
|
| fileno(self)
| Return socket file number.
|
| Interface required by select().
|
| get_request(self)
| Get the request and client address from the socket.
|
| May be overridden.
|
| server_activate(self)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment