Understanding the CompressedFolder Class - Examining the Exposed Methods
(Page 4 of 4 )
The CompressedFolder class has quite a few methods. They break down into three groups: exposed methods, internal methods, and support methods. The exposed methods are the public methods exposed by the class object. These simply point to methods in the second group. The internal methods are the ones that perform the actual work of creating the folder, adding and extracting files, and so forth. The last group is the support methods. These are the extra functions and subroutines that are used by the internal methods.
Public Sub Open(strFile)
FullName = strFile
End Sub
Public Sub Create(strFile)
If objFso.FileExists(strFile) Then objFso.DeleteFile(strFile)
FullName = strFile
NewCompressedFolder FullName
End Sub
Public Sub Add(strFile, blnKeepOriginal)
AddFile FullName, strFile, blnKeepOriginal
End Sub
Public Sub AddMultiple(varSource, blnKeepOriginal)
AddFiles FullName, varSource, blnKeepOriginal
End Sub
Public Sub Extract(strFolder)
ExtractAll FullName, strFolder
End Sub
Here is the first group of publicly exposed methods. You can see that these methods simply accept user input and use it to call another internal method. This is a good coding practice for a couple of reasons, but in my case there was one reason that really stood out.
I wanted to be able to control functionality using the class object’s properties. Since most of these properties would at some point be used as parameters for my methods, I created a simple public method with pertinent parameters, and then passed them along with the others to my internal methods. In this way, even though an internal method might have three or four required parameters, the user will only need to supply one or two in their code. The rest would be predetermined by the object’s properties.
While you won’t see very extensive use of this practice in this code class, I did want to leave that flexibility in place for demonstration purposes, as well as for future upgrades. I have several additional features that I plan on adding to this class in the future.
Unfortunately, I’m out of space for this article. So far you’ve seen all of the parts that are exposed through the class’s object. Be sure to stop back for part two of this series to see the continued explanation of this class. In my next article, we’ll be examining the internal methods used by this class, as well as its implementation. Until next time, keep coding!
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |