This is something new for me , so thought – something like this might be a news for some of the crowd. And I was immensely helped by this concept, so sharing.
Jumping off the context a little – I still remember the first time I heard of ‘Ajax’. It was an job interview, where after I did reasonably well on the Java quizzing, I was asked – ‘What do you know about Ajax?’, and I made an honest admission that I have never heard about it. Well, after the interview, I came back and did a google on ‘Ajax’, and I realized – oh well it’s a football club from Amsterdam. But why the hell was that being asked in a programming interview? .I went on to next results .. and came to learn about the JS Ajax(the one which would be of more value/interest to me in the coming years !!).
Back on to the debounce and throttle needs when making Ajax requests. How much Ajax has been used since it’s inception needs no enlightening. What has been my learning lately though, has been a case of an unnecessary overuse of Ajax, and the tricks which can be used to avoid this misuse.
The use case involves any repeating user Behavior acting as a trigger for a server side request made via Ajax from the UI - (Some examples that I could think of)
But effectively the solution is to tell the browser in someway that – “Please treat the last activity made in a period of ‘n’ duration as the final one, and fire an event for this last activity only(ignoring the earlier ones)”. This technique is termed as debouncing.
A probable alternative solution could be throttling – to limit the execution time of the function on the event(triggered by user activity) by providing a duration limit( in miliseconds) . This approach again may or may not solve the problem you have at hand (depending on the use case). For example for a toggling of a flag var state, this might not be useful, and debouncing will be required.
While the description may go all over your head( I’m not good at explaining), the implementation of these is pretty simple. Thanks to jQuery plugin by “Cowboy” Ben Alman . A five minute read would be more than enough for implementing the required and getting your next month’s pay-cheque from your supervisor instead of a nasty stare.
The examples at the shared link (again courtsey Ben Alman) demonstracte just how helpful this concept could be. How hardly you might be hit in abscence of this fix, will depend on what happens in those Ajax requests, How time consuming they are ?, Do they modify concerned state also ? etc. factors.
Apparantly, the multi-utility library – ‘underscore.js’ also provides the similar functionality. See here.
Disclaimer:Maybe the headline is misleading. I’m talking in terms of technology, And I’ll try to present my POV on this highly debatable topic. I plan to collect input from others and expect their honest feedback with promises of answering whatever queries I am capable of answering.
We’re taught since times we get our senses – “Avoid the easy way out”, “Take the longer route, It’ll make u tough”, “There are no short-cuts in life” etc. etc .. ….
While most of it is true in context of the day-to-day life … I somehow beg to differ with notion that “There are no short-cuts in life” (in context to Technology). I believe that usually their are numerous solutions to each of the situations in day-to-day IT problems. And the ease of taking each one of these routes differs considerably when compared to each other.
I am a java developer who’s been involved in development projects for over four years now, and in my four year old journey as a coder, I’ve come across couple of characters who have been religiously following another (I won’t use the word – ‘old’) school of thought – that says “Don’t use one alien technology to learn another” which is good to hear and makes good sense too , but not always. I myself have stuck to this practice at many a times. However strict adherence to this logic is
(a) not always practical in professional work environments and
(b) not always beneficial also.
It’s one thing to be using an IDE (containing auto-completion & syntax-checking) only after you’ve learned the syntax & the compilation& interpretation of the code. Quite another – to be discarding every new & outstanding technical solution, just because you are not aware of the building blocks of the new solution.
If quickstarting one particular technology can lead to normalizing the learning curve for ten different technologies, then what’s the issue? One eligibility criteria here is that for you learning of the quickstarted technology shall not be more vital than the leanings of the other 10 technologies. The technological solutions that may fall in this category for a java developer could be – Appfuse, Maven, Dojo, DWR, Acegi etc. .
In the past, Ive got flak/taunts from my colleagues/seniors for relying too much on different third party technical tweaks/solutions for solving the problem in hand. I understand their concern.Maintainence issues are automatically increased with each inclusion of something new. but my point is – the amount of time I save by learning and using some third-party solution – I’m willing to input the same on the learning that I’ll achieve in solving any possible maintenance/integration issues instead of spending the same time on ‘Re-inventing the wheel’. Yes, it is re-invention of the wheel when something usable exists and you refuse to use it and it’s As I’ve learnt -A Programmer’s Sin.
Yes, one should not be a short-cut man. He’ll be hollow then. Real knowledge is depth of understanding. However, my suggestion is to not get into the habit of learning everything in the same manner. Prioritize your learning and take them case by case depending on how much you need them. For someone developing a business solution based on a bunch of patterns ‘Appfuse‘ may just provide a building block and it can be learnt as it comes in a leisure time focusing more on the dominant technologies that actually solve the problem. The same technology solution – Appfuse – for one of it’s source contributors will be much more important aspect – and it’ll be a start from the scratch learning for him.
I’ll try to follow this up with a personal experience (w.r.t my experience while learning/working with Appfuse).
revert for a healthy discussion.
The eternal cliche’ – “I have been thinking of writing a blog for quite some time now“
I ‘ve lost count of the number of times I’ve found this statement in any blog’s very first post. And I’m resuing it in my own.
Yes… I also have been thinking for a long duration on starting blogging … soon … The simplest reason for the delay (as if .. there was a fixed time) .. . could be sheer laziness … or maybe .. inhibitions .. that how bad could I get.
I would be presenting my ideas on a variety of topics that interest/disinterest me along with others. The main purpose of my writing my own blog (and I believe this is the prime purpose of blogging) is – to give me a sense of satisfaction – “that I can express myself” .. that I can raise a voice and … if I’m lucky … and if I’m any good …. could maybe get heard too.. .
the title of the blog .. “The mighty one” came to my mind .. this morning when I was watching a movie named “the motorcycle diaries” .. the actor (don’t remember the name) says … from now on… we live as per “the mighty one” . could not think of anything better.
I would try to be regularly blogging. and would try to respond to all comments posted… Maybe I’ll have to hire someone for that ( … assuming my entire fan following turn into my blog’s followers also… ).
Dude .. don’t be turned off … I’m very modest.
And all i know is- that “I’m the Man.”