If you need to swerve to avoid an obstacle, it is important to:

If a hazard warrants you to brake and swerve, you should perform one action and then the other. Either swerve and then brake, or brake and then swerve. Do not do both at the same time.
DMV Writen Test