wiki:UNPLANNED_LOGIC_REFACTORING_R0

Version 6 (modified by jani, 16 years ago) (diff)

--

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=UNPLANNED_LOGIC_REFACTORING_R0, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

Analysis

Overview

This task is about refactoring the logic operations in the application. The problems related to that include (but are not limited to):

  • There are operations that do not use R3 logic.
  • There is code duplication (especially in the menu items and bound controls in HUDs).
  • There is no convention on naming the events and handlers.
  • There is no convention on placing (and grouping) the logic classes.

After this iteration there should be a convention for placing, grouping and naming events and handlers. All existing R3 logics should follow that convention. A lot of the code smells should be eliminated. There might still be old Logics (due to weekly time-boxing).

Task requirements

  • Create a convention for naming, placing and grouping EventIds, OperationDefs and entries in OperationDefs, apply it and start following it.
  • Identify and remove duplicate code.
  • (Optional) Refactor old logic classes to use LogicR3.

Task result

  • Convention for Logics, described in the design section of this page.
  • Source code

Implementation idea

  • It seems sensible that all nested ids for events should be named EventIds. Since they are accessed by the wrapper class, it is clear what event they are for. E.g. MenuItem.EventIds.CLICKED.
  • OperationDef members that handle an event might be named starting with ON_ (e.g. ON_SET_SCREEN_MODE).
  • In the MenuItem there is code duplication on the clicked method. It should become final and fire a CLICKED event.

UNPLANNED_MAIN_WINDOW_REFACTORING_R0
GROUP_BOOK_MODEL_REDESIGN_R0

How to demo

  • This is a refactoring task related to internals and will not be demonstrated.

Design

  • For the align buttons:
    • Create two abstract methods in AlignElementsButton:
      • float calculateAlignValue(List<ElementView> selected) - for a given list of element views calculates some align value, for example, the Y-axis of the top-most element.
      • ImmPoint calculateNewLocation(ImmRect bounds, float alignValue) - calculates a new location for a single element, given the old bounds and the align value, returned from the above method.
    • Replace the clicked method in all align buttons with the above methods.
    • Create AlignElementsLogic with a single handler - ON_ALIGN, which listens for CLICKED from AlignElementsButton.
      • Calculates the align value
      • Creates an immutable list of new locations
      • Creates an immutable list of references to elements. Only elements of type MemberElement are collected.
      • Creates a new AutoAction that iterates over all references and changes MemberElement.KEY_LOCATION with the newly calculated location.

Implementation

Changesets: [5628]

Testing

(Place the testing results here.)

Comments

(Write comments for this or later revisions here.)