In DotA, there are two kinds of gold, reliable and unreliable.
When you die, you lose an amount of unreliable gold, but never reliable, hence the name. Buying items uses unreliable gold first, and buyback uses reliable gold first.
Passive gold you get as time goes on is unreliable. Gold from creep kills is unreliable.
Reliable gold comes from killing heroes, including assists (being in a 1000 radius, you don't actually have to do damage). Team gold from the tower and Roshan is also reliable (but not for the killer). Midas and Track give reliable gold.
As a rule of thumb, if you do not plan on buying back, you should spend all your unreliable gold before you die in order to have no waste.
For advanced players, as a rule of thumb for carries in the later stages of the game, you should wait until you have enough unreliable gold to cover the cost of an item before buying it, unless you have reason not to. A reason not to, for example, would be if you are planning on taking a fight soon and the item is important.
Through this kind of gold management, carries and even supports may find themselves with stockpiles of reliable gold as the game progresses. This goes hand in hand with having buyback available. Indeed, for buyback-minded players the very act of always having buyback means that item purchases are often done with unreliable gold.
As an aid to purchasing quickly, it is useful to have items pinned to quick-buy by shift-clicking them in the shop. You can set hotkeys for quick-buy as well as a sticky key (defaulted to town portal) in settings.