Skip to content

Dirty Flag pattern #560 #717

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

Merged
merged 10 commits into from
May 16, 2018
Merged

Dirty Flag pattern #560 #717

merged 10 commits into from
May 16, 2018

Conversation

waisuan
Copy link
Contributor

@waisuan waisuan commented Feb 19, 2018

  • Implementation of the Dirty Flag pattern

@npathai npathai self-assigned this Feb 26, 2018
@npathai
Copy link
Contributor

npathai commented Feb 26, 2018

@iluwatar I will pick up this review.

@iluwatar
Copy link
Owner

iluwatar commented Mar 4, 2018

Ok @npathai
@waisuan the pull request has conflicts that need to be resolved

@waisuan
Copy link
Contributor Author

waisuan commented Mar 4, 2018

@iluwatar Done.

@waisuan
Copy link
Contributor Author

waisuan commented Mar 4, 2018

Seems to be a JUnit test failure:-

dummyCustomerApiTest() Time elapsed: 0.052 sec <<< FAILURE!
org.opentest4j.AssertionFailedError: Counter limit must be reached ==> expected: but was:
at com.iluwatar.throttling.B2BServiceTest.dummyCustomerApiTest(B2BServiceTest.java:46)

Doesn't seem to be related to my changes here.

@iluwatar

@iluwatar
Copy link
Owner

It is a known issue #643, still unresolved

@iluwatar
Copy link
Owner

@npathai please review the PR

@npathai
Copy link
Contributor

npathai commented Mar 17, 2018

@iluwatar Yes started. Will complete today

return data;
}

return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if DataFetcher should be returning null to indicate no change in data. Any other options for this?

* @return World instance
*/
public static World getInstance() {
if (world == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Just document a warning that this is not a thread safe way to implement Singleton. Refer to Singleton for more information.

*
* @return DataFetcher instance
*/
public static DataFetcher getInstance() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: I don't understand the intent to keep World and DataFetcher singleton here. Any particular reason you chose this way?


@BeforeEach
public void reset() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Field instance = DataFetcher.class.getDeclaredField("df");
Copy link
Contributor

Choose a reason for hiding this comment

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

This singleton reset thing won't be needed if we avoid getInstance. Hence my question about Singletonness.

To avoid expensive re-acquisition of resources. The resources retain their identity, are kept in some
fast-access storage, and are re-used to avoid having to acquire them again.

![alt text](./etc/dirty-flag.png "Dirty Flag")
Copy link
Contributor

Choose a reason for hiding this comment

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

The class diagram should be made with ObjectAid eclipse plugin. More about it in wiki

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@npathai
Copy link
Contributor

npathai commented Mar 17, 2018

@waisuan You have my review comments. Overall it looks great and easy to follow. 👍 There are a few points that I have highlighted though. Awaiting your response.

@npathai
Copy link
Contributor

npathai commented Apr 23, 2018

@waisuan Any updates?

@waisuan
Copy link
Contributor Author

waisuan commented May 2, 2018

@npathai Apologies for the delay here. Been swamped. I'll take a look at your comments tonight and begin working on them accordingly. Cheers!

@waisuan
Copy link
Contributor Author

waisuan commented May 12, 2018

@npathai -- Fixes are up. Could you take another peek? Thanks!

@npathai
Copy link
Contributor

npathai commented May 13, 2018

@waisuan 👍 Surely. I will do that tomorrow.

Copy link
Contributor

@npathai npathai left a comment

Choose a reason for hiding this comment

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

There was one minor change, but lets merge this now and we can do that minor change later.

public void testIsDirty() {
DataFetcher df = new DataFetcher();
List<String> countries = df.fetch();
assertTrue(!countries.isEmpty());
Copy link
Contributor

Choose a reason for hiding this comment

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

Use assertFalse() in place of assertTrue(!condition)

@npathai npathai merged commit eddfe76 into iluwatar:master May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants