Skip to content
This repository has been archived by the owner on Dec 11, 2018. It is now read-only.

Feature/validation #29

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

Conversation

hespoz
Copy link

@hespoz hespoz commented Mar 30, 2018

Hi @rogervinas I have refactored the ValidateUtils to make it easy to extend and mock. Is not a static class anymore.

@hespoz
Copy link
Author

hespoz commented Apr 4, 2018

Hi @rogervinas my changes are in the last commit. I tag you in the commit but apparently github did not notify to you(Sorry I am more a gitlab guy). If you have any doubt just tell me. Bests


public TweetService(EntityManager entityManager, MetricWriter metricWriter) {
this.entityManager = entityManager;
this.metricWriter = metricWriter;
tweetValidationUtils = new TweetValidationUtils();

Choose a reason for hiding this comment

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

Hi @hespoz I see now why do you have doubts about making this static or not static. Why haven't you injected here a TweetValidation instance from the spring context same way you have injected an EntityManager or a MetricWriter.
This way the TweetService is decoupled from the concrete implementation of TweetValidation, and at test time it can be mocked.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @rogervinas thats fair, actually I did not think about, but your approach make sense. I always create static classes for Mappers and Validations, because the memory reason I gave last thursday, but for sure I will rethink things hahahahah.

Copy link
Author

Choose a reason for hiding this comment

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

@rogervinas regarding the injection of TweetValidationUtils, agree with you, we should leverage the IoC that spring or other frameworks offer to us. Just did not think about it when fix it.

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

Successfully merging this pull request may close these issues.

2 participants