The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

Archive for November 4th, 2015

Programming is Gardening, not Engineering

Posted by jpluimers on 2015/11/04

Pragmatic Programmers Andy Hunt and Dave Thomas talk with Bill Venners about a gardening metaphor for software development, the reasons coding is not mechanical,and the stratification of development jobs.

Source: Programming is Gardening, not Engineering

Posted in Uncategorized | Leave a Comment »

Do not expose properties with writeable fields without a chance to react on the writes.

Posted by jpluimers on 2015/11/04

From a chat with a co-worker a while ago:

I’m not against properties. Just something against properties properties that are objects with writeable fields.

So even if you expose such a property as read-only, it can still get its writeable fields overwritten.

That is a pain when those are part of the state of the underlying object.

In other words: encapsulate your state changes.

Here we solved it by making

  • the type of the property immutable
  • the property writeable
  • react on state changes during the write

Proper encapsulation.

In this case it was a project mixing C# and Delphi, but you can easily apply the above to any language featuring classes and properties.

Another solution would have been to extend the type of the property so it can expose an event that fires during change. Much more convoluted.

–jeroen

Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Delphi, Delphi 10 Seattle, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 2 Comments »