So, I have a list of base class pointers:
list<Base*> stuff;
Then, at some point one of the objects will look through all other objects.
Base * obj = ...; // A pointer from the 'stuff'-list.
for (list<Base*>::iterator it = stuff.begin(); it != stuff.end(); it++)
{
if (obj == *it)
continue;
// Problem scenario is here...
I am writing a class (Foo) which, when instantiated, can be called from multiple threads.
Most methods of the Foo class can safely be called by multiple threads in parallel. One method of this class (logout()), requires that all other threads are done.
Before logout is called, the reference to foo is deleted from a thread-safe collect...
I have been reading Robert C. Martin's (aka Uncle Bob) books very intensely as of late. I have found a lot of the things he talks about to be real life savers for me (small function size, very descriptive names for things, etc).
The one problem I haven't gotten past yet is code coupling. One problem I keep having over and over is that ...
I have a scenario whereby I want n amount of classes to look at the same data and decide if any work needs to be done. Work is done by a team, and multiple teams can work on the data at the same time. I was thinking of creating a class for every team that would implement the CreateWork interface. All CreateWork classes must have their sa...
What good resources are out there for learning Design patterns in C# and the .NET Framework?
...
In class library I am currently working on, I need to implement a mechanism in which class users will get hold of an item by operating on an Issuer class:
class Issuer {
public Item GetItem () {
return queue.Pop ();
}
}
//at some other place
var item = issuer.GetItem ();
//work on item and submit back to Issuer
How ca...
I know how all those patterns work separately, I have read some Martin Fowler articles and books. The problem is that I can find only separate different implementations of each of these patterns but I still haven't found some reference architecture diagram (UML or other) which I could use as a starting point to develop a prototype for an...
I've started looking into architecturing a javascript framework.
I don't want to reinvent the wheel here, especially regarding browser quirks, and know that for that matter, I'll have to rely, at some point, on some commonly-used libraries to handle low-level concerns.
The thing is, I'm not sure how i can depend on an external libr...
I'm having a difficult time finding any resources that describe good UI patterns for large search forms. I have a form that requires 20+ possible inputs and can't come up with a design I feel good about (although in my defense I'm no design expert). In my case I'm looking for a web solution, but I imagine a UI-patter for this scenario is...
I have a set of interfaces which are used in close conjunction with particular mutable object.
Many users of the object only need the ability to read values from the object, and then only a few properties. To avoid namespace pollution (easier intellisense) and to get across the usage intent, I'd like to have a small base interface whic...
This might be more of a philosophical debate, but here is what I have:
Two controls which share a Javascript resource library to call a webservice.
They are ususally used in conjunction with each other, but not always.
The javacsript file they both reference is not easily separated.
The javascript file should not be added to every pa...
I have a problem with deciding about class responsibilities.
I have 3 html-forms:
For each form there is a html template containing some text and a marker for the form to be included
Each form needs to be validated, if there is an error the template and the form from (1) needs to redisplayed, together with some error messages. Only som...
I'm trying to find out what the best way would be to have a specification pattern in PHP where the specifications could (optionally) by transformed to PHP.
I am exploring some new directions and am testing how well they would work. Code and ideas are still very unclear in my mind.
Minimal interfaces would be like these:
interface IRep...
I'm developing an app that will talk with a web service exposing multiple methods. I'm trying to figure out what the best pattern would be to centralize the access to the web service, give options for synchronous and asynchronous access, and return data to clients. Has anybody tackled this problem yet?
One class for all methods seems ...
This is the scenario: I have a huge code-base written in .NET 2.0...and sometime back the migration happened to .NET 3.5.
This code-base is both refactored and enhanced as an ongoing maintenance project. I am looking for patterns to identify in code base which are good candidates for LINQ to Objects.
I need pointers for comprehensive a...
Here is the problem, lets say we are making a video game and want to use Dependency Injection. Here is what we have:
Game Class // This is just the code to keep track of the overall game logic
Character Class // This would be the guys in the game, good and bad guys both
Weapon Class // The weapons for the characters
So normally when ...
Hi there, i want to create an abstract representation of an existing object. For this example i want to wrap the functionality of a System.Windows.Forms.TreeNode. I started by creating an adapter as follows...
Edit : The purpose of the abstraction will allow me to use the ITreeNodeAdapter in my application without knowing about the Tr...
I am sure there is a clever way to handle this, but I just can't get it right in my head. Here is the scenario:
I have a base class with about 30 properties. Say that I have a property on this class called Type. For a subset of the instances of this class, I want to add a few more properties based on the Type property. In this case...
I know there has been much shout about the goodness of MVC pattern.
My question is that is there any pattern better than MVC to be
implemented in PHP?
I don't know but other pattern might have advantages over the MVC pattern.
So actually I am in search whether there is something better than MVC.
Thanks in advance.
...
Base Class B
|
|
----
| |
| |
D1 D2
public static object GetDerivedClass(Type t1, MyProcess p1)
{
DerivedClass D1 = null;
DerivedClass D2 = null;
if (t1 is typeof(Derived)
{
Process(D1,p1);
return D1;
}
else if(t1 is typeof(Derived)
{
...