473,587 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

the Strategy Pattern in PHP 5

I'm almost done my series of design patterns using PHP 5. Today's
pattern is the Strategy Pattern.

http://www.fluffycat.com/PHP-Design-Patterns/Strategy/

In the Stratedy Pattern a "family of algorythms" is used interchangably
by calling clients.

This is the second pattern in as many days as I've used my older work
with patterns in Java, and again I liked the old example when I first
looked at it, but now I wonder about it. In this example the context
is passed a parameter at instantiation, and the context then chooses a
concrete strategy which it hold on to for every time it needs a
strategy. This means that the calling client would need to call the
appropriate context. Not sure if this is the real intent here, might
have to revisit this one...

Aug 29 '06 #1
0 1355

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3249
by: syncman | last post by:
I think there are 2 options for how to implement the Strategy pattern. One is to use polymorphism; derived classes have the same interface and can be plugged in. The other is to use templates: Instantiate the class, passing in a functor (algorithm). Code samples below. The problem with the first way is that the interface must be the same...
5
1919
by: Ben Jeurissen | last post by:
Hello, I have to deal with the following issue in C++: Two threads are started from the main thread, both capturing images from a different firewire camera. Both threads take shots of 460800 bytes at a rate of 30 frames per second. This works fine, without frame loss, and I can display the two framestreams on screen. Now I would like...
2
1792
by: philippe sillon | last post by:
Hi, I have a problem to implemente the strategy pattern. the problem come from that a method take different arguments type (object in interface and String / Int in implemented class). When price3 instance call getPrice, the method invoked is the one of PriceRule abstract class. But, I want to invoke the method of PriceruleForRegion. So I...
6
4696
by: Daniel Santa Cruz | last post by:
Hello all, I've been trying to go over my OO Patterns book, and I decided to try to implement them in Python this time around. I figured this would help me learn the language better. Well, I've gotten stuck with my first go at OO patterns with Python. I guess it goes without say that some of the stuff that are taken for granted in most...
5
2063
by: pythoncurious | last post by:
Hi python experts In C++ I can do something like this: class Base { public: void f() { this->f_(); } private: virtual void f_() = 0; };
1
2485
by: Nick | last post by:
Hi, I read somewhere recently that the strategy pattern could be used instead of using switch command on an enum (for example). How would this work? A small example would be great. Thanks, Nick
8
2147
by: CK | last post by:
Good Morning All, I am writing an app to calculate the cost of a hotel room. I am new to c++. I have decided to try using the Strategy Design Pattern. I want a superclass HotelRoom, and then make 3 classes that inherit from it. SuiteRoom, StandardRoom, and DeluxeRoom. The price of the room is based on 3 factors, if there is are more then 2...
3
1468
by: Mike TI | last post by:
Aug 2, 2007 12:00pm Hi all I have to design and program an application which will be used in three countries. It would be a fairly large application with lot of data entry. The database hence has to be consolidated and at one location. Now the internet is excellent in one country and reasonable in the other
8
2756
by: Slaunger | last post by:
Hi all, I am a Python novice, and I have run into a problem in a project I am working on, which boils down to identifying the patterns in a sequence of integers, for example ..... 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 1 6 6 1 6 6 1 6 6 1 6 6...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.