''Perhaps a ProtoPattern? There are many uses, some of which would be enumerated in EscapeMechanisms, but ''this'' page is not yet in the PatternPattern. -- MatthewAstley'' '''Pattern Name:''' EscapeHatch '''Aliases:''' EscapeMechanisms, EscapeHatchMechanism '''Context:''' You are in a paradigm (''e.g.'' language, runtime environment, scribble on back of envelope) and you need to express or do some thing which does not fit. '''Problem:''' You are being restricted by your current tool set. '''Forces:''' * You may not be able to ditch your current tool for various reasons: technical, legal, political or legacy code. * There may not be a tool which does everything you need, or it may be too complex. * It may be wise to keep some things separate, ''e.g.'' the financial accounts and the Internet. (Here, a KVM switch plus spare computer would do the trick .. but only the ThreeLetterAgencies are that paranoid.) Maybe this is a digression or unnecessary generalization? '''Solution:''' Pop the EscapeHatch and go somewhere else. You can generally return from wherever it is you go. '''Resulting Context:''' You now have two tools stuck together, with a route between. '''Design Rationale:''' '''Examples:''' * KawaScheme * HookOperations * Inline assembler in C source, or linking against an object file generated from another language * Java JNI, Perl XS ... * Inline PerlLanguage in an Exim (mail transport) configuration file * Using PuTty (SecureShell) or VNC to escape to your UnixBox, when you are trapped in MicrosoftWindows * Much less handy the other way around since you can't CutAndPaste across TerminalServer with rdesktop (but you can with windows and VNC). '''Related Patterns:''' ---- Contributors: RaySchneider, StevenBlack, MichaelFeathers [I haven't rolled the other people's comments in yet] ---- '''Original''' In general ''escape hatches'' are ways to get out of the rigid structure of the ''paradigm'' and add extenders. UML has a feature that allows that which makes it already a lot better than anything that doesn't. More generally, escape hatches are any structure in a program that provides for extending the program in unanticipated ways later in the development cycle. It is often necessary to have an EscapeHatchMechanism to make this possible. Afterall, on most software projects 60% of the requirements are discovered after the requirements documents have been approved. Argh! (strangling sound) --RaySchneider ---- EscapeHatches can be rigged (or are, by definition rigged?) with HookOperations. -- StevenBlack ---- EscapeHatches are wonderful, in some instances they are really a rudimentary form of a FrameWork. "Don't call us, we'll call you." You call the escape hatch and wait for it to return. The downside of EscapeHatches is that anything can happen. In the case of UML, stereotypes are an escape hatch. We'll have to see if they are abused. I once designed a programming language and wrote a compiler for it. The compiler produced C++. We made an escape hatch to allow C++ statements directly in the language. Saved our lives a couple of times. Java the language/platform can be seen as something without EscapeHatches for security reasons. It'll be interesting to see if this is wise. -- MichaelFeathers The Java Native Interface API is an escape hatch. -- DaveHarris Does the concept of "reflection" (as in FallBackOnReflection) constitute an "escape hatch"? (For example, you can use reflection to invoke methods in Java.) ---- I don't think so. You cannot do anything with reflection that you can't do with compiled method calls. On the other hand, the JNI allows you to get beneath the virtual machine and make direct calls operating system or execute real machine code. --NatPryce With reflection, you can load a class, check to see what methods it implements, and call a method that was not in the interface at the time your program was written. This is something you can't do with compiled method calls. Inheritance is a kind of escape hatch. You don't like the way a class works? Subclass it and override the method you don't like. It isn't as powerful as other escape hatches, but it is safer and easier to use. ''Do I get slapped if I add "compare: kludge" to this page? 8-)'' Tut, tut. The modern approach is to call it TheKludgePattern, you barbaric heathen. As long as you call it a pattern, you can do no wrong. Although others may call it an AntiPattern, of course; aye, there's the rub.