Skip to content

getJobString Refactor - AbstractTest Class #3

@icr8FreeCode

Description

@icr8FreeCode

Code readability
The following code is hard to read and maintain. It should used functional design with single responsibility principles to clean up the logic and flow of the method calls. Additionally, String.format ( ) can be a function call and abstracted from the getJobString() and called withing each method.

protected String
getJobString (Job job)
     throws NoSuchMethodException, ClassNotFoundException,
       InvocationTargetException, IllegalAccessException, NoSuchFieldException
     {
       return String.format ("%nID: %d%n" +
			     "Name: %s\n" +
			     "Name: %s%n" +
			     "Employer: %s\n" +
			     "Employer: %s%n" +
			     "Location: %s\n" +
			     "Location: %s%n" +
			     "Position Type: %s\n" +
			     "Position Type: %s%n" +
			     "Core Competency: %s\n",
			     getJobId (job),
			     getJobFieldString (job,"name",true),
			     getJobFieldString (job,"employer",true),
			     getJobFieldString (job,"location",true),

			     "Core Competency: %s%n",getJobId (job),

			     getJobFieldString (job,"name",true),
			     getJobFieldString (job,"employer",true),
			     getJobFieldString (job,"location",true),
			     getJobFieldString (job,"positionType",true),
			     getJobFieldString (job, "coreCompetency", true));
			     getJobFieldString (job, "positionType", true),
	  		     getJobFieldString (job, "coreCompetency", true));
     }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions