H
hobosalesman
I've divided my code into classes, and I use objects as much as
possible to make the code maintainable and so I can reuse code. I have
modules and objects that need to be used throughout my relatively large
program, from several different packages/classes. FOr instance I have a
handful of fully encapsulated classes with get/set methods to access
instance variables and all. Each of these objects needs to interact
with my database, and obviously I can't have 100 different database
connections for every object. So I want to use inheritance so that all
classes that need to use the database inherit methods for doing so from
a database parent.
But then I also have a class for logging actions that every object
needs to use. And each object needs to use a configuration class that
reads from the config file. And on, and on. I don't know how to set
this up, multiple inheritance? I want to keep it simple, maybe I can
have one parent class that creates instances of the log/db/conf classes
and allows every other class to inherit functions that allow access to
these log/db/conf objects.
I don't want some hack with global variables, I want namespacews as
clear as possible. Maintainability, code re-use, clarity are all more
important than speed for this program. Any advice is welcome.
possible to make the code maintainable and so I can reuse code. I have
modules and objects that need to be used throughout my relatively large
program, from several different packages/classes. FOr instance I have a
handful of fully encapsulated classes with get/set methods to access
instance variables and all. Each of these objects needs to interact
with my database, and obviously I can't have 100 different database
connections for every object. So I want to use inheritance so that all
classes that need to use the database inherit methods for doing so from
a database parent.
But then I also have a class for logging actions that every object
needs to use. And each object needs to use a configuration class that
reads from the config file. And on, and on. I don't know how to set
this up, multiple inheritance? I want to keep it simple, maybe I can
have one parent class that creates instances of the log/db/conf classes
and allows every other class to inherit functions that allow access to
these log/db/conf objects.
I don't want some hack with global variables, I want namespacews as
clear as possible. Maintainability, code re-use, clarity are all more
important than speed for this program. Any advice is welcome.