General OO teaches us to encapsulate and best practices teach us organization. So we end up with re-useable self-documenting code that relieves us of any details regarding implementation.
So, if I need to invoke the windows command line I use my command line class.
class CommandLine
{
CommandLine(){}
Invoke(string command) {}
CloseAsync(){}
Close Sync(){}
}
Over time these simple encapsulations turn into libraries. We may even have further classifications via Namespaces. This works very well in the same language. Especially when its a language the developer commonly uses.
But, I often run into situations, especially in lesser used languages, where I need to recall a simple common concept that may not actually be a class at all. For example, I don't write a lot of jQuery, but I write enough where I get tired of looking up the proper syntax for $(document).load...or is it
$(document).ready()
or...
$(document).read(function(){});...
This kind of boiler plate code, which I understand well the purpose of, but lack the experience and regular usage of the language to remember the syntax is where my problem lies.
I have seen some developers write a blog to simply remember the idea. My usual approach is...
Google "document load"
GOogle "document load jQuery"
...find some snippet
Google "Document Ready jquery"...done
And this has usually been fine. But, I have also noticed that on SO, some of the top answerers, say Jon Skeet, seem to pull boiler plate answers very quickly...so quickly I wonder if they have built up some sort of reference material to quickly search and slap together this code on the forum, piecemeal or in full.
I would like to use this same concept (if it exists...) to store my "document.ready" snippets so that I may use them for my own coding.
So, does an effecient storage and lookup exist?
What is the best way to store and organize these irregular, but common useful snippets?
Bonus...its even more interesting to note how my coding approach does not lend itself well to white-board interviews (where we have no google, but are expected to write code). How do you handle this issue when facing the "lesser used" languages in your vocubulary?