wgy8283335 opened a new issue #2606: The implementation of "toString()" method 
of Interface "Alterable" in "TablePlaceholder" related questions?
URL: https://github.com/apache/incubator-shardingsphere/issues/2606
 
 
   ## Question
   The "toString(final RoutingUnit routingUnit, final Map<String, String> 
logicAndActualTables)" method in "TablePlaceholder". "routingUnit" is not used 
in the method definition. The "routingUnit" is useful for another two 
implementation classes : IndexPlaceHolder,InsertValuePlaceHolder. So, in order 
to keep the "Alterable" is suitable for the method caller and make the code in 
"TablePlaceHolder" more meaningful. My suggestion is below:
   original code is
   ```
       @Override
       public String toString(final RoutingUnit routingUnit, final Map<String, 
String> logicAndActualTables) {
           String actualTableName = logicAndActualTables.get(logicTableName);
           actualTableName = null == actualTableName ? logicTableName : 
actualTableName;
           return Joiner.on("").join(quoteCharacter.getStartDelimiter(), 
actualTableName, quoteCharacter.getEndDelimiter());
       }
   ```
   Then ,split the method into two pieces.
   ```
      @Override
       public String toString(final RoutingUnit routingUnit, final Map<String, 
String> logicAndActualTables) {
                toString(logicAndActualTables);
       }
   ```
   ```
   private String toString(final Map<String, String> logicAndActualTables){
           String actualTableName = logicAndActualTables.get(logicTableName);
           actualTableName = null == actualTableName ? logicTableName : 
actualTableName;
           return Joiner.on("").join(quoteCharacter.getStartDelimiter(), 
actualTableName, quoteCharacter.getEndDelimiter());
   }
   ```
   This will make clearly that the "routingUnit" is not used.And the reason why 
use it, is only for adaptable to "Alterable" Interface. 
   It is just an immature suggestion, I'd like to discuss this question with 
you.
   Thanks a lot.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to