• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Questions

 
Lorenzo Ascurbico
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,

i'm new to the forum and i'm going to take the Architect exam in the near future.

I'm just starting to study using the available books ( OCM Java EE 6 Enterprise Architect Exam Guide (Exams 1Z0-807, 1Z0-865 & 1Z0-866), Sun Certified Enterprise Architect For Java EE Study Guide).

I'd ask you info on some questions. Hope someone can help me.

Let's start:

About strategy pattern which is/are an objective/s ?

Thanks a lot.
 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

So what is the strategy pattern? According to Gang of 4 (GOF) strategy pattern's intent is:
* Define a family of algorithms, encapsulate each one, and make them interchangeable
* Let the algorithm vary independently from clients that use it

Can you think of examples when to use the strategy pattern?
 
Lorenzo Ascurbico
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On a note document i found:

Strategy
• Many related classes differ only in their behavior. Strategies provide a way to configure a class with one of many behaviors.
• You need different variants of an algorithm. For example, you might define algorithms reflecting different space/time trade-offs.
• An algorithm uses data that clients shouldn't know about. Use the Strategy pattern to avoid exposing complex, algorithm-specific data structures.
• A class defines many behaviors, and these appear as multiple conditional statements in its operations. Instead of many conditionals, move related conditional branches into their own Strategy class.


so even "any related classes differ only in their behavior. Strategies provide a way to configure a class with one of many behaviors." is an objective ?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic