Some states struggle with a judiciary that is either unaccountable to the people or subject to the whims of voters who, for the most part, may know nothing about the candidate they select on the ballot. California has an excellent system that combines both. Most attorneys in Kern County have a great deal of confidence in the independence and ability of the judges that hear their cases, and that confidence is entirely justified.
Some states have the governor appoint their trial judges, while other states have these judges face direct election. Neither system is very good.
A handful of states use retention elections, but that idea has not really caught on. It appears to combine the worst of both systems: the judges are appointed and the people do not really have a choice in the election. According to another old saying, you can't beat somebody with nobody.
In the Golden State, appeals court judges are appointed by the governor and confirmed by the nonpartisan Commission on Judicial Appointments. The governor can choose the best person for the job and, at the same time, cannot play politics or reward campaign donors with judicial positions. Their terms are limited to 12 years.
Trial court judges must face election every six years, but the elections are nonpartisan. The result is that a voter must know something about the candidate before casting a vote. Such a system makes the judges independent, but still makes them responsive to the electorate.