Dynamic Web Development with Seaside

Buy PDF Buy Print

1.5Formatting Conventions

We need to say a word about formatting conventions before we proceed. In Pharo, as in most Smalltalk implementations, you edit code using a code browser as we will show you in the next Chapter. To look at the code for a method, you select a package, then a class, a method category and finally the method you want to see. The method’s class is always visible. When reading a book, a method’s class may not be so obvious.

To help your understanding of the code we present, we will follow a common convention to display Smalltalk code: we will prefix a method signature with its class name. Here is an example. Suppose you need to enter the method renderContentOn: in your browser, and this method is in the class: WebSudoku. You will see the following code in your browser.

renderContentOn: html
html div
id: 'board';
with: [ html form: [ self renderBoardOn: html ] ]

To help you remember that this method is defined in the class WebSudoku, we will write it as follows:

WebSudoku>>renderContentOn: html
html div
id: 'board';
with: [ html form: [ self renderBoardOn: html ] ]

When you enter the text for this method, you do not type WebSudoku>>. It is there only so you will know the method’s class. We will use a similar convention in the running text. To be precise about a method and its class, we will use WebSudoku>>renderContentOn:.

In Smalltalk, a class and an instance of a class both have methods. The class methods are analogous to static methods in Java. Class methods respond to messages sent to the class itself. To make it clear that we are talking about a class method, we will refer to it using WebSudoku class>>canBeRoot. For example, here is the definition of the class method canBeRoot, defined on the class WebSudoku:

WebSudoku class>>canBeRoot
^ true

We use the following annotations for specific notes:

This is a side-note and might be interesting to readers more curious about the topic.

This is a remark covering advanced topics. It can be safely skipped on the first pass through the book.

This is an important note, if you do not follow the suggestions you are likely to get into trouble.

Copyright © 26 February 2017 Stéphane Ducasse, Lukas Renggli, C. David Shaffer, Rick Zaccone
This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license.

This book is published using Seaside, Magritte and the Pier book publishing engine.