Why doesn’t generic ICollection implement IReadOnlyCollection in .NET 4.5?

There are probably several reasons. Here are some: Huge backwards compatibility problems How would you write the definition of ICollection<T>? This looks natural: interface ICollection<T> : IReadOnlyCollection<T> { int Count { get; } } But it has a problem, because IReadOnlyCollection<T> also declares a Count property (the compiler will issue a warning here). Apart from … Read more

Kyle Simpson’s OLOO Pattern vs Prototype Design Pattern

what exactly does his pattern introduce? OLOO embraces the prototype chain as-is, without needing to layer on other (IMO confusing) semantics to get the linkage. So, these two snippets have the EXACT same outcome, but get there differently. Constructor Form: function Foo() {} Foo.prototype.y = 11; function Bar() {} Bar.prototype = Object.create(Foo.prototype); Bar.prototype.z = 31; … Read more

Template design pattern in JDK, could not find a method defining set of methods to be executed in order

A simple example is java.io.OutputStream. The template method is public void write(byte b[], int off, int len). It calls the abstract method public abstract void write(int b), which must be implemented by a subclass of OutputStream. In this case the invariant portion of the template is the basic error handling that is common to every … Read more

Should the renderingThread of a SurfaceView have the same life-cycle as the view or the activity?

The Activity and the View are created at essentially the same time. The Surface is created later, and that’s what the SufaceHolder callbacks are for. You can’t render on the Surface before it exists or after it’s destroyed, so there’s no point in starting your rendering thread before then or leaving it running after. The … Read more