Blog Image

Software Development

About the blog

The blog was created in an attempt to keep those valued points which are discovered in daily development and give something back to the community.

Books

Favourites Posted on 2010-05-02 22:49

Roy Osherove’s : The Art of Unit Testing

Read it and LEARN !

Andrew Hunt & David Thomas’ : The Pragmatic Programmer

Lots of stuff to improve behaviour, code quality and probably also self esteem when you recognize some of your own behavioral/coding patterns.

Martin Fowler et al’s : Refactoring

The basis of all modern software development and maintenance.

Erich Gamma, Richard Helm, Ralph Johnson & John Vlissides : Design Patterns

An important part of the foundation for every software developer.



DataGridView.AutoGenerateColumns

Databinding Posted on 2010-05-02 11:11

If the DataGridView seems unwilling to change the column-order even when specifically ordered to, then the reason is probably that AutoGenerateColumns is set to true.

The symptoms are not very consistent, because it will seem like it’s possible to move some columns but not others, which may lead one into a wild goose-chase for the reason why the particular column that one is trying to position can’t be positioned exactly where one wants.



DataGridView.AllowUserToAddRows

Databinding Posted on 2010-05-02 11:04

AllowUserToAddRows needs the DataSource to support IBindingList with AllowNew set to true.

So either normalize the data to a BindingList instance which is then used as the DataSource or support IBindingList on the collection which is used as DataSource.



Events and Anonymous Delegates

C# Posted on 2010-04-09 14:47

Some time ago I got started using anonymous delegates extensively for unittesting event-raising, but not tidying up after the subscription annoyed me.

If a class subscribes to an event on an object it’ll prevent the subscribee from being garbage collected. This is a particular problem with anonymous delegates, because normally you won’t think of removing the subscription, and how to do it may not initially seem obvious. However the subscription can be removed by specifically creating the instance of the subscriber delegate before the actual subscription and keeping it for the un-subscription:

var anonymousDelegate = new SomeDelegate(
delegate (…params…) { … implementation … }
);

SomeObject.SomeEvent += anonymousDelegate;
SomeObject.SomeMethodWhichRaisesSomeEvent();
SomeObject.SomeEvent -= anonymousDelegate;



« Previous