I am trying to write my own Game of Life, with my own set of rules. First 'concept', which I would like to apply, is socialization (which basicaly means if the cell wants to be alone or in a group with other cells). Data structure is 2-dimensional array (for now).
In order to be able to move a cell to/away from a group of another cells,...
How do we identify when to use dependency injection or singleton pattern.
I have read in lot of websites where they say "Use Dependency injection over singleton pattern". But I am not sure if I totally agree with them. For my small or medium scale projects I definitely see the use of singleton pattern straightforward.
For example Logger...
I have a circular dependency in my code, and I'm not sure how to resolve it.
I am developing a game. A NPC has three components, responsible for thinking, sensing, and acting. These components need access to the NPC controller to get access to its model, but the controller needs these components to do anything. Thus, both take each oth...
Hi,
I am using Factory pattern to create .NET objects of a class. I also need to make sure that all such objects should be disposed before application terminates.
Where and How can I dispose the objects created by factory pattern? Shall I dispose in the class in which I am getting the objects created by factory?
...
Background:
My organization uses Microsoft .Net (3.5) with SQL Server 2005 as back end.
With RAD being the norm and Agile being the widely used process. I have always found using design patterns difficult since it involves a bit more understanding and bit more training.
Can you give me some examples where design patterns have solved r...
Sorry for bad English :(
Suppose i can preliminary organize recipes and ingredients data in any way.
How can i effectively conduct search of recipes by user-provided ingredients, preferably sorted by max match - so, first going recipes that use maximum of provided ingridients and do not contain any other ingrs, after them recipes that u...
Hello
I am thinking through a nice pattern to be useful across domains of measurable units (ie, Length, Time) and came up with the following use case and initial classes, and of course, questions!
1) Does a Composite pattern help or complicate?
2) Should the Convert method(s) in the ComposityNode be a separate converter class?
All c...
Problem Statement - Would like to know if particular web app user is active (i.e. logged in and using site) and be able to query for list of active users or determine a user's activity status.
Constraints - Doesn't need to be exact (i.e. if a user was active within a certain timeframe, that's ok to say that they're active even if they'v...
There are certain tables that get called often but updated rarely. One of these tables is Departments. So to save DB trips, I think it is ok to cache this table taking into consideration that the table has very small size. However, once you cached it an issue of keeping the table data fresh occurs. So what is the best way to determine th...
I'm developing a game. Each entity in the game is a GameObject. Each GameObject is composed of a GameObjectController, GameObjectModel, and GameObjectView. (Or inheritants thereof.)
For NPCs, the GameObjectController is split into:
IThinkNPC: reads current state and makes a decision about what to do
IActNPC: updates state based on wha...
Diagram.net is good diagramming tool.
I need to understand what design patterns are used by this tool so that I can understand how it works.
What design patterns are used in this tool?
What design patterns are generally used for diagramming tools?
I would also like to know how can I use this to develop very simple diagramming tool (...
I have a multi-user software solution (containing different applications, i.e. EXEs) that should allow only a limited number of concurrent users. It's designed to run in an intranet. I don't have a really good, satisfactory solution to the problem of counting the client licenses yet. The key requirements are:
When users start any appli...
What is the name of that kind of structure?
Or where can I read about that.
class A : public B < A > { ... }
...
Hello,
I was wondering what would be the best way to implement some kind of "drag n drop" user interface?
What i mean is that there would be one main page and every link click (eg. other sections like about, gallery, contact form) would open a new drag n drop element on top of that main page. Something like windows desktop where you ca...
Thinking about service orientation, our team are involved on new application designs. We consist in a group of 4 developers
and a manager (that knows something about programming and distributed systems). Each one, having own opinion on service design.
It consists in a distributed system: a user interface (web app) accessing the services...
I've been reading about these and they're pretty prominent in the .NET world. Why aren't there any web frameworks that implement any of these patterns in Ruby, Python, or PHP? Is it because it only works with component-based frameworks, like ASP.NET? Or are they just slow to adopt it?
...
Attached is a classic Decorator pattern. My question is how would you modify the below code so that you can wrap zero or one of each topping on to the Pizza
Right now I can have a Pepporini -> Sausage --> Pepporini --> Pizza class driving the total cost up to $10, charging twice for Pepporini.
I don't think I want to use the Chain of ...
Should factories persist entities they build? Or is that the job of the caller? Pseudo Example Incoming:
public class OrderFactory
{
public Order Build()
{
var order = new Order();
....
return order;
}
}
public class OrderController : Controller
{
public OrderController(IReposit...
A scene like this:
I've different of objects do the similar operation as respective func() implements.
There're 2 kinds of solution for func_manager() to call func() according to different objects
Solution 1: Use virtual function character specified in c++. func_manager works differently accroding to different object point pass in.
...
Consider this scenario. I have some business logic that now and then will be required to write to a log.
interface ILogger
{
void Log(string stuff);
}
interface IDependency
{
string GetInfo();
}
class MyBusinessObject
{
private IDependency _dependency;
public MyBusinessObject(IDependency dependency)
{
_de...