If you have not yet been formally charged, an attorney can often work to avoid the filing of formal charges. if the police are investigating you, or if you are arrested, your attorney can give you a voice in the process and try to help you avoid charges all together. Most cases go from the police to a prosecutor who must decide whether to charge you. You will want an attorney to advocate for you. In Domestic Violence cases it is common that the alleged victim is coopertive in seeking to drop the charges. An attorney can advocate for you and facilitate trying to get your case dropped even before you are actually charged.
Maximize your chance for success
Even if you are charged, a good attorney will find out what evidence exists, scrutinize that evidence, and file appropriate motions to suppress evidence or dismiss the case. This may lead to your case being dismissed, or may get evidence suppressed, thereby improving your chances at trial. Ultimately, even if the government's case survives the scrutiny and attack mounted by the defense, you will have a well prepared attorney, who will have minimized the evidence that may be used against you, if you elect to go to trial. This process often has the side benefit of yielding the best possible plea offers, in case you don't have a desire to force the government into proving your case at trial.
The best way to avoid the consequences of a criminal charge? Hire an attorney and prepare to go to trial. You can't get a sentence if you aren't convicted. It is often the case that by preparing for trial, your case may get dismissed or favorably resolved without ever really needing a trial.