Quesitons about dc motor, capacitor and diode

To drive a dc motor, we need to add a capacitor in parallel with the motor. How do we decide the capacitance of the capacitor?

In case of a stepper motor, there are two coils. Do we need to use two capacitors? If we use a single capacitor for both coils, how do we decide the capacitance of the capacitor?

Please take this stepper motor Nema 17 Stepper Motor 2A as an example.

By the way, in the article arduino - Purpose of the diode and capacitor in this motor circuit - Electrical Engineering Stack Exchange , the author said we need also a diode to drive a dc motor. Is it necessary?

Please forgive me if these are too obvious questions to you ^^.

The cap you see in parallel with most brushed dc motors is to help reduce the electrical noise that the motor produces from the brushes moving across the contacts. It filters the fast spikes that can cause problems in the rest of the circuit.

The diode is used to provide a safe path for the current in the motor coils. Called a "flyback diode" This is to provide a current path when the motor is freewheeling (power is removed, or pwm off cycle) so that voltage doesn't rise and damage the circuit.

Brushless motors and Stepper motors generally have less electrical motor noise than brushed motors, You don't normally see the capacitor across the coils. You still need good decoupling for your power source however.