For Joomla! specific information use the Joomla Docs website at http://docs.joomla.org, it has a Developers page. While most documents have been updated for the 3.x series it's worth knowing that a lot of the 2.5.x articles are still relevant.
Joomla supports three main extension types — modules, plug-ins and components.
Joomla! Magazine had a series starting back in Feb 2013 on Extension Development as well.
Finally there are also a range of good books/eBooks, including official Joomla! Press titles, and 3rd Party books, the most recent I'm aware of is "Learning Joomla! 3 — Extension Development" from PackTPub. [Disclaimer: I own a copy of this book and know the author from the Sydney Joomla User Group that he co-ordinates & hosts each month.]
For K2, I would suggest the community forums and Google (as their developer focused documentation is, shall we say, very scarce).
The other good way is to look at how existing K2 extensions are written.