Muster, diverse

Sammlung interessanter Muster, nicht thematisch geordnet.

Hands in Sight

Inventor's Paradox

Simply Understood Code

Hands in Sight

Name: Hands In View

Problem: The skier fails to commit downhill on steeps and bumps, resulting in slides, backward falls, and "yard sales".

Context: In order to explore the entire mountain environment, a skier must be comfortable to any terrain and rapid terrain change. To take advantage of this pattern the skier should be skiing at a level at which parallel turns can be linked consistently.

Forces:

Fear of falling is the most basic of all responses

Reliance on equipment is essential

Continuous movement is essential

Fatigue can be a factor in long descents

Commitment downhill over skis is essential for skis to function as designed

Solution: Concentrate on keeping the hands in view. Bring them into sight immediately after each pole plant and turn.

Resulting Context: Keeping the hands in view changes the alignment of the body from sitting timidly back and allowing the edges to skid out from under the skier. Thus, keeping the hands in view pulls the body forward and thus downhill, bringing the skier's weight over the downhill ski, forcing the edge to bite and turn.

Rationale: As steepness increases, the natural tendency of any sane person is to sit back against the hill and retain the perpendicularity the inner ear prefers. Unfortunately, skis must be weighted to perform as designed, the weight causing flex, which in turn pushes the edges into the snow in an arc, making a turn. Therefore it is essential to "throw" oneself down the mountain and over the skis, depending on them to "catch" the fall as they bite into the snow to turn underneath the perpetually falling skier. Intellectually this can be clearly understood but fear prevents execution. Concentrating on something as simple and indirect as "look at your hands" causes the desired behavior without directly confronting the fear. This is directly analogous to what occurs when an individual walks: the weight is thrown forward in a fall, with the consequent forward thrust of the leg to catch this fall, repeated for left and right sides in a continuous tension and release of yielding to gravity in order to defy it.

Author: Don Olson 95/07/07

Originator: Anonymous ski instructor somewhere in Utah. Wherever you are, thanks for provoding the breakthrough to better skiing for the author.

Das Muster ist folgendem Buch entnommen:

James O. Coplien: Software Patterns. SIGS 1996.

Inventor's Paradox

Simplify by solving a more general problem. Applied to programming this means to simplify by writing a more general program. Split the program into several loosely-coupled building blocks or aspects. Avoid unnecessary spreading or duplication of information in program building blocks to improve understandability and to reduce size of programs. Use appropriate filters to select what is relevant to one building block from other building blocks. (This pattern is not about any kind of abstraction mechanism in programming but it focusses on those abstraction mechanisms which significantly simplify the solution by solving a much more general problem.)

Das Muster ist inspiriert durch die Aussage des Mathematikers Georg Polya: »The more ambitious plan may have more chances of success« G. Polya, How To Solve It Princeton University Press, 1945

Das Muster stammt von Karl J. Lieberherr College of Computer Science, Northeastern University Boston

Simply Understood Code

At the lowest levels of a program are chunks of code. These are the places that need to be understood to confidently make changes to a program, and ultimately understanding a program thoroughly requires understanding these chunks.

In many pieces of code the problem of disorientation is acute. People have no idea what each component of the code is for and they experience considerable mental stress as a result.

Suppose you are writing a chunk of code that is not so complex that it requires extensive documentation or else it is not central enough that the bother of writing such documentation is worth the effort, especially if the code is clear enough on its own. How should you approach writing this code?

People need to stare at code in order to understand it well enough to feel secure making changes to it. Spending time switching from window to window or scrolling up and down to see all the relevant portions of a code fragment takes attention away from understanding the code and gaining confidence to modify it.

People can more readily understand things that they can read it their natural text reading order; for Western culture this is generally left to right, top to bottom.

If code cannot be confidently understood, it will be accidentally broken.

Therefore, Arrange the important parts of the code so it fits on one page. Make that code understandable to a person reading it from top to bottom. Do not require the code to be repeatedly scanned in order to understand how data is used and how control moves about.

This pattern can be achieved by using the following patterns: Local Variables Defined and Used on One Page, which tries to keep local variables on one page; Assign Variables Once, which tries to minimize code scanning by having variables changed just once; Local Variables Reassigned Above their Uses, which tries to make a variable’s value apparent before its value is used while scanning from top to bottom; Make Loops Apparent, which helps people understand parts of a program that are non-linear while retaining the ability to scan them linearly; and Use Functions for Loops, which packages complex loop structure involving several state variables into chunks, each of which can be easily understood.

Autor: Peter Gabriel 1995

[Aktuell] [Veranstaltungen] [Projekte & Publikationen] [Literatur & Links] [Miscellanea] [Impressum] [<][^][>]