Note that there are some explanatory texts on larger screens.

plurals
  1. POClass design: allow a class to be used both as an object and also supply public static methods
    primarykey
    data
    text
    <p>I have a silly, little class "<strong>FileSystemSize</strong>" which can be used both as an object and also via public, static methods. The output is similar, but not identical in each case.</p> <p>The class was <strong>intially static</strong>, but I added the possibility to initialize it as an object to allow extending with new "<strong>convenience methods</strong>" in future versions, without the need for a lot of parameter parsing. For example I have <strong>GetKBString()</strong>, <strong>GetMBString()</strong>, etc...methods to allow getting the file size conveniently formatted the way I want it (as a string). Internally the class stores the file byte size as a double.</p> <p>I am a bit confused if this makes sense at all. It seems like I should perhaps split this into a static version and an object version like Microsoft does for Directory and DirectoryInfo. However it just seems easier to me to have this all in one place with a name that can't be mistaken - it should be clear what FileSystemSize does? Are there any implications for maintenance that I am not anticipating? What's that smell?</p> <pre><code>var mypath = @"C:\mypath"; var filesystemsize = new FileSystemSize(mypath); string kilobytes = filesystemsize.GetKBString(); string megabytes = filesystemsize.GetMBString(); double bytes = filesystemsize.ByteSize; double staticbytes = FileSystemSize.GetDirectoryBytesSize(new DirectoryInfo(mypath)); double statickilobytes = FileSystemSize.ConvertSize(staticbytes, "KB"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload