Scenario: I have the following defined classes.
class Baseclass { };
class DerivedTypeA : public Baseclass { };
class DerivedTypeB : public Baseclass { };
// ... and so on ...
class Container
{
list<Baseclass*> stuff;
list<DerivedTypeA*> specific_stuff;
// ... initializing constructors and so on ...
public:
void add(Basecla...
Imagine you have a class with dozens of private member variables. Each member variable has a public getter and a setter function:
class Foo
{
public:
int GetA() const { return m_a; }
:
int GetZ() const { return m_z; }
void SetA(int val) { m_a = val; }
:
void SetZ(int val) { m_z = val; }
private:
int m_a;...
If a class implements a singleton pattern, should all the variables be declared static?
Is there any reason they shouldn't be declared static? Does it make a difference?
...
I may have made some poor design choices on this one. I have several objects being instanced like this.
core.modules.trial = function(sandbox){
return{
alert_private : function(){
alert(omgpi);
}
};
};
I would like to do this:
core.modules.trial[omgpi] = "external private var";
var trial = core.modules.trial...
say you have to interpret a sting of command arguments like AABBCDEEFF... and the idea is that each character represents a command for which you have to take some actions on the class, the ugly solution is to write a big switch-case but i dont want to use that , can anybody suggest a more elegant solution ??
...
I'm developing a puzzle game application - watch on youtube - for iPhone, and the actual "in-game" part is almost done. It is a separate Class (subclass of UIView) what initializes with a puzzle clue, puzzle pieces, and is ready to send a message for somebody if the puzzle has solved ("completeness" check invoked on every touchesEnded).
...
I'm wondering what the recommended approach is for dealing with relational data with the IRepository pattern.
My database has the following tables with column names in parenthesis:
Plans (PlanId, Name, CreationDate,
ModifiedDate, ViewId)
Areas (AreaId, Name, nTop, nLeft,
nRight, nBottom)
Views (ViewId, nTop, nLeft, nRight,
nBottom)
P...
Hi,
I have an application, where there are many forms which follow visual form inheritance.
Every form has standard delphi components as well as custom components.
Form validating functionality needs to be added. That is, A small red circle or astric image needs to be drawn next to a control, if the control's value is not valid.
This...
I am trying to understand UML diagram describing Decorator Pattern at link below
http://www.dofactory.com/Patterns/PatternDecorator.aspx
I don't understand why there is a "Aggregation" relation between Decorator and Component.
I believe it should be composition as Decorator cannot exist without the base component.
...
The MSDN Library documentation for the RequiresProvidesDirectiveProcessor class in the Microsoft.VisualStudio.TextTemplating namespace refers to a design pattern called "requires/provides". What is this design pattern?
"The abstract base class for a directive processor that defines and
implements a design pattern called
requires/...
Are there any good patterns/practices used while designing Services. I came across this post today:
http://stackoverflow.com/questions/1549743/when-to-use-the-decorator-pattern/1549771#1549771
Though I didn't completely understand but it really gives a new direction to think about designing services.
Note: This question is not any tec...
I want to have singleton class that its object is not statically created. having the following code, when I call ChromosomePool::createPool() I get the following error message :
--> ChromosomePool.h:50: undefined reference to `myga::ChromosomePool::pool' <--
Can anyone please tell me how can I solve the problem ?
class ChromosomePool ...
I'm developing basic GUI application. I have model class which counts time, I need to display this time to label in specific format. What is the right way to do it in according to MVC paradigm ? Logically I think it should be formatted in the view, but view is standard label control and implementing sub-label class seems a little bit ove...
Short summary: When you want to predefine certain instantiations of a class, is it better to create subclasses or a factory?
Problem Context
I have a view helper class MyWebserviceUrl that has a bunch of properties. It's purpose is to generate an url.
I would like to be able to have preconfigured instances of this class, so that I do...
With the rise of the nosql movement we see different options for storing objects. Are there object persistence patterns that can handle both sql and nosql backends and allow to easily switch between the two?
...
Hi guys, I would like to write code without a lot of switch, if/else, and other typical statements that would execute logic based on user input.
For example, lets say I have a Car class that I want to assemble and call Car.Run(). More importantly, lets say for the tires I have a chocie of 4 different Tire classes to choose from based o...
What pattern(s) would be good to manage multiple API's?
A scenario for using multiple API's would be a payment portal that allows clients to use different payment vendors to post transactions. So this system may need to utilize a papypal, fasttransact, x, y, or z API.
...
Hello all!
I have an asp.net mvc application with three layers:
- data layer with entities and repository (nhibernate) pattern
- service layer with services (functions), which communicates with data layer.
- ui layer with asp.net mvc application, which communicates with service layer.
The problem is that the data in my entities is diff...
How can I know that I need a facade Pattern at a point in my application development?
How can I draw the line between Facade Pattern and Template Pattern?
For example: In [this] article, we see that, int placeOrder(int CustomerID, List<BasketItem> Products) has a number of predefined steps in the algorithm. So why don't the author use ...
Although the example below exploits ExtJS, one can easily extrapolate to another framework. I am a fan of abstraction and data hiding (and OO in general); does anyone else hide data and members/functions or do you consider this attempt to be overkill?
(Note: I believe strongly that DOM IDs should almost never be hardcoded. And, thou...