Latest Replies
Tuesday
Jun242008

Minor code readability

Here's minor thing that just made the code feel a little better:

using (var inputStream = _inputFile.PostedFile.InputStream)
using (var stream = _fileStore.Create(tempInfo))
{
  inputStream.PumpTo(stream, <span style="color:green;">128.Kb()</span>);
}

128.Kb() is more friendly to the eye than 1024*128

« Launchy - Open Source Keystroke Launcher for Windows | Main | Using Windows Server 2008 64 bit as a development workstation »

Reader Comments (2)

That's neat :) You could also have the same for other measures like seconds/minutes. The only problem I see, is that it can be used nonsensically - for example Thread.Sleep(1.Kb()) or inputStream.PumpTo(stream, 128.Seconds()). But garbage in = garbage out, so I don't think I really have a problem with that.

June 24, 2008 | Unregistered CommenterFredrik

Fredric,

Clear logics of the code could save us from some trouble here. So if we extend int.Seconds() to return TimeSpan, it would disallow us to use derived expressions in pumping code.

Thread.Sleep, on the other hand, accepts the TimeSpan (as any other methods that deal with the timing).

WBR,
Rinat

June 24, 2008 | Unregistered CommenterRinat Abdullin

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>