Do you have a budget-conscious friend who advocates using cash to stay out of debt? Or perhaps data breaches at stores like Target or Staples have you wondering if you should always use cash at box stores. But then again, plastic is so convenient. Turns out, choosing to use cash or card is context specific. There’s a time and a place for both. It also depends a bit on your spending habits. Here’s what to know.

When to use cash

Although the convenience of credit and debit cards is well-established and widespread, sometimes not having cash in your pocket can be a headache. Using cash in these four situations is the better choice.

You’re trying to budget. Studies show that people part with their plastic much more easily than their cash because the money feels invisible, so if you’re trying to rein in your discretionary spending and even not-so-discretionary spending, greenbacks are your friend. Bottom line, people don’t like parting with cash. Try using the old-fashioned envelope system recommended by money guru Dave Ramsey to budget for groceries, entertainment, eating out and clothing. When you’ve used up your allotment for entertainment, for example, you’ll need to find free opportunities for the rest of the month. (Don’t borrow from another envelope.)

Shopping at farmers markets or food trucks. Even in this modern age, some places only accept cash, like taco and Asian noodle trucks or vendors at farmers markets. Sure, many mom and pop businesses use mobile iPads these days, but not everyone. If you’re heading out for lunch at your local food truck, be sure you have cash in your pocket.

Paying in cash at a restaurant Tipping in cash allows your server to take the money home immediately. Tipping on a credit card may mean the waiter doesn't get your tip until payday. (Photo: Artemenko Daria/Shutterstock)

Tipping at a restaurant. I’m in the habit of tipping with my card, but I’m moving to cash now that I know better. Cash tips give servers more control over their money, and it goes home with them immediately for groceries and other living costs. Restaurant policies vary, but tipping with your card usually means a delayed payment to the server because it’s often added into the paycheck at the end of the pay period. The fees for the card transaction may be passed along to the server as well. But don’t make not having cash an excuse not to tip. A plastic tip is better than no tip.

Vacation incidentals. When you’re touring for the day, you may bump into situations where cash is required — for example, some forms of public transportation, a kids’ balloon artist or fruit stands. I once got caught short at a city monorail that only took cash. Luckily, the kind attendant charged me only what I had in my pocket.

When to use plastic

I love my debit card because like cash, there’s no way to overspend, and it allows me to track purchases more precisely. In many cases, debit cards will work just fine, but they too can be compromised, so you should learn about your liability. In some instances, a credit card should be used instead for both practical and safety reasons. Here are four:

Using a credit card for online shopping Online retailers don't take cash, so a credit card is the way to go. (Photo: allstars/Shutterstock)

Purchasing items online. Cash won’t work for Amazon, and storing your debit card number online isn’t the best choice. A credit card is safest because if a site is hacked, your bank account can’t be drained since the credit card isn’t linked directly to it. According to Bankrate.com, debit cards are susceptible for a variety of reasons: Your computer might contain malware or a merchant might experience a data breach, to name a few.

Reserving a rental car or hotel. Some hotels allow debit cards, but a credit card is preferable so that any refundable deposits or temporary fees are refunded without you even noticing the money was being held. Using a debit card may entail waiting a few days for the refund. Many credit cards offer car-rental insurance, too, so you can skip that supplemental insurance the rental agency wants you to buy.

The gas pump or outdoor ATM. Your card information can be stolen via a “skimmer” installed to read magnetic strips or card numbers. Card theft at the gas pump is on the rise in 2016, and the technology has gotten more sophisticated and difficult to detect even if you’re alert to it. The best way to protect yourself is to use cash or a credit card (for the card’s zero-liability policy) and pay inside the building. If taking out cash from an ATM, choose machines inside stores or other high-trafficked places.

Big-ticket purchase. For a new dishwasher or a flat-screen TV, you may want to pay with a credit card because many offer extended warranty coverage for an extra year (check your card for rules and exclusions). Some cards also offer a certain amount of purchase protection if anything happens to the item you bought, and it needs to be returned.

Joanna Nesbit ( @joannanesbit ) Joanna Nesbit is a freelance writer specializing in education, parenting, personal finance, and college topics.