Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#10 closed task (released)

Refactor source code for readability

Reported by: ibboard Owned by: ibboard
Priority: major Milestone:
Component: General/Unknown Version:
Keywords: Cc:
Blocked By: Blocking:

Description

Some functions are very long and complex. Short methods are cleaner code and cleaner code is easier to read, understand and modify. Where possible methods should be refactored to smaller methods.

Change History (17)

comment:1 Changed 11 years ago by ibboard

Status: newaccepted

comment:2 Changed 11 years ago by ibboard

Type: enhancementtask

comment:3 Changed 11 years ago by ibboard

(In r19) Re #10 - Refactor for readability

  • Refactor out repeated number parsing in to a separate method

comment:4 Changed 11 years ago by ibboard

(In r20) Re #11 - Documentation

  • Document Stats and SystemStats at class level to explain the difference
  • Document WarFoundryXmlFactory at class level

Re #13 - XPath for XML loading

  • Load categories using XPath - needs fixing so we can do a proper "categories/cat" query

Re #10 - Refactoring for readability

  • Fix method signature for getting number from attribute added in r19
  • Refactor more code in to GetExtraData method
  • Separate out loading of categories for GameSystem

comment:5 Changed 11 years ago by ibboard

(In r27) Closes #21 - File loading in order

  • Reworked LoadFiles to smaller methods for readability (also re #10) and structure
  • Now determine expected load return before loading then load all "expected GameSystem" before "expected Race"
  • Make "can load as race/game system/army" methods public in interface

Re #22 - Get errored file loading

  • Created FileLoadFailure class and made LoadFiles return a list of them

Also

  • Some code cleanup
  • Change to DictionaryUtils calls

comment:6 Changed 11 years ago by ibboard

(In r41) Re #10 and re #11 - Refactor code and document code

  • Split LoadFile method out in to smaller methods
  • Document possible exception from IWarFoundryFactory object loading method
  • Catch exception in WarFoundryLoader file loading

comment:7 Changed 11 years ago by ibboard

(In r72) Re #10 - Code refactoring

  • Remove unused attribute

comment:8 Changed 11 years ago by ibboard

(In r83) Re #50 - Complete loading of XML files

  • Load base points
  • Check category exists when loaded

Re #10 - Refactor source code for readability

  • Rearrange some methods
  • Move storing "extra data" in to a method

comment:9 Changed 11 years ago by ibboard

(In r84) Re #10 - Refactor source code for readability

  • Add SelectSingleElement method that checks type and casts return as XmlElement

Also:

  • Delete code to staged load Army and add TODO

comment:10 Changed 11 years ago by ibboard

(In r85) Re #10 - Refactor for readability

  • Re-order methods so that they are in the correct order to read the code from top to bottom
  • Reduce visibility of methods where possible
  • Make use of XMLTools class
  • Refactor "can complete loading" checks in to single method

comment:11 Changed 11 years ago by ibboard

(In r87) Re #10 - Refactor for readability

  • Break WarFoundryXMLFactory out in to GameSystem, Race and Army factories
  • Create factory utils classes with methods from WarFoundryXMLFactory for getting node lists etc

comment:12 Changed 11 years ago by ibboard

(In r131) Re #10 - Refactoring for readability

  • Remove "trainwreck code" by making Unit and UnitType publish methods to get arrays of stats
  • Remove "trainwreck code" by making Unit, UnitType and Stats publish methods to get value of one stat
  • Make factory use new methods

comment:13 Changed 11 years ago by ibboard

(In r132) Re #10 (Code readability) and Re #86 (Complete GTK# GUI):

  • Update UnitDisplayWidget to use new way of getting unit stats

comment:14 Changed 10 years ago by ibboard

Resolution: fixed
Status: acceptedclosed

Most code is now fairly readable. Further improvements will generally be made while working on the code for other tickets.

comment:15 Changed 10 years ago by ibboard

released: 1

Mark released changes as released

comment:16 Changed 10 years ago by ibboard

released: 1yes

Mark released fixes as released using radio values

comment:17 Changed 10 years ago by ibboard

Resolution: fixedreleased

Mark fix as released under a previous version

Note: See TracTickets for help on using tickets.