1

I'd like to implement resource pooling using design patterns so the implementation is neat and and flexible. The resources that I need to create have high memory costs. Is there any design patterns fitting the nature of pooling or suitable for its implementation?

Thanks!!!

  • possible duplicate of [C# Object Pooling Pattern implementation](http://stackoverflow.com/questions/2510975/c-sharp-object-pooling-pattern-implementation) – weston Jun 21 '14 at 19:10
  • Thanks for the hints, it was nice to read the other link, although I want to be language independent for my solution. – user3763480 Jun 27 '14 at 14:04

1 Answers1

0

The Resource Pool and Resource Cache patterns from POSA3 might be useful, and are surely flexible. Here's a reference:

Pattern-Oriented Software Architecture Volume 3, Patterns for Resource Management, Michael Kircher, Prashant Jain, John Wiley & Sons Ltd, 2004.

You'll find downloads of source code in various languages.

There are also some PowerPoint slides from Doug Schmidt's courses that explain Pooling in the context of resource management.

You'll find an explanation of Pooling from the authors of POSA3.

Fuhrmanator
  • 11,459
  • 6
  • 62
  • 111
  • Thanks for the extensive reply. I like the resource you mentioned. However these are more about the pooling itself. I am more interested to know the design patterns which can be used in combination with the pooling to make the pooling implementation more modular and maintainable. Thanks! – user3763480 Jun 27 '14 at 13:58
  • Ok, so I think I don't understand what you mean in your question. Can you try to be more concrete? Why aren't you happy specifically with the POSA3 patterns? What makes them not so maintainable or modular? – Fuhrmanator Jun 28 '14 at 14:44
  • Thanks! POSA3 Patterns says if you want to increase your performance then here it is Pooling.The main force for that pattern is enhancing the performance. Now, what I'd like to know is is I could take POSA3 which is a basic implementation of Pooling and make it more flexible where I have more forces such as (i) the objects are expensive to create (ii) there are different types of objects (iii) I need to reset the objects before reuse and etc etc – user3763480 Jul 01 '14 at 13:41
  • POSA3 does not take into account the further forces that someone might face in a specific context. Do you think it is possible to use low level design patterns (GOF) to address these forces within the structure that POSA3 suggests. Any thoughts? Thanks!!! – user3763480 Jul 01 '14 at 13:41
  • The PowerPoint slides mention many dimensions, not just performance. Flexibility considers different types of objects for resources. Nothing stops you from making an abstraction of the `Resource` and specializing them for your various types. A Proxy would be useful to provide access to a memory-expensive resource. Your "reset object before reuse" problem sounds like the Resource Lifecycle Manager pattern (again see the PowerPoints). – Fuhrmanator Jul 02 '14 at 01:15