
52 Cal.2d 808 (1959)
In re RUDOLPH BROWN MARTINEZ, on Habeas Corpus.
Crim. No. 6343. 
Supreme Court of California. In Bank.  
Oct. 30, 1959.
 Gladys Towles Root, Eugene V. McPherson and Robert Barnett for Petitioner.
 Edmund G. Brown, and Stanley Mosk, Attorneys General, Doris H. Maier, Deputy Attorney General, Roy A. Gustafson, District Attorney (Ventura), and Woodruff J. Deem, Deputy District Attorney, for Respondent.
 TRAYNOR, J.
 Petitioner seeks a writ of habeas corpus on behalf of Rudolph Brown Martinez, an inmate of the California State Prison at Folsom. Martinez is held under a judgment of conviction entered on his plea of guilty of robbery and burglary (Pen. Code,  211, 459), both of which the court found to be in the first degree. He also admitted that he was armed with a deadly weapon at the time of the *811 offenses. The petition charges that his conviction was obtained in violation of his constitutional right to counsel.
 It appears from the transcripts of the proceedings in the trial court that Martinez was arraigned and entered a plea of not guilty to the offenses charged in the information on September 4, 1956. At that time he was represented by petitioner as attorney of record. Trial was set for September 27th, but on September 26th the trial was reset for October 22d for the convenience of petitioner. On October 9th Martinez appeared in court without counsel, stated his willingness to proceed without counsel, withdrew his plea of not guilty, entered a plea of guilty, admitted that he was armed with a deadly weapon at the time of the offenses, waived a presentence report, waived time for sentencing, and agreed that he had no legal excuse to offer why judgment should not be pronounced against him according to law. The court accepted the deputy district attorney's recommendation that the sentences run concurrently and pronounced judgment accordingly.
 Petitioner contends that Martinez did not freely and intelligently waive his constitutional right to counsel at the time he entered his plea of guilty and that his conviction was therefore obtained in violation of that right. (Cal. Const., art. I,  13; People v. Chesser, 29 Cal.2d 815 [178 P.2d 761, 170 A.L.R. 246]; In re Connor, 16 Cal.2d 701 [108 P.2d 10].) We issued an order to show cause why the writ should not be granted and appointed a referee to take evidence and make findings as to whether Martinez understood his right to counsel and freely waived it when he pleaded guilty on October 9, 1956. The referee found that Martinez understood his right to be represented by counsel on that date, that there was no improper coercion or inducement to elicit the plea of guilty, and that he was mentally competent to waive his right to counsel. Petitioner has filed objections to these findings.
 [1] The record of the referee's hearing discloses that Martinez was informed of his right to counsel at his preliminary examination on August 28th and again when he was brought before the superior court for arraignment on August 30th; that on August 30th he was given a continuance to obtain counsel; that he was present when counsel was appointed for his codefendants after they stated that they had no money; and that at his actual arraignment on September 4th he appeared with counsel and his right to counsel was *812 recited to him for a third time. When he entered his plea of guilty he stated in effect that he wished to proceed without his attorney. In the light of these facts, his previous courtroom experience, and his admissions at the referee's hearing, there can be no doubt that he was well aware of his right to counsel on the date he pleaded guilty.
 [2a] There is also ample evidence to support the finding that Martinez freely and intelligently waived that right. The allegations that the district attorney threatened him with prosecution as an habitual criminal unless he changed his plea and that he promised him a recommendation of leniency and medical care for alleged narcotic withdrawal symptoms if he pleaded guilty were directly contradicted by the district attorney, who testified that no such representations were made and that he had never visited the prisoner in jail. There was thus presented a clear-cut question of credibility, which the referee decided adversely to Martinez, and which we find no reason to decide differently. Moreover, there is no credible evidence to support an inference of impropriety on the part of any representative of the state except the fact that Martinez changed his plea without notice to his attorney of record. Martinez' statement that since he had been caught in the act of robbery, "there was no doubt" of his guilt, his knowledge that his codefendants had pleaded guilty and had been promptly sent to prison, and his expressed desire to avoid wasting any more "dead time" while awaiting trial, fully explain the change of plea and preclude any inference of coercion or improper inducement.
 Finally, in the light of the testimony of the expert medical witness and Martinez' description of his own symptoms, we agree with the referee that there is no substance to petitioner's claim that Martinez was incapable of intelligently waiving his right to counsel because he was suffering from narcotic withdrawal symptoms at that time.
 [3] Although not binding on this court, the findings of fact made by a referee are entitled to great weight. (In re Allen, 47 Cal.2d 55, 57 [301 P.2d 577]; In re Mitchell, 35 Cal.2d 849, 855 [221 P.2d 689]; In re De La Roi, 27 Cal.2d 354, 364 [164 P.2d 10].) [2b] We have concluded that the foregoing evidence fully supports the referee's decision and we therefore find that Martinez understood and freely waived his right to counsel on the date he pleaded guilty. Accordingly, the judgment based thereon cannot be set aside on *813 the ground that Martinez was deprived of his constitutional right to counsel. The only question remaining, therefore, is whether the violation of certain statutory provisions compels vacating the judgment.
 [4] The trial court erred in permitting Martinez to withdraw his plea of not guilty and plead guilty in petitioner's absence and without his consent so long as he remained attorney of record. The procedure set forth in section 284  [fn. 1] and 285  [fn. 2] of the Code of Civil Procedure for a change of attorney applies to criminal as well as civil actions. (People v. Bouchard, 49 Cal.2d 438, 440-441 [317 P.2d 971]; see Code Civ. Proc.,  22, 24.) Petitioner did not consent to a change of attorney, no notice was given him until after the final judgment, and no order for a change of attorney was entered by the court. Thus petitioner remained attorney of record, and the trial court erred in allowing Martinez to proceed in person. (People v. Merkouris, 46 Cal.2d 540, 554-555 [297 P.2d 999].)
 [5] The trial court also erred in accepting a plea of guilty from Martinez without fully complying with section 1018 of the Penal Code.  [fn. 3] The following colloquy shows substantial compliance with the requirement of that section that the defendant state to the court "that he does not wish to be represented by counsel." "Mr. Holzauer: [the prosecuting attorney] ... So although Mr. McPherson has represented Mr. Martinez previously, if it is Mr. Martinez's desire to proceed now in the absence of Mr. McPherson, I can see no objection *814 to that. The Court: Are you willing to proceed now? The Defendant: That's right. Mr. Holzauer: It is your desire to proceed now? The Defendant: That's right."
 There was no adequate compliance, however, with the requirement that the court "first fully inform him of his right to counsel." It is true that Martinez was told of his right at and prior to his arraignment. The statute, however, was designed to ensure that a defendant appearing without counsel is aware of his right to counsel at the time he pleads guilty. It is not met by instructions given almost six weeks before that time.
 [6] Finally, the required finding that "defendant understands his right to counsel and freely waives it" was not expressly made by the trial judge and under the circumstances cannot be implied. Martinez' change of plea and his wish to proceed without counsel were presented to the trial court with no explanation other than the following statement by the prosecutor: "... I was informed Mr. Martinez wished to be taken into court as early as possible, and I caused an officer to go down to the jail to verify that that was, in fact, Mr. Martinez's wish and I was assured that he did wish to be taken into court." The court made no inquiry to discover whether Martinez had the experience and mental capacity to understand his rights or to determine whether his decision was the result of an intelligent choice freely made by him or of improper influences theretofore brought to bear upon him. (Cf. In re Berry, 43 Cal.2d 838, 841-843 [279 P.2d 18], footnote.) Thus there is nothing in the record to suggest an awareness of the statutory requirement, let alone an attempt to comply with it.
 [7] We have concluded, however, that since these procedural errors did not result in any deprivation of the constitutional right to counsel, they do not compel vacating the judgment. The only relevant purpose of section 1018 of the Penal Code and sections 284 and 285 of the Code of Civil Procedure is to secure the right to representation by counsel. (See Boca etc. R.R. Co. v. Superior Court, 150 Cal. 153, 156 [88 P. 718]; Board of Commissioners v. Younger, 29 Cal. 147, 150 [87 Am.Dec. 164].) When that right has been freely and intelligently waived, the defendant has not been deprived of any right that the statutes are designed to secure. [8] Vacation of the judgment on habeas corpus under these circumstances would serve only as an admonition to trial courts in *815 other cases. That is not a proper function of the writ. (See In re McInturff, 37 Cal.2d 876, 880-881 [236 P.2d 574]; In re Lindley, 29 Cal.2d 709, 722-723 [177 P.2d 918]; In re Bell, 19 Cal.2d 488, 492-495 [122 P.2d 22].) It must be presumed that trial courts will ordinarily insist on compliance with these statutory provisions and thereby discourage groundless collateral attacks on final judgments of conviction.
 [9a] It is true that convictions have been set aside on habeas corpus for failure of the trial court to require compliance with the provision in section 1018 of the Penal Code that a plea must be put in by defendant personally, even though the plea was entered by defendant's counsel in defendant's presence and without objection by him. (In re Breen, 162 Cal.App.2d 235 [328 P.2d 465]; In re Brain, 70 Cal.App. 334 [233 P. 390].) If those cases were correctly decided, the judgment should be vacated in the present case, for there is no more reason in the former than in the latter to vacate the judgment without inquiry as to whether the right secured by the statute had in fact been violated. [10] The purpose of the requirement that a plea be entered by defendant personally is to ensure that the plea is his own. If it is, the purpose of that requirement is accomplished, just as the purpose of the provisions to secure the right to counsel is accomplished when the defendant freely and intelligently waives that right. [9b] Accordingly, in those cases the court should not have declared the judgment void without determining that the defendant had not authorized or adopted counsel's statement of his plea. If he had authorized or adopted counsel's statement of his plea, no purpose other than admonition was served by setting aside the judgment on habeas corpus. In re Breen, 162 Cal.App.2d 235 [328 P.2d 465], and In re Brain, 70 Cal.App. 334 [233 P. 390], are therefore disapproved to the extent that they hold that a judgment must be vacated even if the defendant authorized or adopted counsel's statement of his plea.
 The petition for habeas corpus is denied, and the order to show cause is discharged.
 Gibson, C.J., and White, J., concurred.
 Schauer, J., Spence, J., and McComb, J., concurred in the judgment.
 PETERS, J.,
 Concurring and Dissenting.
 I concur with the opinion of Mr. Justice Traynor insofar as it holds that it *816 was error not to comply with sections 284 and 285 of the Code of Civil Procedure. I also concur with that opinion insofar as it holds that it was error for the trial court not to comply with the provisions of section 1018 of the Penal Code. However, I dissent from that opinion insofar as it classifies such errors as being merely "procedural," and insofar as it holds that such errors did not adversely affect "the constitutional right to counsel."
 The facts upon which I predicate my dissent are as follows: When arraigned on September 4, 1956, Martinez was represented by counsel. This was known to the trial judge and to the prosecutor. It was a matter of record. Thereafter, the record shows, the district attorney's office had certain negotiations with the lawyer for Martinez. Sometime later the district attorney's office was "contacted" by the wife of Martinez and "received a message" which, if written, was never produced, that Martinez desired to plead guilty. The wife denied getting in touch with the district attorney. At any rate, the district attorney sent his chief investigator to interview Martinez to ascertain if the latter desired to plead guilty. The attorney for Martinez was not present at, nor was he notified of, that interview. Thereafter, the district attorney ordered the sheriff to produce Martinez in court. Counsel for Martinez was not notified of this hearing. Before the court session started the prosecutor interviewed Martinez and, among other things, asked him if he wanted to discharge his attorney.
 All of this was, of course, highly improper. The propriety of the prosecuting officials thus communicating with an accused, and questioning him, without his lawyer being present, when they knew that he had a lawyer, was improper. In civil litigation it would be a serious breach of ethics for a lawyer representing one side of a case to communicate and question the adverse party without at least notification to the lawyer for the adverse party. This rule applies with even greater vigor to a criminal case.
 Independently of this invasion of the rights of Martinez, there were other violations of his constitutional rights of an even more serious nature.
 On October 9, 1956, when Martinez was brought into court and stated that he was willing to proceed without counsel, as already pointed out, his attorney was not notified. The record shows that the trial court and the prosecutor were then *817 fully aware of the fact that Martinez had a lawyer. But, in spite of this fact, Martinez, without counsel, was permitted to withdraw his plea of not guilty, to enter a plea of guilty, to admit being armed with a deadly weapon, to waive a pre-sentence report, to waive time for sentencing and to agree that judgment should be immediately pronounced against him.
 The majority holds that because the evidence produced before the referee shows that Martinez waived his constitutional right to counsel, and understood what he was doing at the hearing on October 9th, his right to counsel was not interfered with, and that the failure to comply with sections 284 and 285 of the Code of Civil Procedure was a mere procedural error not warranting the issue of the writ of habeas corpus.
 This reasoning disregards one of the obvious purposes and intents of the two code sections. The Constitution of this state (art. I,  13) grants to an accused the right "to appear and defend, in person and with counsel." Thus, an accused has an undoubted constitutional right to appear without counsel, and to waive his right to counsel. But such accused also has the right to appear by counsel. The Legislature, in aid of that constitutional right, has provided that once counsel has been appointed he may be removed only as provided in sections 284 and 285 of the Code of Civil Procedure.  [fn. 1] Section 284 requires a consent by client and counsel filed with the clerk or an order of court after notice to the client and counsel. Until these sections are complied with petitioner remained the attorney of record and it was error to permit Martinez to proceed in person. (People v. Merkouris, 46 Cal.2d 540, 554 [297 P.2d 999].) The sections are not intended simply to protect the lawyer from being replaced without being heard, but are also aimed at protecting the rights of the accused. The framers of our Constitution saw fit to grant the right to counsel to those accused of crime. In implementing that right the Legislature saw fit to provide that, once counsel has been secured, such counsel cannot be removed except as provided in section 284. This is to protect an accused, a layman, from making legal decisions affecting his freedom, without the opportunity of chosen counsel being there and advising him not only of his legal rights, but of the result of his waiver of such rights. It is to protect an accused who is represented *818 by counsel from the possibility of duress and pressure being exerted by the court or by the prosecution. It is to protect an accused who has counsel from forfeiting the protection of legal advice except as provided in the code section.
 This basic error was aggravated by the failure of the court to comply with the provisions of section 1018 of the Penal Code. Even if the right to have counsel present was waived, this section was not complied with. The majority correctly holds that when Martinez is supposed to have waived his right to counsel, the court did not "fully inform him of his right to counsel" as required by the section. Thus, at the very time he was pleading guilty he was not only permitted to do so without his lawyer being present, but was not then told of his right to counsel, even though he then had a lawyer. Nor was a finding made, as required by the section, that "defendant understands his right to counsel and freely waives it." The majority correctly points out that the "court made no inquiry to discover whether Martinez had the experience and mental capacity to understand his rights or to determine whether his decision was the result of an intelligent choice freely made by him or of improper influences theretofore brought to bear upon him. ... Thus there is nothing in the record to suggest an awareness of the statutory requirement, let alone an attempt to comply with it."
 It was for these very reasons, that is, to protect an accused even from himself, that the three code sections were passed.
 It has heretofore been held in In re Breen, 162 Cal.App.2d 235 [328 P.2d 465], and In re Brain, 70 Cal.App. 334 [233 P. 390], that convictions must be set aside where other provisions of section 1018 of the Penal Code have not been followed. The majority recognizes that those two cases are direct authority for the issuance of the writ in the instant case. In order to avoid the rule of these cases, they are "disapproved." I think that those cases were correctly decided. The basic theory behind them is that the Legislature by section 1018, and also in sections 284 and 285, has seen fit to provide certain safeguards to protect one who waives counsel or purports to discharge his attorney. These safeguards are legislative implementations of the constitutional provision. The Legislature determined that these safeguards were necessary to protect those accused of crime. It is not for this court to say that such safeguards are merely "procedural" and may be disregarded. *819
 As already pointed out, the majority admits that error was committed in the present case. The implication is that, had defendant appealed, the error would require a reversal. But such error, it is held, does not require the issuance of the writ of habeas corpus.
 How could the accused appeal in the present case? Without being properly informed of his rights, he purported to discharge his counsel and to plead guilty. He did not know that he had been deprived of his statutory and constitutional rights until long after his time for appeal had passed. By permitting him to discharge his counsel illegally, the court deprived him of legal advice about an appeal at the very time he needed such advice.
 I think that the writ of habeas corpus should issue.
 "1. Upon the consent of both client and attorney, filed with the clerk, or entered upon the minutes;"
 "2. Upon the order of the court, upon the application of either client or attorney, after notice from one to the other. ..."
NOTES
[fn. 1]  1. "The attorney in an action or special proceeding may be changed at any time before or after judgment or final determination, as follows:
[fn. 2]  2. "When an attorney is changed, as provided in the last section, written notice of the change and of the substitution of a new attorney, or of the appearance of the party in person, must be given to the adverse party. Until then he must recognize the former attorney."
[fn. 3]  3. "Unless otherwise provided by law every plea must be put in by the defendant himself in open court. No plea of guilty of a felony for which the maximum punishment is death, or life imprisonment without the possibility of parole, shall be received from a defendant who does not appear with counsel, nor shall any plea of guilty of any other felony be accepted from any defendant who does not appear with counsel unless the court shall first fully inform him of his right to counsel and unless the court shall find that the defendant understands his right to counsel and freely waives it and then, only if the defendant has expressly stated in open court, to the court, that he does not wish to be represented by counsel. ..."
[fn. 1]  1. These sections clearly apply to criminal cases. (People v. Bouchard, 49 Cal.2d 438, 440 [317 P.2d 971]; Code Civ. Proc.,  22 and 24.)
