Skip to content

Object Mother pattern #498

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

Closed
iluwatar opened this issue Oct 2, 2016 · 5 comments
Closed

Object Mother pattern #498

iluwatar opened this issue Oct 2, 2016 · 5 comments

Comments

@iluwatar
Copy link
Owner

iluwatar commented Oct 2, 2016

http://martinfowler.com/bliki/ObjectMother.html

@igeligel
Copy link
Contributor

igeligel commented Oct 2, 2016

Hi! Great library 👍
I want to take this one but what is the main difference to a simple factory pattern?

Since the link you shared was working with employees i have thought for something like this:

EmployeeMother mother = new EmployeeMother();
Employee heather = mother.bear(EmployeeName.HEATHER);
Employee heather = mother.bear(EmployeeName.JOHN);

where EmployeeName is an enumeration of names. Is this the right approach?

@iluwatar
Copy link
Owner Author

iluwatar commented Oct 3, 2016

@igeligel some elaboration here http://stackoverflow.com/questions/923319/what-is-an-objectmother. I'll change to labels to indicate you're working on it.

@igeligel
Copy link
Contributor

igeligel commented Oct 3, 2016

Yeah i want to work on this. I will probably code it the next days and check for a code review here then (i will announce if i think it is ready).

Edit: Thanks for the response 👍

@igeligel
Copy link
Contributor

igeligel commented Oct 4, 2016

I have made the first try. The only thing that has not worked yet is the PlantUML diagram. I will try to make this tomorrow and commit to the fork again. A code review would be appreciated :)

@iluwatar
Copy link
Owner Author

iluwatar commented Oct 6, 2016

Don't worry about the PlantUML diagram - it is still experimental and we don't check it when you make the pull request. ObjectAid diagram is the one you should generate, as per instructions here https://github.com/iluwatar/java-design-patterns/wiki/01.-How-to-contribute

iluwatar added a commit that referenced this issue Nov 26, 2016
@iluwatar iluwatar added this to the 1.14.0 milestone Nov 26, 2016
grzegorz2047 added a commit to grzegorz2047/java-design-patterns that referenced this issue Feb 13, 2017
* Initial commit of the object mother iluwatar#498

Add a simple king and queen classes which implement the behaviour of the
royalty interface. Also wrote the object mother of royalty objects which
is final so you can just call the static methods in it to create objects
with a specific state to use them fast in tests. The tests are already
created for testing the behaviour and the type of the objects which are
created by the object mother.
I also created the UML diagrams via object aid and updated the readme.

* Add PlantUML file for the UML diagram iluwatar#498

* End process logic clause has been corrected.

* Unused import removed.

* Add SonarQube.com badge

* iluwatar#502 Replaced usages of System.out with logger.

* Change name of variables in test iluwatar#498

* add entry to parent pom.xml iluwatar#498

* Fix pom.xml

* Fix pom.xml

Deleted </modules> tag because i added it one time more than neccessary

* FirstCut++

FirstCut++

* SecondCut++

SecondCut++

* App++

App++

* App

App

* checkstyle errors removed

checkstyle errors removed

* iluwatar#502 Reverted changes in composite example, due to nature of this example using logger isn't good idea

* Remove use of coveralls-maven-plugin (sonarqube.com covers this)

* iluwatar#502 Adjusted tests for logger introduction

* iluwatar#502 Introduced logging in new example

* Create presentation template

* Link Hexagonal Architecture pattern to corresponding blog entry

* Work on Hexagonal Architecture presentation

* Add new diagram

* Add presentation link to README.md

* Update App.java

The relationship between decorator and target (in the code example between Troll und SmartTroll) ist not a composition as described in the code comment lines of class App. It's a aggregation. In a composition both instances canncot live without the other one. But the target (Troll) could live without the decorator (Smart Troll). Changed "composition" to "aggregation" in the comment lines. Code lines are unchanged.
Greetings Thomas

* Review comments++

* Review comments++

* iluwatar#502 Reduced amount of information logged

* Issue iluwatar#450. First commit. Queue Based Load Leveling

* Issue iluwatar#450. Updated pom.xml

* Updated checkstyle errors.

* Updated pom.xml with maven-pmd-plugin

Added dependency "maven-pmd-plugin" to the pom file.

* Reverted pom.xml changes that are done previously.

* Fixed PMD issue.

* Decorator pattern: Improve the example

* Removed unused imports in tests

* Proxy pattern: Improve the example

* Proxy pattern: Add missing license header

* Update URM Version to 1.4.4 and regenerated all puml files

* Update license headers

* Fixed all the code changes after review

* Review comments++

* Sonar bug fixes using Yoda condition in equals expression when comparing String literal with String object.
Using try-with-resources if we use Scanner to close the underlying stream is a good practice to handle resources.
Minimal refactor.

* Sonar bug fixes using Yoda condition in equals expression when comparing String literal with String object.
Using try-with-resources if we use Scanner to close the underlying stream is a good practice to handle resources.
Minimal refactor.

* Adding initialization on demand holder idiom.

* Changing constant interface pattern with a Noninstantiable class

* Add some material for proxy presentation.

* Add presentation for Proxy pattern.

* Add link to Proxy presentation.

* Achieved milestone 1.14.0

* Set version for next development iteration

* iluwatar#525 Add link to Queue-Based Load Leveling blog

* iluwatar#525 Add link to proxy blog

* Changing code to use interfaces instead of implementations.

* Changing code to use interfaces instead of implementations.

* Reverting initialization on demand holder idiom.

* iluwatar#190 Regenerate puml files

* iluwatar#190 Rename package for Queue-Based Load Leveling pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants