2005-09-12

This is the fourth article in my mini series about object pooling. Be sure to read part 1, part 2 and part 3 first. This part will be about automated object creation. To begin with, we need a way for the object pool to have additional objects created at all. One way to do that would be to just call new on the object type — and to use the new constraint on the generic class definition, of course. But that’s an unnecessary restriction, and it would imply that poolable classes always need to …


2005-09-11

This is the third article in my mini series about object pooling. Be sure to read part 1 and part 2 first. In this part I’m going to put some of the infrastructure in place that’s needed to handle the list of pooled objects, to make objects available and to allow for them to be put back into the pool.

Initializing the pooled object list

As I don’t want to look at automated object creation just yet, I’ll create a constructor for my pool that allows for a list of pooled objects to be passed …


2005-09-09

This is the second article in my mini series about object pooling. You can find the first part here. Now I want to get going by defining an interface for the pool — I don’t mean a C# interface, but rather a framework for the methods and properties that the implemented class is going to have. I’ve also given some thought to the internal organization. One thing’s clear: the pool needs to have a list of objects that it currently holds. This list will have to be extendable, but there aren’t any ot …


2005-09-08

The other day there was a thread in a newsgroup which ended up discussing object pooling. Jon pointed to Spring.NET — an application framework for enterprise .NET applications. I’m sure there are other implementations out there, at the moment, Spring.NET merely offers a few interfaces and a rather simplistic implementation of a pool. I thought it might be interesting to people to see how pooling functionality can be implemented, so I’m going to do that for this article, which is supposed to be …


2005-09-02

In a project on which I’m currently working, I had these classes:

class MultiCriteria : Criteria {
  public MultiCriteria(params Criteria[] criteria) {
    criteriaList = new BindingList<Criteria>(criteria);
  }

  private BindingList<Criteria> criteriaList;
  public BindingList<Criteria> CriteriaList {
    get { return criteriaList; }
    set { criteriaList = value; }
  }
}

class AllCriteria : MultiCriteria {
  public AllCriteria() { }
  public AllCriteria(params Criteria[] criteri ...

2005-09-01

Something I heard yesterday made me think about the aspect of performance, when deciding whether to use interfaces or delegates to implement a specific feature. For example, when implementing the Observer pattern, the classic approach involves interfaces, while .NET has support for (multicast) delegates natively, suggesting a builtin approach that might make more sense in a .NET language.

To make this decision, there are of course many arguments to consider — most importantly, when talking ab …


2005-08-26

I heard criticism about my first post on the topic: if a control was on the form, apart from the background drawing, the rubber rectangle would appear behind the control, not in front of it. Of course there are several ways to change this, I decided to implement one of them just for fun :-) This is what things look like before and after my changes:

rubberband2-before.png

rubberband2-after.png

Here’s the complete …


2005-08-26

I saw the question coming up in a newsgroup today: how do you draw a selection rubber band just like the one Explorer uses, in C#? The first thing that came to mind was the ControlPaint.DrawReversibleFrame() method, but that’s rather restricted. It’s fine to draw a rectangle around an area to select, but it can’t do anything more than that and it also has problems because it draws over windows that are supposed to be in front of the current app window. Here are screenshots of a selection made i …