I'm starting to learn OOP so forgive me (or offer suggestions) if my UML is not keeping to standards.
Currently writing in VBA due to business restrictions so I don't have access to inheritance but it does have support for events and interfaces.
I have a Folder class (in blue) which has an object mFileSystemObject of type FileSystemObject
The Folder class holds many File objects in an array called Files.
Each File object has a FileDetails object (green).
I'd like to use the functions from the FileSystemObject class in the FileDetails class.
I'd like to use the same instance of the FileSystemObject in the Folder class as I don't want to instanciate a new one for every FileDetails class and fill up the heap and I'm not doing any work concurrently.
So I'd like to pass the reference to the FileDetails class so they all use the same one.
The only way I can think of doing this is to pass it through the File object even though File will not use it which just seems a bit ugly.
My question is - is there a pattern that solves this "passing through" problem - I've searched online and looked at several design patterns but they don't seen to offer any suggestions for a solution.
Any help would be greatly appreciated.
Many Thanks
Nick
Aucun commentaire:
Enregistrer un commentaire