Dynamics


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.

  1. Unless you really need it DO NOT use dynamic (well this is exception if you are using dynamic language. See this)
  2. Dynamic keyword is easy to use. Manipulating it is easier. Just use foreach!
  3. Auf Wiedersehen, compilation error checking!
  4. Au revoir, low maintenance!
  5. See you, high performance!
  6. Oh! Hello there, many exceptions!
  7. Visitor pattern ready programming type.
  8. 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.

Advertisements

Author: Aditya Yedija Situmeang

Developer, Lover, Christian, Omnomnomnivore, Gamer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s