Geeks With Blogs
Running with Code Like scissors, only more dangerous January 2008 Entries
Simplified Parameter Checking: the Contract class
One of the first things we went over in my first computer science class was the idea of preconditions and postconditions for functions: what the caller should expect will be needed before and how the results will be after the call. We also discussed parameter validation, which I've found more and more to be important. Parameter validation is not only important for security purposes, but helpful in debugging scenarios when you wouldn't otherwise be sure that an exception is being generated because ......

Posted On Thursday, January 31, 2008 11:07 PM

The Remoting Mystery... solved!
I remarked yesterday that I was having difficulty accessing remoted objects - sometimes I would never break into the methods I was calling, and sometimes calling RemotingServices.Disconnect() would fail. I was a bit miffed about all this, and to say the documentation was unclear about why precisely an object would intermittently just stop. I was custom-marshaling the object upon startup of the host program; it wasn't server-activated, and shouldn't have any reason for just going away. But the failure ......

Posted On Tuesday, January 29, 2008 10:36 PM

The Madness of Remoting
My latest project has been pretty much my first real distributed application - it involves securely storing and encrypting credit card data in a system that makes it nigh impossible to access the information. It's actually been really fun, delving into the depths of secure programming and trying to come up with security measures to thwart perceived avenues of attack against the system. Part of the way that this system works is by encrypting sensitive data as soon as it arrives to the application ......

Posted On Tuesday, January 29, 2008 12:04 AM

My C# 4.0 Wishlist, Part 5 : The raise Keyword
One of the more obscure features of C# is the ability to specify custom overloads for adding and removing event registration similarly to properties, via the add and remove keywords. Known as "event accessors," they implement the parts of event registration that the C# compiler normally handles. You didn't think that that += operator was implemented on the type, did you? 1: class Test 2: { 3: public event EventHandler Event1; 4: 5: private EventHandler ev2; 6: public event EventHandler Event2 7: ......

Posted On Sunday, January 27, 2008 11:25 PM

My C# 4.0 Wishlist, Part 4 : Constant typeof() Expressions
Along with some of the hacks I introduced into ShinyDesign, there was a problem using a generic parameter as an enum - I couldn't cast it back to an integral type, even System.UInt64, because T was not guaranteed to be an integral value (yet again why we should allow a type constraint, but I digress). In any case, there have been cases where I'd like to, for instance, switch against a Type, particularly since incorporating generics. Consider: 1: switch (typeof(T).GetUnderlyingTyp... 2: { 3: case ......

Posted On Friday, January 25, 2008 12:30 AM

Dear Blizzard, Please Fix Warcraft's Patcher
Blizzard Entertainment's World of Warcraft is ostensibly the most popular massively-multiplayer roleplaying game available in the present market. It was released to the United States in November of 2004, and just last fall reached 7 million subscribers. It seems to be the holy grail of online gaming - imagine, at $15 per month (the U.S. price - international prices vary), 7 million subscribers sends a cool $105 million per month to Blizzard out in California. Now of course they've got consistent ......

Posted On Wednesday, January 23, 2008 11:40 PM

ShinyDesign - a Brighter Face for the PropertyGrid
I've officially released my property grid extension project, called "ShinyDesign," under the open-source BSD-like license. I blogged about this project just a few days ago, and I'm excited to be releasing it to the public domain. In truth, there are some ugly hacks, and I'm sure I could have done a better job commenting on what I did. All told, the multiple-tab hack is probably the worst. The Windows Forms PropertyGrid does not allow you to directly add additional property tabs; rather, you add Type ......

Posted On Wednesday, January 23, 2008 1:05 AM

My C# 4.0 Wishlist, Part 3: The Return of Const-ness
In C++, I can decorate member functions with the const modifier, which indicates that calling the member function will not modify the internal state of the object. Here's a sample class definition: Test.h: 1: class CTest 2: { 3: private: 4: int m_nVal; 5: 6: public: 7: CTest(void); 8: ~CTest(void); 9: int GetValue() const; 10: void SetValue(int value); 11: int Add(int value) const; 12: }; Test.cx: 1: #include "Test.h" 2: 3: CTest::CTest(void) 4: { 5: } 6: 7: CTest::~CTest(void) 8: { 9: } 10: 11: ......

Posted On Thursday, January 17, 2008 9:40 PM

Announcing a Better PropertyGrid
I haven't settled on a "definite" name yet, but I think I'm calling it "Shiny.Design" for one of my favorite adjectives from the Firefly universe. And with that in mind, let me announce my new PropertyGrid control and design project. Current supported features include: Support for renaming class properties Designation of custom names for enumeration fields A replacement UI type editor for enumerations marked with the [Flags] attribute Support of localization by overriding a property of the new [Name] ......

Posted On Wednesday, January 16, 2008 11:52 PM

My C# 4.0 Wishlist, Part 2 : Default/Optional Parameters
When I was first getting into C# (about .NET 1.0 Beta 2), I saw that it didn't support optional parameters. The explanation was simple enough: method overloads supported an alternative method of default or optional parameters. I thought that it was probably a useful choice. But, check this out: 1: public static class MessageBox 2: { 3: static void Show(string message) 4: { 5: Show(message, null, MessageBoxButtons.OK, MessageBoxIcon.Information); 6: } 7: 8: static void Show(string message, string ......

Posted On Tuesday, January 15, 2008 8:49 PM

My C# 4.0 Wishlist, Part 1 : Eliminate Type Constraint Constraints
C# 2.0 introduced a great new feature to the .NET Type system: generics. Generics are really cool in that they allow you to define template classes; I can use a single class definition to provide a strongly typed collection, for example. They enable some other tricks that I would tend to consider something of a "hack" as well; for example, this expression evaluates to true: 1: typeof(IEnumerable<int>) != typeof(IEnumerable<doubl... This expression is nice because there are some odd class ......

Posted On Tuesday, January 15, 2008 9:34 AM

Another Reason to Avoid Simple Properties
Another reason to avoid using Simple Properties: [Name("Simple Property Example")] [Browsable(true)] public string TestProp1 { get; set; } Look at the property in the debugger: Oh wait, I can't. I can't even set a breakpoint to let me know when the property is being accessed. I understand not being able to see the backing store or the value component - they are after all not part of the code. But you can't even see when they're being hit. All I have to say is... STAY AWAY ......

Posted On Monday, January 14, 2008 2:15 AM

A Reminder of Why We Like Object Orientation
I love Simple Machines Forum. It's a fantastic community software package, it's open-source, it's pretty fast, free, and it's got boatloads of features. It's so great, in fact, that I'm basing one of my personal projects on it. SMF is written in PHP (I'm running into too many acronyms already - this is, after all, a post about OOP). Being that PHP is a scripting language, and among other things strong with string processing, it seems pretty natural that it performs the parsing of UBBC (Universal ......

Posted On Sunday, January 13, 2008 11:37 PM

Where Have All My Gigabytes Gone?
I don't know if this is a Windows Vista-specific trick, or maybe something related to Volume Shadow Copy (the service that supports System Restore), but there seems to be a major discrepancy on my hard drive. In Windows Explorer, open the C drive, select all, then Alt+Enter to open the properties dialog. Size: 128gb (137,787,853,411 bytes) Size on disk: 129gb (138,600,678,813 bytes) (Note: I don't know how there's an odd number of bytes, except that apparently NTFS uses some type of odd clustering ......

Posted On Wednesday, January 2, 2008 12:51 AM

Copyright © Robert Paveza | Powered by: GeeksWithBlogs.net