xen-troops / displ_be

GNU General Public License v2.0
2 stars 8 forks source link

DisplayItf::Connector : wrong class design #115

Open iusyk opened 4 years ago

iusyk commented 4 years ago

Description

There are some methods that:

  1. are not necessary
  2. bring the implementation of additional code to support them
  3. require the additional try{}catch{} blocks to handle the class behavior properly

The following methods should be removed or modified

  1. release() - the sense of this method is to release the instance state, because of this, instance of class is not usable until user calls method 'init'. If it is necessary to change the state of the class instance in one transaction, it is better to use a) pattern state - implement the State class and use the method setState b) replace the method release with reset one, where reset should have the list of the parameters to activate a new class state This method MUST be replaced.

  2. isInitialized - MUST be removed because the sense if this method, to be sure, that method init has been called after release This method is the source of the following problems a) isInitialized MUST be called in all methods of the class, besides, the exception MUST be thrown if isInitialized is false b) all calls of then class methods MUST be inside of block try{}catch{} c) because of 'a' and 'b', the source code grows and class is more complicated

Solution

Redesign the class to use the State pattern or method reset.