Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5062

Extract private method in EncounterServiceImpl.saveEncounter

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Could
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Core 2.2.0
    • Component/s: None
    • Labels:
    • Complexity:
      Low

      Description

      To reduce the complexity, increase readability and maintainability in

      EncounterServiceImple.saveEncounter(Encounter)

      I suggest to extract related parts into smaller private methods, with longer meaningful names:

      https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/impl/EncounterServiceImpl.java#L96-L100 into

      failIfDeniedToEdit(Encounter)
      

      https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/impl/EncounterServiceImpl.java#L102-L116 into

      createVisitForNewEncounter(Encounter)
      

      https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/impl/EncounterServiceImpl.java#L123-L129 into

      requirePrivilege(Encounter)
      

      and move the temp variables

      https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/api/impl/EncounterServiceImpl.java#L119-L122

      close to where they are actually used.

      Keep the private methods in order of their execution and right after the method saveEncounter.

      And only extract the private methods without refactoring them as well in order to ease code review and reduce risk of breaking the code. If you have an idea on how to improve the private methods later on submit another PR.

        Attachments

          Activity

            People

            Assignee:
            tahira Tahira Niazi
            Reporter:
            teleivo Ivo Ulrich
            Designated Committer:
            Suthagar Kailayapathy
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 hour
                1h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h