Finally the laziness of mine came to fruition! What happened here is that I needed to parse lengthy json from a website and I was really lazy to map it all into a specific type. I was not fully lazy, I was also chased by tight deadline in my project. So to overcome my laziness I searched on how to deserialize json into a usable object. I came to JsonFx and I felt so happy on the result! I could cast the result into a dynamic object right away! Result: PRODUCTIVITY OVERLOADED!!!
Somehow, special thanks to Vivaldi and Mariko Senju, I got an enlightenment. I realized something I forgot: Performance issue! I thought of so many ways to overcome this and I got like not so different result. Ultimately, I was using C# and the result of this dynamic thingy is that I have no control to access the attributes directly. I got to use foreach! Look on the laziness of mine that possibly results in overflow!
I deeply discourage you all to use dynamic keyword on your code. After doing a little research on the dynamic, I came into some conclusion.
- Unless you really need it DO NOT use dynamic (well this is exception if you are using dynamic language. See this)
- Dynamic keyword is easy to use. Manipulating it is easier. Just use foreach!
- Auf Wiedersehen, compilation error checking!
- Au revoir, low maintenance!
- See you, high performance!
- Oh! Hello there, many exceptions!
- Visitor pattern ready programming type.
- I think it will be long to see you again refactor. (Well, if you are angry at your company and prefer to resign and then revenge, this will be great, though!)
Before you call me dynamic hater, please remember, I love this and used this! I also had not changed my code! I read this article and found out that using dynamic was really bad. A good guy here was testing the performance and see for yourself! The performance from 9 became 78, which nearly is powered by two! A nice number to consider, eh?
As far, I do not really know if there is any update and enhancement from Microsoft to improve the performance of using dynamic. I hope – for the sake of laziness and exploit as fact – that they will make dynamic keyword better. And the moment this is published, I should have been in a slumber sleep for I make this published later.