Sub-classes use the same technology. Is it necessary to separate them into sub-classes?
This is why the decoration mode is generated.
Class mybufferreader {
Mybufferedreader (class 1 class to improve efficiency ){}
Mybufferedreader (Class 2 class to improve efficiency ){}
Mybufferedreader (Class 3 class to improve efficiency ){}
}
--------------------------------
Code A after optimization:
Class mybufferreader extends parent class {
Private parent class;
Mybufferedreader (parent class ){}
// Combination Structure
}
---------------------------------
Decoration mode, which is more flexible than inheritance; reduces the relationship between classes.
Because the decoration class enhances existing objects, it has the same functions as existing objects, but provides stronger functions. Therefore, the decoration class and the decoration class usually belong to a system.
-----------------------
Decoration class, covering the abstract methods in the reader class
Public void close (){
Class. Close ();
}
Public int read (char [] Buf, int off, int Len ){
Return R. Read (BUF, off, Len );
}
---------------------------------