Skip to content

Updated pull request #42

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 23 commits into from
Apr 4, 2015
Merged

Updated pull request #42

merged 23 commits into from
Apr 4, 2015

Conversation

joshzambales
Copy link
Contributor

Changelog:
-Split app into separate java files
-Added javadocs
-changed image url to point to iluwatar (UML diagram)
-changed setter injection to constructor injection
-Added intercepting-filter to pom.xml parent as a module
-configured intercepting-filter's pom.xml (my bad, careless mistake)
-separated buttons from button array and changed variable names for more consistent code

Considerations:
To make code more organized and neat, I've decided not to use anonymous classes anymore. Also, if possible, consider retention of FilterManager as I just followed the framework of my source and the delegation is how it manages the FilterChain.

@joshzambales joshzambales reopened this Apr 3, 2015
@@ -431,6 +437,17 @@ Behavioral patterns are concerned with algorithms and the assignment of responsi
**Applicability:** Use the Callback pattern when
* When some arbitrary synchronous or asynchronous action must be performed after execution of some defined activity.

<<<<<<< HEAD
Copy link
Owner

Choose a reason for hiding this comment

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

Remove this merge marker.

*/
public class FilterChain{
private ArrayList<Filter> filters = new ArrayList<Filter>();
private Target target;
Copy link
Owner

Choose a reason for hiding this comment

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

Style issue, make this final since it is initialized in constuctor

@iluwatar
Copy link
Owner

iluwatar commented Apr 4, 2015

Let me know when you've implemented the changes and I'll review again.

@joshzambales
Copy link
Contributor Author

I made changes according to the comments:
*Added and revised javadocs as specified
*Added access specifiers
*declared final on target as it is initialized on constructor
*replaced +- operator with String.format
*removed merge markers

@@ -497,10 +515,13 @@ The difference is the intent of the patterns. While Proxy controls access to the
* [Let’s Modify the Objects-First Approach into Design-Patterns-First](http://edu.pecinovsky.cz/papers/2006_ITiCSE_Design_Patterns_First.pdf)
* [Pattern Languages of Program Design](http://www.amazon.com/Pattern-Languages-Program-Design-Coplien/dp/0201607344/ref=sr_1_1)
* [Martin Fowler - Event Aggregator](http://martinfowler.com/eaaDev/EventAggregator.html)
* [TutorialsPoint - Intercepting Filter](http://www.tutorialspoint.com/design_pattern/intercepting_filter_pattern.htm)
* [Presentation Tier Pattern](http://www.javagyan.com/tutorials/corej2eepatterns/presentation-tier-patterns)
Copy link
Owner

Choose a reason for hiding this comment

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

Should be: Presentation Tier Patterns

@iluwatar
Copy link
Owner

iluwatar commented Apr 4, 2015

Nothing major detected, so I'm off to try to run this on my machine.

@iluwatar
Copy link
Owner

iluwatar commented Apr 4, 2015

Ok, there is one showstopper here. The Java source files have no package declaration (should be com.iluwatar) and they have wrong folder structure.

Put this declaration to each source file: package com.iluwatar; Then move all the source files under folder src/main/java/com/iluwatar. See the other projects for example.

Let me know when you have done this, and I'll review again.

@joshzambales
Copy link
Contributor Author

Fixed folder structure and added package :)

@iluwatar
Copy link
Owner

iluwatar commented Apr 4, 2015

Great! I was able to run it in Eclipse now.

iluwatar added a commit that referenced this pull request Apr 4, 2015
@iluwatar iluwatar merged commit 477d622 into iluwatar:master Apr 4, 2015
}else if(tempout[1] == null){
return "INVALID Contact Number!";
}else if(tempout[0] == null){
return "INVALID Name!";
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't know if this will violate pattern structure or filters reusability, but I would like to keep related things together.
For example OrderFilter must know that it works with input array index-field "4", and FilterChain must know that value abscence for tempout[4] is "INVALID ORDER".
I see this magic (numbers and messages) go as constants either to Filter interface, or as public static final fields in each implementation.
if (tempout[OrderFilter.INDEX] == null) { return OrderFilter.ERROR_MSG; }

And one step further (although its also can have more problem with pattern consistency):
can we move INDEX and ERROR_MSG to Filter interface as methods, so we can perform polimorfic loop on list of filters instead of if-else chain?

@iluwatar
Copy link
Owner

iluwatar commented Apr 4, 2015

Yes, the magic numbers create an itch for me too. @vehpsr could you please work on this?

@vehpsr
Copy link
Contributor

vehpsr commented Apr 4, 2015

I certanly could, but only if @joshzambales will give up on this.
I never heard about this pattern and I never professionally worked with Desctop and Swing, so I may "lead in a wrong direction"...

Another question for me is: would I allow such/additional methods, for example, in chain-of-responsibility pattern implementation?...

@iluwatar
Copy link
Owner

iluwatar commented Apr 4, 2015

Yes, the Chain is certainly similar in implementation. But AFAIK they solve different problems.

There is good discussion about this here and here. Also, Intercepting Filter is well know and documented in Core J2EE Patterns.

@iluwatar
Copy link
Owner

iluwatar commented Apr 4, 2015

Created issue #43. @joshzambales @vehpsr let me know if you want to work on it, otherwise I will take it myself.

@iluwatar
Copy link
Owner

@all-contributors please add @joshzambales for code

@allcontributors
Copy link
Contributor

@iluwatar

I've put up a pull request to add @joshzambales! 🎉

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.

3 participants