Posts

Showing posts with the label bad

Why JSON Won ... And Is Good As It Is

I keep seeing developers complaining about different things with JSON protocol and don't get me wrong, I've been the first one trying to implement any sort of alternative starting from JSOMON and many others ... OK? Well, after so many years of client/server development is not that I've given up on thinking " something could be better or different ", is just that I have learned on my skin all reasons JSON is damn good as it is, and here just a few of these reasons. Reliable Serialization ? No , 'cause YAGNI . There are few serialization processes I know that kinda work as expected and since ever, PHP serialize is a good example. Recursion is not a problem, is part of the serialization process to solve it, as well as classes together with protected and private properties. You can save almost any object within its state, even if this object won't be, as reference, the same you serialized .. and I would say: of course ! There are also two handy methods, _...

JavaScript Random Hints

Update some point has been made more clear, thanks to Dmitry Soshnikov for suggestions. Forget the global undefined Too many developers relies into undefined variable in ES3, and all they should do is to set undefined = true on global scope and see if the application or all unit tests break or not. I am going to demonstrate how simple is, at least in ES3, to redefine by mistake the global undefined. // inside whatever closure/scope function setItem(key, value) { this[key] = value; } // later in the scope, setItem may be reused // through call or apply for whatever object setItem.call(myObject, myKey, "whatever value"); // if for some reason the first argument used as context // is undefined, the "this" will point to the global context // if for some reason the second argument used as key // is undefined, the accessor will cast it as undefined string // the result of latter call with these two // common or simple conditions // is the quivalent of: window.undefin...