Symmetry
def publish_test_report(test_results) create_report_directory @formatter.generate_report(test_results) upload_report end
class SymmetricalPublisher def publish_rest_report(test_results) create_report_directory generate_report(test_results) upload_report end def generate_report(test_results) @formatter.generate_report(test_results) end
V Ruby můžeme zajít ještě mnohem dále.
class ConcisePublisher extend Forwardable def_delegators :@formatter, :generate_report def publish_test_report(test_results) create_report_directory generate_report(test_results) upload_report end
Reversing Method
Příklad špatného kódu
class SillyPublisher extend Forwardable def_delegators :@formatter, :create_report_directory, :generate_report, :upload_report def publish_test_report(test_results) create_report_directory generate_report(test_results) upload_report end