<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The Problem with Patterns</title>
	<atom:link href="http://incompl.com/2008/the-problem-with-patterns/feed/" rel="self" type="application/rss+xml" />
	<link>http://incompl.com/2008/the-problem-with-patterns/</link>
	<description>Design, Programming and the Web</description>
	<lastBuildDate>Thu, 03 Sep 2009 12:40:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: incompl.com &#187; Pattern Prone</title>
		<link>http://incompl.com/2008/the-problem-with-patterns/comment-page-1/#comment-14</link>
		<dc:creator>incompl.com &#187; Pattern Prone</dc:creator>
		<pubDate>Wed, 23 Jul 2008 02:44:54 +0000</pubDate>
		<guid isPermaLink="false">http://incompl.com/?p=30#comment-14</guid>
		<description>[...] The Problem with Patterns  [...]</description>
		<content:encoded><![CDATA[<p>[...] The Problem with Patterns  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gsmith</title>
		<link>http://incompl.com/2008/the-problem-with-patterns/comment-page-1/#comment-13</link>
		<dc:creator>gsmith</dc:creator>
		<pubDate>Sat, 19 Jul 2008 16:54:06 +0000</pubDate>
		<guid isPermaLink="false">http://incompl.com/?p=30#comment-13</guid>
		<description>Pete:

This could have been an interesting contribution, which is why it is too bad you chose to end it with an inaccurate and rude insinuation.

I maintain that there are good design patterns in any language.  My point us that some are more universally helpful and that some languages are prone to needing complex solutions to simple problems.  This doesn&#039;t seem to contradict what you point out.

It seems it would have been better to title this article &quot;The problem with pattern-prone languages.&quot;</description>
		<content:encoded><![CDATA[<p>Pete:</p>
<p>This could have been an interesting contribution, which is why it is too bad you chose to end it with an inaccurate and rude insinuation.</p>
<p>I maintain that there are good design patterns in any language.  My point us that some are more universally helpful and that some languages are prone to needing complex solutions to simple problems.  This doesn&#8217;t seem to contradict what you point out.</p>
<p>It seems it would have been better to title this article &#8220;The problem with pattern-prone languages.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete</title>
		<link>http://incompl.com/2008/the-problem-with-patterns/comment-page-1/#comment-12</link>
		<dc:creator>Pete</dc:creator>
		<pubDate>Sat, 19 Jul 2008 16:15:38 +0000</pubDate>
		<guid isPermaLink="false">http://incompl.com/?p=30#comment-12</guid>
		<description>Programming is a form of expression -- you are expressing what you want the computer to do.  The programming language is the way you express what you want.  If we had a perfect form of expression, the computer would always be able to tell exactly what we wanted and we would have *no* problems with programming.

Therefore, *all* programming problems can be seen as problems with a programming language, since all problems *could* be solved at the language level.  In the real world, we have to be pragmatic and use the flawed languages that we have available.  These *all* have recurring problems, which result in recurring solutions.  These solutions are then generalised into design patterns, which are applicable across various languages that share similar features, but certainly do *not* apply universally.

I&#039;m pretty sure this is explained in the first few chapters of the GOF design patterns book, but since you seem to think it was based around the problems with Java (when, IIRC, it used C++ and Smalltalk), I&#039;m guessing that you never actually read it?</description>
		<content:encoded><![CDATA[<p>Programming is a form of expression &#8212; you are expressing what you want the computer to do.  The programming language is the way you express what you want.  If we had a perfect form of expression, the computer would always be able to tell exactly what we wanted and we would have *no* problems with programming.</p>
<p>Therefore, *all* programming problems can be seen as problems with a programming language, since all problems *could* be solved at the language level.  In the real world, we have to be pragmatic and use the flawed languages that we have available.  These *all* have recurring problems, which result in recurring solutions.  These solutions are then generalised into design patterns, which are applicable across various languages that share similar features, but certainly do *not* apply universally.</p>
<p>I&#8217;m pretty sure this is explained in the first few chapters of the GOF design patterns book, but since you seem to think it was based around the problems with Java (when, IIRC, it used C++ and Smalltalk), I&#8217;m guessing that you never actually read it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gsmith</title>
		<link>http://incompl.com/2008/the-problem-with-patterns/comment-page-1/#comment-11</link>
		<dc:creator>gsmith</dc:creator>
		<pubDate>Sat, 19 Jul 2008 15:12:52 +0000</pubDate>
		<guid isPermaLink="false">http://incompl.com/?p=30#comment-11</guid>
		<description>Ramon Leon:

Yeah, I can see where my examples could have been better.  This is a useful critique to improve my argument.  Thanks for taking the time to explain where you&#039;re coming from.

keithb:

Good points here.  Especially about Flyweight: never thought of it that way.

I definitely agree that there are patterns in every language.  I&#039;m being careful not to suggest that there are no &quot;real&quot; patterns, or that all patterns are in some way &quot;bad.&quot;  My point is a weaker statement: That some languages have more of them because of how inflexible the language is.  In that case, you get many, many patterns, some of them solving fairly simple problems.

It is also worth considering the difference between patterns that exist because of a lack of a feature and patterns that exist because of a constraint.  I personally believe that languages should be simple, elegent, and flexible.  I&#039;m not much for &quot;features&quot;, at least not the type that can&#039;t be expressed as macros or libraries. I suppose any pattern can be obsoleted by adding features, but more interesting are the ones that can be obsoleted by removing constraints.</description>
		<content:encoded><![CDATA[<p>Ramon Leon:</p>
<p>Yeah, I can see where my examples could have been better.  This is a useful critique to improve my argument.  Thanks for taking the time to explain where you&#8217;re coming from.</p>
<p>keithb:</p>
<p>Good points here.  Especially about Flyweight: never thought of it that way.</p>
<p>I definitely agree that there are patterns in every language.  I&#8217;m being careful not to suggest that there are no &#8220;real&#8221; patterns, or that all patterns are in some way &#8220;bad.&#8221;  My point is a weaker statement: That some languages have more of them because of how inflexible the language is.  In that case, you get many, many patterns, some of them solving fairly simple problems.</p>
<p>It is also worth considering the difference between patterns that exist because of a lack of a feature and patterns that exist because of a constraint.  I personally believe that languages should be simple, elegent, and flexible.  I&#8217;m not much for &#8220;features&#8221;, at least not the type that can&#8217;t be expressed as macros or libraries. I suppose any pattern can be obsoleted by adding features, but more interesting are the ones that can be obsoleted by removing constraints.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keithb</title>
		<link>http://incompl.com/2008/the-problem-with-patterns/comment-page-1/#comment-10</link>
		<dc:creator>keithb</dc:creator>
		<pubDate>Sat, 19 Jul 2008 11:17:25 +0000</pubDate>
		<guid isPermaLink="false">http://incompl.com/?p=30#comment-10</guid>
		<description>So, Java in fact is not the language that brought patterns to my mind, C++ was and the folks from whom I learned C++ patterns were explicitly importing into that language culture a style of knowledge management that they had learned in the Smalltalk world. 

Note that &quot;Design Patterns: A Smalltalk Companion&quot; exists and that it devotes 14 pages to Factory Method. I have a subtle disagreement with Ramon: in Smalltalk programming it&#039;s not that Factory is unnecessary, it&#039;s that it&#039;s ubiquitous. Not that Smalltalk doesn&#039;t require you to add utility creation methods to a class class, but almost all programmers do almost all the time.

It think that what you are trying to do, identify patterns that are more interesting because they are not so much a work-around for missing language features is an interesting approach—and greatly more sophisticated that the average &quot;critique&quot; of patterns. And yet, would Flyweight seem so interesting in a language with symbols and automatic memoisation?

Or, consider that one collection of Smalltalk patterns contains a write–up of &quot;Abstract Class&quot;, which would be irrelevant, or be invisible or whatever dismissive adjective you like if only Smalltalk had...abstract classes! As it is invisible in Java.

I submit that there are patterns of use in every language, because no language has every kind of way of organising code built in. Even in the languages with a culture of programming extending the language we still find repeating idioms that by convention are not (for example) captured as a macro.</description>
		<content:encoded><![CDATA[<p>So, Java in fact is not the language that brought patterns to my mind, C++ was and the folks from whom I learned C++ patterns were explicitly importing into that language culture a style of knowledge management that they had learned in the Smalltalk world. </p>
<p>Note that &#8220;Design Patterns: A Smalltalk Companion&#8221; exists and that it devotes 14 pages to Factory Method. I have a subtle disagreement with Ramon: in Smalltalk programming it&#8217;s not that Factory is unnecessary, it&#8217;s that it&#8217;s ubiquitous. Not that Smalltalk doesn&#8217;t require you to add utility creation methods to a class class, but almost all programmers do almost all the time.</p>
<p>It think that what you are trying to do, identify patterns that are more interesting because they are not so much a work-around for missing language features is an interesting approach—and greatly more sophisticated that the average &#8220;critique&#8221; of patterns. And yet, would Flyweight seem so interesting in a language with symbols and automatic memoisation?</p>
<p>Or, consider that one collection of Smalltalk patterns contains a write–up of &#8220;Abstract Class&#8221;, which would be irrelevant, or be invisible or whatever dismissive adjective you like if only Smalltalk had&#8230;abstract classes! As it is invisible in Java.</p>
<p>I submit that there are patterns of use in every language, because no language has every kind of way of organising code built in. Even in the languages with a culture of programming extending the language we still find repeating idioms that by convention are not (for example) captured as a macro.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramon Leon</title>
		<link>http://incompl.com/2008/the-problem-with-patterns/comment-page-1/#comment-9</link>
		<dc:creator>Ramon Leon</dc:creator>
		<pubDate>Sat, 19 Jul 2008 05:57:03 +0000</pubDate>
		<guid isPermaLink="false">http://incompl.com/?p=30#comment-9</guid>
		<description>The command pattern is not necessarily working around lack of closures.  Smalltalk has closures, but closures alone don&#039;t make a command pattern and closures in most languages aren&#039;t generally easily serializable because of how they capture the local environment.  Consider an undo redo stack, a command would encapsulate both the action required to execute it, and to undo it.  Commands get much fancier than just execute them.  It&#039;s easy to think they&#039;re just making up for something missing in the language, but they aren&#039;t, they&#039;re a description of an object model that is hany, in *any* OO language, even those with closures, but that isn&#039;t the case, it&#039;s more complicated than that.

&#039;I guess if you take it just to mean “a method intended to create and return a new object” you’re not limiting yourself to any particular purpose. The definition I was addressing is “Using methods to abstract away the concrete class of the constructed object.”&#039;

Those two sentences mean virtually the same thing.  The sole purpose of extracting new object creation into another method is to hide the concrete class, you wouldn&#039;t do it otherwise.  Of course it&#039;s just taking advantage of inheritance, that&#039;s a huge part of what OO is, and that knowledge wasn&#039;t generally accessible to most people prior to the design patterns book, it popularized a common vocabulary for object models that helped make OO widely known.

You are right about some of the patterns being unnecessary in other languages, but you chose bad examples.  Both factory method and command patterns are widely used in languages that you can&#039;t say lack the right features.

 A better example would have been the factory pattern itself, it&#039;s generally only useful in languages lacking *real* meta-classes.  In Ruby or Smalltalk, you&#039;d use the class itself as the factory for its instances and you can add methods to it, and pass it around, classes are real objects, making factories unnecessary.  Or the strategy pattern, which is really just a way to fake anonymous methods for specializing higher order functions.</description>
		<content:encoded><![CDATA[<p>The command pattern is not necessarily working around lack of closures.  Smalltalk has closures, but closures alone don&#8217;t make a command pattern and closures in most languages aren&#8217;t generally easily serializable because of how they capture the local environment.  Consider an undo redo stack, a command would encapsulate both the action required to execute it, and to undo it.  Commands get much fancier than just execute them.  It&#8217;s easy to think they&#8217;re just making up for something missing in the language, but they aren&#8217;t, they&#8217;re a description of an object model that is hany, in *any* OO language, even those with closures, but that isn&#8217;t the case, it&#8217;s more complicated than that.</p>
<p>&#8216;I guess if you take it just to mean “a method intended to create and return a new object” you’re not limiting yourself to any particular purpose. The definition I was addressing is “Using methods to abstract away the concrete class of the constructed object.”&#8217;</p>
<p>Those two sentences mean virtually the same thing.  The sole purpose of extracting new object creation into another method is to hide the concrete class, you wouldn&#8217;t do it otherwise.  Of course it&#8217;s just taking advantage of inheritance, that&#8217;s a huge part of what OO is, and that knowledge wasn&#8217;t generally accessible to most people prior to the design patterns book, it popularized a common vocabulary for object models that helped make OO widely known.</p>
<p>You are right about some of the patterns being unnecessary in other languages, but you chose bad examples.  Both factory method and command patterns are widely used in languages that you can&#8217;t say lack the right features.</p>
<p> A better example would have been the factory pattern itself, it&#8217;s generally only useful in languages lacking *real* meta-classes.  In Ruby or Smalltalk, you&#8217;d use the class itself as the factory for its instances and you can add methods to it, and pass it around, classes are real objects, making factories unnecessary.  Or the strategy pattern, which is really just a way to fake anonymous methods for specializing higher order functions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gsmith</title>
		<link>http://incompl.com/2008/the-problem-with-patterns/comment-page-1/#comment-8</link>
		<dc:creator>gsmith</dc:creator>
		<pubDate>Sat, 19 Jul 2008 01:41:34 +0000</pubDate>
		<guid isPermaLink="false">http://incompl.com/?p=30#comment-8</guid>
		<description>What you describe is a valid use of a Factory method.  But still, what you say is not really any more interesting as a pattern to me.  It is just inheritence.

It is certainly confusing that there is supposedly a &quot;Factory Method&quot; pattern and a &quot;Factory Pattern&quot; and all these different takes on it.  I guess if you take it just to mean &quot;a method intended to create and return a new object&quot; you&#039;re not limiting yourself to any particular purpose.  The definition I was addressing is &quot;Using methods to abstract away the concrete class of the constructed object.&quot;  The pattern is the goal and the technique.

As for the command pattern: You say it right when you say it is &quot;trying to emulate a closure.&quot;  You don&#039;t try to emulate these in languages that support them natively.  That is what I&#039;m trying to get at.  You&#039;re working around something your language doesn&#039;t do.

As for design patterns for Smalltalk: I think if the pattern makes sense for Smalltalk it probably does stand a better chance of being truly interesting.  Smalltalk is a fine language that doesn&#039;t have a lot of Java&#039;s problems.  Some design patterns applicable in Java are not applicable in Smalltalk for that very reason.</description>
		<content:encoded><![CDATA[<p>What you describe is a valid use of a Factory method.  But still, what you say is not really any more interesting as a pattern to me.  It is just inheritence.</p>
<p>It is certainly confusing that there is supposedly a &#8220;Factory Method&#8221; pattern and a &#8220;Factory Pattern&#8221; and all these different takes on it.  I guess if you take it just to mean &#8220;a method intended to create and return a new object&#8221; you&#8217;re not limiting yourself to any particular purpose.  The definition I was addressing is &#8220;Using methods to abstract away the concrete class of the constructed object.&#8221;  The pattern is the goal and the technique.</p>
<p>As for the command pattern: You say it right when you say it is &#8220;trying to emulate a closure.&#8221;  You don&#8217;t try to emulate these in languages that support them natively.  That is what I&#8217;m trying to get at.  You&#8217;re working around something your language doesn&#8217;t do.</p>
<p>As for design patterns for Smalltalk: I think if the pattern makes sense for Smalltalk it probably does stand a better chance of being truly interesting.  Smalltalk is a fine language that doesn&#8217;t have a lot of Java&#8217;s problems.  Some design patterns applicable in Java are not applicable in Smalltalk for that very reason.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramon Leon</title>
		<link>http://incompl.com/2008/the-problem-with-patterns/comment-page-1/#comment-7</link>
		<dc:creator>Ramon Leon</dc:creator>
		<pubDate>Sat, 19 Jul 2008 01:17:50 +0000</pubDate>
		<guid isPermaLink="false">http://incompl.com/?p=30#comment-7</guid>
		<description>You misunderstand why the factory pattern is useful and what it&#039;s for.  It&#039;s not fixing broken constructors in Java, Smalltalk constructors work just like you envision, you can return any type from them, and yet we still need the factory pattern.

The point of the factory pattern is to provide overridable hooks so subclasses can inject different concrete classes into the superclass&#039;s algorithms.  I might subclass UIComponent and override the renderingCanvas method to return my own custom canvas that draws things how I like.  The point really is to not have naked class references in the middle of methods anywhere because that&#039;s not very flexible; extracting naked class references into a separate method gives the *option* of overriding it to future subclassers who may want to do things differently.

The command pattern is also not just trying to emulate functions in languages that lack them.  It&#039;s trying to emulate a closure, a function with state.  A closure is an object with one function and an object with one function is closure.  This is important because you want to be able to serialize commands.  A database transaction log is a good example, a sequence of commands serialized to disk that when replayed in that same order later will rebuild the state back to the point the crash occurred.  You can&#039;t do that with just functions, you need closures/objects.

Half the examples in the design patterns book were written in Smalltalk, a language which suffers none of Java&#039;s silly restrictions.  What they are however, is patterns for object oriented languages, so they may not apply if functional/procedural programming is your thing.</description>
		<content:encoded><![CDATA[<p>You misunderstand why the factory pattern is useful and what it&#8217;s for.  It&#8217;s not fixing broken constructors in Java, Smalltalk constructors work just like you envision, you can return any type from them, and yet we still need the factory pattern.</p>
<p>The point of the factory pattern is to provide overridable hooks so subclasses can inject different concrete classes into the superclass&#8217;s algorithms.  I might subclass UIComponent and override the renderingCanvas method to return my own custom canvas that draws things how I like.  The point really is to not have naked class references in the middle of methods anywhere because that&#8217;s not very flexible; extracting naked class references into a separate method gives the *option* of overriding it to future subclassers who may want to do things differently.</p>
<p>The command pattern is also not just trying to emulate functions in languages that lack them.  It&#8217;s trying to emulate a closure, a function with state.  A closure is an object with one function and an object with one function is closure.  This is important because you want to be able to serialize commands.  A database transaction log is a good example, a sequence of commands serialized to disk that when replayed in that same order later will rebuild the state back to the point the crash occurred.  You can&#8217;t do that with just functions, you need closures/objects.</p>
<p>Half the examples in the design patterns book were written in Smalltalk, a language which suffers none of Java&#8217;s silly restrictions.  What they are however, is patterns for object oriented languages, so they may not apply if functional/procedural programming is your thing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
