HotComments is a pattern that gets employed when somebody needs a way to extend a non-extensible format. For example, suppose you have a fixed format containing name, address, etc., and suddenly there is a crushing need to store the GPS coordinates of their mailbox too. You add a hot comment: Name [delimiter] address [delimiter] ... ; !GPS=(X,Y,Z) Old applications that don't know about GPS will still be able to parse it. However, you have now ruined the semantics of comments. They were supposed to be uninterpreted data. Now they are interpreted. Instead of being able to discard comments, your parser now needs to scan through them looking for the magic trap door sequences that signal additional information. If you find yourself doing this, it is time to switch to an extensible format. ''XML, anyone?'' See XmlSucks... ---- '''Examples''' * JavaDoc comments in JavaLanguage source code. Most of the JavaDoc tags are ignored by the compiler, which still must process them in order to properly handle the @deprecated tag. * MacromediaDreamweaver uses HotComments in HTML as markers for the start/end of template sections, and refuses to let you edit the templated parts. [This is a common pattern for extending HTML. Who needs a ContentManagementSystem when you can embed metadata in comments?] * PostScript has always used them to embed machine-readable directives ('%%' comments); see Adobe Document Structuring Conventions http://partners.adobe.com/public/developer/en/ps/5001.DSC_Spec.pdf , EPS format spec http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf , etc. -- TobyThain * Annotating that return values are 'never reached' for 'lint' tools. * ConditionalComment in Microsoft HTML and scripting languages, like JScript. They are effectively a form of IfDef for JavaScript and HTML. See http://en.wikipedia.org/wiki/Conditional_comment * DelphiLanguage and FreePascal put compiler directives in comments. * The SPARK language is a syntactic subset of AdaLanguage and uses comments for annotations that add additional information about what something actually does. '''A non-example''' * Embedded DocumentTypeDefinition''''''s look like HotComments, but aren't. A DTD is specified in an SGML DOCTYPE directive, which, although it begins with AST, potentially with the ability to also return warnings and errors. LiterateProgramming might take AST->PostScript. Tools, such as IDEs, developed to process the language would probably import the parser then include their own back-end (e.g. an IDE might use the AST to highlight the original source-text, aide with searches, and provide hovertext associated with certain areas of code). Related: AnnotationMetadata ------- Yeah, this works great after you have a system that depends on having content in a comment, and then someone else does the same thing with different content in the comment, and now both systems are mutually incapable of parsing this supposed 'extensible' format. ''Use two comments. Each system ignores comments it doesn't understand. Problem solved.'' Then... what do you do about name collisions? (same comment has different meaning) then... you have to add a namespaces capability? ------ Backward-compatibility or lacking command jurisdiction to change the format are common reasons to apply kludges. It's messy, but that's life. Put in your recommendation for a better format, and if it's rejected, that's that. Move on. ''In other words: what are you all hanging around here debating for? Stop trying to make things better!'' ---- See DataCodeEquivocationConsideredHarmful, CategoryXml (for a fix) (And note this is not a AntiPattern exactly - just a source of abuse that can lead to one. For example, JavaDoc comments are still comments, so they are not as icky as, say, twiddling your compiler settings out of a comment...) ---- CategoryAntiPattern