Spring is a popular time for renters to move in and out of apartments. If you’re moving into an apartment, it’s not too early to think ahead and play by the rules so you can get all of your security deposit back when you decide to leave.

I always recommend taking pictures of the apartment the day you move in to note the condition of the unit. Make sure to document any known defect: scratches on the floor or paint, a dent in the refrigerator, a mark from a doorknob on the wall, a spot on the carpet, a missing doorknob, a hole in a screen or a crack in a window.

Make sure you have a date on those pictures — email them to yourself to be sure. It’s not a bad idea to email those pictures to your landlord as well. It’s best to avoid being in the position of paying for damage that a prior tenant caused.

Also, if you wish to make any adjustments to the home, like painting even one wall, you must get your landlord’s permission in writing. Once the changes are approved in writing, keep that correspondence as a record.

Take the same amount of caution when moving out. This will determine whether you get all or part of your security deposit back.

If you hung pictures on the wall, go back and fill in the holes left by nails. If you painted, you will need to return the walls to the original color it was the day you moved in. Assess the overall condition of the paint to see if there are scuffs or scratches on the walls that you caused.

Check to see if there is anything in the bathroom that needs to be re-caulked. Make sure all appliances are functioning. Check the ceiling, floor, windows, doors, screens — everything — to make sure they look the same as the day you moved in. If not, do what you can to correct the damage. A trip to Home Depot or your local hardware store should help you get all the supplies you need.

If you feel the damage is beyond what you can fix, hire someone to help you. If you are in a condo or co-op, ask around to see whether the other unit owners have a handyman and a cleaning service. A handyman who has worked in the building will be familiar with some of the common features and problems, and will know how to fix them and where to get replacement parts if needed.

Both a handyman and a cleaning service that are already working in the building may be able to give you a better price quote. Spending money to have the home cleaned when you move out is a good idea, if you can afford it. If the owner decides the home is not clean enough and has to hire a cleaning service, you will not have control over that cost. The owner will choose their cleaning service and take the cost out of your security deposit.

The security deposit issue can be a little complicated when one roommate opts to move out before the other one. The roommate who is staying will probably have to give a portion of the security deposit to the one departing.

The departing roommate should make sure their name is taken off the lease and utility bills so they will no longer be held responsible for paying them.

The person who is staying may want to look for a new roommate. The landlord would have to process and approve the application of the new roommate in order for their name to go on the lease. The new roommate should also be responsible for a portion of the security deposit.

That person should also take pictures of the home on the day of move-in.

Taking these steps on the front end can save you headaches later when you move out.

Nancy Simmons Starrs is founder and president of Apartment Detectives, a D.C., Maryland and Northern Virginia apartment-search service.