Most of us use patterns as a problem-solving tool. But patterns do, or should, drive us to heightened use of aesthetics. Not all problem/solution pairs are patterns. RichardGabriel, in his wonderful contribution to http://st-www.cs.uiuc.edu/users/patterns/definition.html, notes that a pattern is much more than a solution to a problem in a context. He tells us: : Each pattern is a three-part rule, which expresses a relation between a certain context, a certain system of forces which occurs repeatedly in that context, and a certain software configuration which allows these forces to resolve themselves. [See "A Timeless Way of Hacking."] But a pattern should also have a pleasant literary quality. It must be ''elegant''. It must, to be accepted and effective. Solutions that are the lesser of two evils don't strive upward toward elegance; they avoid falling downward into ugliness. For example, see KansasCityAirConditioner (moved from here to there by AlistairCockburn). Here, the solution fails to avoid both Scylla and Charybdis; it just explains why Scylla is less evil than Charybdis. A recent pattern that overcame some problems of VisualBasic using a global variable to support a Singleton pattern struck me this way. That may owe to the nature of the problem itself, or to the presentation, but both are problems to be overcome in a good pattern. -- JimCoplien ---- Going off at a tangent, here's how I do a VbClassicSingleton (-; -- Stefan Kapusniak ---- Hmmm... So what do you do if a problem's solution can only be expressed as the lesser of two evils? Should you spawn a search for a third, better solution? This just reminds me of Hegel's dialectic. The idea that you can always take a thesis and its antithesis and somehow arrive at a synthesis always seemed to me to be hollow intellectual posturing. There are some problems that just *don't* work that way. The problem is that the world isn't always elegant. Should we ignore reality in our search for elegance? I understand what you're saying, Cope, don't get me wrong. You're looking for that magical feeling you get when reading the forces builds up a tension that is released when you read the solution. Unfortunately, sometimes all you get from a solution is a "oh", or even worse "ick". It's not necessarily because the pattern fails as literature, it's because there IS no good solution to the problem, at least the way we understand it. For instance, one of the biggest problems in quantum physics today is the fact that in solving many of the equations you can end up with nonsense answers (infinities). There's a technique called renormalization that can eliminate some of these infinities, but most physicists look upon it with the distaste that they feel toward cod-liver oil or a proctological examination. In other words, it's good for you, you really need it, but you don't have to *like* it. So should physicists stop teaching renormalization, or stop using it because it's not elegant or esthetically appealing? No, but they shouldn't give up the search for something better either. As Einstein once said, many problems can't be solved in the frame of reference in which they are discovered. Either you have to step outside the frame of reference, or you have to live with the best solution that's available. -- KyleBrown ---- In practise the lack of elegance could often have been avoided with more foresight. If the air conditioning had been allowed for in the original building design, it would surely have cost less than retro-fitting it later. Software isn't a building, bad metaphor, well built software makes the cost of change the same later as now, you should be able to add any feature at any time for the same price. ''How does one apply foresight to something that hasn't been invented yet?'' -- DaveHarris ---- What is a pattern? Is it simply something that repeats? Does it have to be elegant? To whom? Part of the problem is that different people have different reasons they are interested in patterns. Some people have problems they want to solve, and they hope patterns will help them solve it. Others have solutions, but want better solutions. Others are more interested in understanding how to come up with good solutions than in solving any particular problem. People looking for understanding are more impressed by general, widely applicable patterns than in very specific ones like KansasCityAirConditioner. But people who just want to solve a problem don't care. If the pattern fits, they are happy. -- RalphJohnson --------- See also: PatternBacklash ---- CategoryPattern