Informatics 102 Spring 2012
Code Examples


Code examples, from lecture and otherwise

Over the course of the quarter, I'll be providing commented code examples for you. You are not permitted to copy and paste any of this code into your own projects. These examples are mostly to give you clean and well-documented examples of some of the things we cover in lecture (and possibly a few things that we don't, time permitting), so that you can be free in lecture to avoid trying to take detailed notes when we're writing code together, instead concentrating on understanding the process and the bigger-picture concepts at work.

Lecture Date(s) Description
Th 4/5 An aspect that adds generalized method-tracing to a Java program
Th 4/5 Using an aspect to address a concern that crosscuts a single class
Tu 4/10 An aspect that requires an object to be initialized properly before certain methods can be called legally
Tu 4/10 An aspect that injects support for caching the results of a slow method
Tu 4/10 Using an aspect to inject methods and inheritance relationships into existing classes
Th 4/12 Using a dynamic cflow pointcut to detect recursion
Th 4/12 Writing a pointcut that selects a "varargs" method and hoists its parameters out into advice
Th 4/12 Java annotations and using AspectJ to declare new compile-time errors and warnings
Tu 4/17 Generalizing the Student initialization example using annotations
Tu 4/17 Revisiting our caching example, with annotations used as an improvement
Th 4/19 Our QuickUnit unit testing framework, illustrating the use of reflection and annotations
Th 5/3 A simple Erlang process that says "I am happy!" every five seconds until it's shut down
Th 5/3 A simple Erlang server process that calculates the area of rectangles and circles
Th 5/3 The area server rewritten as an Erlang actor, hiding message passing details beneath a simpler interface
Tu 5/8 Our implementation of the MapReduce algorithm in Erlang
Tu 5/15 Using Erlang ports to communicate between an Erlang interpreter and a Java program
Th 5/17 Using Protocol Buffers from Java to serialize a message into a file and read it back again
Tu 5/22 Writing a recursive-descent parser, given a suitably-written grammar
Th 5/24 Separating scanning from parsing, including writing a custom scanner
Tu 5/29
Th 5/31
Designing and implementing a simple domain-specific language