This is a trolling rant. Reader discretion is advised!
.Net is elegant
Whenever I have to deal with Http in C#, I am reminded that .Net is a very elegant framework. Why?, because Http classes in .Net are the exact opposite of elegant.
While everything in .Net encourages reusability, encapsulation and inheritance. Http classes are quite the opposite.
Obviously Microsoft is so in love with Http that they decided to spawn like a hundred HTTP request classes.
so every time you want to make an http call, you have to pick from a handful of classes:
- you get HttpWebRequest, to deal with Request streams.
- you get HttpRequest to deal with IIS requests in ASP.Net pages.
- you get HttpListenrRequest to deal with self-hosted servers.
- you get HttpRequestMessage to deal with HttpClient.
- and the list goes on..
Ok, but requests are not created equal, but you get the same response, right? NO. each of these requests has its own response.
And none of them is powerful enough on its own. In one, you get a content stream, the other has the stream as a body property. the third gives you http headers in one place, the forth gives you the content headers in a separate collection (don’t get me started on how each class defines the header collection!).
so basically, whichever class you choose, you are screwed, and you will have to implement the parsing and helpers that are already implemented in the other class!
Seriously?! haven’t they heard about inheritance? reusability? conforming to standards?. I know MS has a problem with standards, but these are your OWN standards!
so Yay!. now every other open source framework can re-write their half-baked http client. Making it impossible to find a good one. Just what we needed.
you mean IntelliDull! You can never write C# code without using ReSharepr or VisualAssistX or the other 100 alternatives that everyone has to use. You can never tell on your own if a collection uses .Count or .Size or .Length or .Count(). You can never tell if you need to use GetImputStream() or InputStream or Stream using just intellisense.
means loosely fitting. like wearing a shirt 3 sizes bigger.
Where I work, I code in C++ a lot, and I hate it, and I count the lines till I can get back to .Net. But whenever I am back after a while. I can’t resist the feeling that .Net is no longer a solid framework. Sure it rarely has issues, and it is well tested, but it is like every MS employee is writing his own class with his own implementation. and I am sure this is not the case.
But I am also sure that there is no one in MS walking around and beating developers on their head with a standard!