PMSNT -- Place Methods with Same Name Together

From RAD Studio
Jump to: navigation, search

Go Up to C++ Audits


Description

Groups methods together that differ only by their parameter list. It is good practice to order from the least number of parameters to the most.

Incorrect

 class Printer {
 public:
   void print(String s) {
      ...
   }
    
   void flush() {
      ...
   }
    
   void print(char[] buf) {
      ...
   }
 };

Correct

 class Printer {
 public:
   void print(String s) {
      ...
   }
   
   void print(char[] buf) {
     ...
   }
 
   void flush() {
     ...
   }    
 };

See Also