Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code refactoring #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

code refactoring #22

wants to merge 3 commits into from

Conversation

hitum-dev
Copy link

refactoring from group 4

@@ -23,6 +23,109 @@
@RequestMapping("api/import")
public class ImportCSV {

class ParsedEntity {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea to create an inner class to ease parsing :)

private int pos;

/***
* contructor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this comments were not finished because of time reasons...just want to comment that a more meaning full text would help why you added this class

* @param pet
* @return
*/
public boolean deregisterPetFromOwner(Pet pet) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you kept the indentations small throughout the class :) except maybe in this class, the for-loop and three if-clauses could be eased a bit

HttpHeaders headers = new HttpHeaders();
if (matchingOwners.size() == 0) {
headers.add("errors", "Owner not found");
return new ResponseEntity<List<Pet>>(headers, HttpStatus.BAD_REQUEST);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that you return meaningful error messages

@@ -33,106 +136,62 @@
produces = "application/json")
public ResponseEntity<List<Pet>> importPets(@RequestBody String csv) {

int i = 0;
int pos = 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is maybe still a bit long...maybe you could extract some methods to create e.g., the importPets method only handles the http request, and then you have a new methods that orchestrates the parsing and then you have many small methods that to the parsing of the various fields and updating the database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants