|
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
(parameters passed in) for all strategies. The problem with the
second way is that there is no...
|
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 think the solution is somewhere on casting to
original type (PriceRuleForRegion) but I don't how I...
|
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 of the books (ie. Interfaces, Abstract classes) don't
really apply to Python per say, but the idea...
|
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;
};
|
by: ltruett |
last post by:
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
|
|
by: Peter Kirk |
last post by:
Hi
i have a string variable which can take one of a set of many values.
Depending on the value I need to take different (but related) actions. So I
have a big if/else-if construct - but what is a better way of doing this?
if ("control" == commandString)
{
}
else if ("execute" == commandString)
|
by: |
last post by:
Is it fine to call another method from Switch?
Eg.
Switch (stringVar)
{
case ("a"):
somVar = "whatever";
Another_Method(); //call another method
return;
|
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 people in the room, there is a $10 charge per
persons over 2, if they add an extra bed, and the room...
|
by: George Sakkis |
last post by:
I have a situation where one class can be customized with several
orthogonal options. Currently this is implemented with (multiple)
inheritance but this leads to combinatorial explosion of subclasses as
more orthogonal features are added. Naturally, the decorator pattern
comes to mind (not to be confused with the the Python meaning of
the term "decorator").
However, there is a twist. In the standard decorator pattern, the
decorator...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
|