CSC223 2004F, Class 12: Make: A Tool for Building Programs Admin: * Reminder: If you miss class, send me an explanation * Today, this means Kat, among others * Note: If you keep missing class with the assumption taht "the eboards will suffice", I will stop creating eboards. (or you should talk to me) * Will REKS (the fearsome foursome) ever all show up to the same class? * Questions on the homework? * Create stubs for any classes you don't feel like implementing. * Good hierachical design should obviate the need for many classes. Overview: * Detour: Listeners * Problems Make addresses * Make basics * Make variables * Standard Make targets * Advanced Make /Detour: Listeners/ * Pages 4 and 5 of Design Patterns * "Standard" pattern: Model-View-Controller pattern * Often used for UI programs * Model: Keeps track of the "state" of your system * Controller: UI for changing state (typically) * View: UI for showing the "state" of your system * Models should not need to know much about their controllers or views (see diagram on real whiteboard) * Complication: What messages does a model send its views? * Option one: Precise description of change (Position X,Y now contains a Bug) * Option two: "I've changed", provide callbacks * Option three: Synthesis: "I've changed here"; provide valueAt(X,Y) * Given that * models should not know much about their views * models may have multiple views * models are not responsible for choosing their views * We need a way to connect models and views so that the models know which views to send messages to * Traditional solution: Listeners * Typical application: Event-oriented programming * More than one thing can listen for the same event * They must register that they're listening for that event * Sam recommends that you not use the javax listener stuff. /About Make/ * Problems in building large systems * Serious Dependency Trees (handled automatically by our Java compiler) * Multiple commands needed for one "action": Shove all my .class files into a .jar file in some standard action * Example * Create the .jar file * Copy it over * Similar example * Run SED on a file to generate source code * Compile that source code * Different systems have different configurations (many people have the Java compiler in /usr/bin/java, we have it in /opt/IBMJ1231321231/bin) * Make is the standard Unix tool for dealing with all three issues * Make was designed for C programmers, so lots of C stuff is automated. /Make Basics/ * Instructions for Make are put in a file called Makefile (or makefile) * Simplest instructions: rules for building something target: things-it-depends-on instructions-for-building-it * Example: make.jar: Ma.class Ke.class jar -c make.jar Ma.class Ke.class * A Jar file is a collection of .class files all shoved into one file. It is smaller and easier to transport. * To run a rule in a Makefile, type make target * Make then * Creates anything that the target depends on (recursively) * Updates the target using the instructions * Make also checks to see if any updates have been made since the last make * Warning: You must use a TAB before the instructions. /Variables in Make/ * Defining VARIABLE = value * Use $(VARIABLE) * Useful for shorthand * Useful for customization * Intended primarily for programmers distributing code to other programmers /Advanced Make/ * Problem: To create a .class file, comiple the correspnding .java file with $(JAVAC) * Note: $< is "the thing that the target depends upon" * Note: $* is "the prefix of the target"