design-patterns

C# threading pattern that will let me flush

I have a class that implements the Begin/End Invocation pattern where I initially used ThreadPool.QueueUserWorkItem() to thread my work. The work done on the thread doesn't loop but does takes a bit of time to process so the work itself is not easily stopped. I now have the side effect where someone using my class is calling the Begin (...

Design Pattern for Server Emulator

I wanna build server socket emulator, but I want implement some design pattern there. I will described my case study that I have simplified like these: My Server Socket will always listen client socket. While some request message come from the client socket, the server emulator will response the client through the socket. the response...

What do you call a generalized (non-GUI-related) "Model-View-Controller" architecture?

I am currently refactoring code that coordinates multiple hardware components for data acquisition, and feeling a bit like I'm recreating the wheel. In particular, an MVC-like pattern seems to be emerging. Except, this has nothing to do with a GUI and I'm worried that I'm forcing this particular pattern where another might be more approp...

How to make 2 incompatible types, but with the same members, interchangeable?

Yesterday 2 of the guys on our team came to me with an uncommon problem. We are using a third-party component in one of our winforms applications. All the code has already been written against it. They then wanted to incorporate another third-party component, by the same vender, into our application. To their delight they found that the ...

What is the right way to implement communication between java objects?

I'm working on an academic project which simulates a rather large queuing procedure in java. The core of the simulator rests within one package where there exist 8 classes, each one implementing a single concept. Every class in the project follows SRP. These classes encapsulate the behavior of the simulator and inter-connect every other ...

how to implement this observer pattern?

Hello. I have 4 classes, that describe state diagram. Node, Edge, ComponentOfNode, ComponentOfEdge. ComponentOfEdge compounds from ComponentsOfNode. Node can have 0..n outgoing edges. Edge can have only 2 nodes. Edge should be able to offer ComponentOfNode, but only from nodes that Edge has, in form ComponentOfEdge. The user can change...

How to "wrap" implementation in C#

Hello, I have these classes in C# (.NET Framework 3.5) described below: public class Base { public int State {get; set;} public virtual int Method1(){} public virtual string Method2(){} ... public virtual void Method10(){} } public class B: Base { // some implementation } public class Proxy: Base { private B _...

PHP Access property of a class from within a class instantiated in the original class.

I'm not certain how to explain this with the correct terms so maybe an example is the best method... $master = new MasterClass(); $master->doStuff(); class MasterClass { var $a; var $b; var $c; var $eventProccer; function MasterClass() { $this->a = 1; $this->eventProccer = new EventProcess();...

Podcasts on GoF design patterns

Anyone know of a good podcast on design patterns? ...

some confusions to singleton pattern in PHP

Hi all, In my team I've been told to write resource class like this style: class MemcacheService { private static $instance = null; private function __construct() { } public static function getInstance($fortest = false) { if (self::$instance == null) { self::$instance = new Memcach...

Is REST mandatory for MVC?

I am beginning on ASP.net MVC. All the articles I have read so far mention REST as a key feature in MVC implementation My question: is REST mandatory for MVC implementation? ...

Following Domain Driven Design with MVVM/WPF

Hello, I have plain POCO's here and as INotifyPropertyChanged is a Interface for the View's need its implemented in the ViewModel not the Model. Now I want to show validation errors in the View beside every textbox the user typed in data. I do not want to implemented the IDataErrorInfo interface in my Models because lets assume I am n...

how to call method of Owner?

Hello. I have Class1, which has methods: setSomething() createObjectOfClass2() Now, when I create object of Class2, is it possible to call setSomething method from it? ...

Advantages of Thread pooling in embedded systems

I am looking at the advantages of threadpooling design pattern in Embedded systems. I have listed few advantages, please go through them, comment and please suggest any other possible advantages that I am missing. Scalability in systems like ucos-2 where there is limit on number of threads. Increasing capability of any task when nece...

Real life examples of actionStack helper in Zend Framework

Do you know any real life examples of actionStack() action helper in Zend Framework? It seems quite a big overhead to have multiple dispatch loops. Then when it is really needed? ...

Are we using IoC effectively?

So my company uses Castle Windsor IoC container, but in a way that feels "off": All the data types are registered in code, not the config file. All data types are hard-coded to use one interface implementation. In fact, for nearly all given interfaces, there is and will only ever be one implementation. All registered data types have a ...

Design Principles, Best Practices and Design Patterns for C (or Procedural Programming in general)?

Are there any known design principles, best-practices and design patterns that one can follow while designing a C project? Or useful design principles for procedural (imperative) programming in general? (I'm child of the 'object-oriented generation' and have to design a large C project for the first time) ...

Which type of design pattern should be used to create an emulator?

I have programmed an emulator, but I have some doubts about how to organizate it properly, because, I see that it has some problems about classes connection (CPU <-> Machine Board). For example: I/O ports, interruptions, communication between two or more CPU, etc. I need for the emulator to has the best performance and good understandi...

is it good design practice to only have a parameterless base class constructor?

In base class constructors I always see a parameterless constructor, like so: public abstract BaseClass {... protected BaseClass() { } ...} but is it acceptable design to include a parameter in the base class constructor? public abstract BaseClass {... protected BaseClass(string initObj) { } ...} ...

Using switch and enumerations as substitute for named methods

This pattern pops up a lot. It looks like a very verbose way to move what would otherwise be separate named methods into a single method and then distinguished by a parameter. Is there any good reason to have this pattern over just having two methods Method1() and Method2() ? The real kicker is that this pattern tends to be invoked on...