I was wondering what is the effective weight of extension methods, if used very wildly.
If, for example, i decide to create a lot of string/int/datetime extension methods for many of the common day-to-day tasks, to obtain a kind of fluent interface as a result, it may be that the overall weight would pump up excessively? And if yes, would it be at design time (e.g. intellisense db growing too much) or runtime or both? Or none of them? To avoid a massive amount of intellisense-suggested methods everywhere, i was thinking about putting them inside a separate namespace like "MyCompany.PathExtensions" or "MyCompany.DateTimeExtensions" or even all of them in a fancy "MyCompany.FluentEverywhere" or similiar...
An example of what I'm talking about:
DateTime d;
d = 23.Minutes().FromNow();
d = "14".ToIntOr(0).IsBetween(10,20).IfFalseThrow(new Exception("foo"));
String finalPath;
// This will give you "c:\foo\bar\"
finalPath = "c:\\".AppendPath("foo").AppendPath("bar").EnsureTrailingBackslash();
String finalUrl;
// This will give you "ftp://mycompany.com/foo/bar"
finalPath = "mycompany".EnsureDomainExtensionOr("com").AppendPath("foo/bar").EnsureTrailingSlashNotThere().EnsureProtocolOr("ftp");
And so on... oh, and do not go berserk on things like .IfFalseThrow(...)
, they were just examples ;) !
What do you think? Apart from the usage, that is likable or not depending on tastes, there may be problems relating overall weight?
Thanks