When you maintain a web site, it’s helpful to have tools. In this chapter and the next, we’ll develop an application that can serve as a framework for a number of tools to track and manipulate pages in a web site. What tools might we have? · Viewers – to show pages · Editors […]
Author: Bill Wake
Growing Frameworks: Patterns
Design patterns are micro-architectures that solve a particular design problem. See the class text Design Patterns. A pattern is a literary form that describes a problem, the forces surrounding it, and a solution that resolves those forces. The designs described here will influence your framework’s structure. They will also be at work in your […]
Suppose you’ve been developing programs for a while, and you keep finding yourself building graphs – the node and edge kind – over and over. So, you’ve built a graph class, which you move from one project to the next, improving it as you go. You’ve heard of frameworks, and you think your graph might […]
Summary: How to use the “Template Method” in Java frameworks. The Template Method is a pattern commonly used in frameworks to implement the “Hollywood Principle”: “Don’t call us, we’ll call you.” [Design Patterns, Gamma et al.] The key idea is that there is a basic algorithm we want to stay the same, but we want […]
Growing Frameworks: Introduction
Note: This is a draft manuscript. I haven’t worked on it in several years [since about 1999]. (I got “distracted” by Extreme Programming 🙂 I’d still welcome any feedback on the ideas it contains. Introduction Goals: · What is a framework? · Show how to move from basic code to a framework. · Sensitize reader […]
Pattern Patter: Backpatching
Summary: Use mostly-sequential output streams by fixing them later. You’re generating a stream of output. Everything is mostly fine, except that you have some information that really belongs at the front of the file or at a few places in the middle. Forces Generating an output stream (mostly sequential). Information occasionally must go in earlier […]
Pattern Patter: Templates/Macros
Summary: You want to extend a language without writing a new compiler. Forces Working in a particular language. Want to extend it for convenience. Subroutines are not a convenient mechanism: either they’re unavailable or don’t fit syntactically. Example C is extended with a macro language. Pro*C (Oracle) extends C with Oracle features. Resolution Use a […]
Pattern Patter: Program Generator
Write a program to write programs. “I’d rather write programs to write programs than write programs.” Dick Sites [DEC], quoted by Jon Bentley in More Programming Pearls. Context Have a high-level specification of a program; want to be able to run it directly. Forces High-level specifications can’t be executed directly. An interpreter might be too slow. […]
Pattern Patter: Table-Driven Design
Summary: Code that’s tedious to write, but must be changed easily, can often be accommodated with a table-driven design. Forces Code is most easily written “ad-hoc”. There’s often a structural aspect that is constant even though the details change. Ad-hoc code is bulky because it repeats the “constant” part. Example Language grammars undergo numerous small […]
Build a compiler that compiles just before (or during) runtime to get benefits of both compilers and interpreters. [Architectural Pattern] Context Language implementation. Forces An interpreter has advantages over a compiler: It’s usually the fastest, easiest way to implement a language. The representation used by the interpreter can be space-efficient. The representation used by the […]