Page 1 of 1

About Question enthuware.ocpjp.v7.2.1177 :

Posted: Thu Apr 25, 2013 4:03 pm
by jklb
I used the "Head First Design Patterns" by Freeman, Sierra and Bates to prepare for the exam and in Chapter 9 they introduce single responsibility along with the Composite pattern. For example, the composite pattern helps deal with the problem of needing to deal with two responsibilities: handling aggregation and handling iteration.

I didn't select DAO or Composition, so I was really off-base, but I did some more researching when I was reviewing answers and now believe Composition is the correct answer.

Re: About Question enthuware.ocpjp.v7.2.1177 :

Posted: Sat Apr 27, 2013 7:24 am
by admin
I don't know about what other book says but composite pattern actually violates the single responsibility principle. The question asks you to select a pattern that illustrates this principle so composite is not the right answer.

HTH,
Paul

Re: About Question enthuware.ocpjp.v7.2.1177 :

Posted: Sun Sep 15, 2013 2:35 am
by The_Nick
Hi everyone,

What about the Factory Pattern?
Isn't that single responsability too? it just creates entities.

Thanks in advance.

The_Nick.

Re: About Question enthuware.ocpjp.v7.2.1177 :

Posted: Sun Sep 15, 2013 5:54 am
by admin
Tangentially, yes. That way, even Singleton has only one responsibility i.e. to make sure there is only instance of a class. But I do not think these are appropriate choices because that is not their primary objective. Of course, it can be quite subjective.

HTH,
Paul.

Re: About Question enthuware.ocpjp.v7.2.1177 :

Posted: Tue Oct 08, 2013 1:58 pm
by Student
According to wikipedia (no sniggering)

"In object-oriented programming, the single responsibility principle states that every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class".

Also (http://www.oodesign.com/single-responsi ... ciple.html):

"This principle states that if we have 2 reasons to change for a class, we have to split the functionality in two classes. Each class will handle only one responsibility and on future if we need to make one change we are going to make it in the class which handle it. When we need to make a change in a class having more responsibilities the change might affect the other functionality of the classes."

Therefore it would appear this is a principle that should be applied to all classes i.e. it's a foundational OO programming principle, and not something that is the province of any particular pattern.
Humbly,
Student

Re: About Question enthuware.ocpjp.v7.2.1177 :

Posted: Tue Oct 08, 2013 2:46 pm
by admin
Please see the discussion above. As mentioned above, it is quite subjective. So no matter what you believe, there will be contradicting opinions. So our suggestion is to go with the most reasonable answers without trying to split hair because in the exam you will not be given space to write your arguments about why you think an option is correct or incorrect. You have to pick the one that will be evaluated as correct :)

HTH,
Paul.