mercredi 16 décembre 2009

Touch of Class




As stated in the first sentence of the preface, «[Touch of class] is not just about learning to program but about “Learning to Program Well”». Meyer’s last book provides teaching material which has been gathered for more than a half a decade. It transmits an impressive experience in the field of computer science in general, going well beyond software engineering. This book does not assume any prior programming knowledge. It goes all the way up to modern programming by conveying wise advices, methodology, practices and historical anecdotes on how to achieve quality when programming. Software engineering concerns other than programming appears in the last chapters. The book's target audience is students and teachers.

Touch of class covers many different topics including the object paradigm, boolean logic, hardware, algorithm and many more. The goal of the book is certainly not to be exhaustive. Chapters named “Just enough ...” convey indispensable tools for good programming.

Object orientation and design by contract are central to the book. It successfully presents formals methods without loosing clarity. Instead of using complex mainstream languages, Eiffel Studio is the support for programming. Meyer argues in a convincing manner why Java is probably not the best language on Earth for an introductory course on programming.

A high importance is given to the vocabulary. Never a technical word is used without being carefully introduced. The large quantity of provided information is well organized. For example, “Touch of Style” boxes provides important and helpful advices on programming style whereas “Touch of Methodology” boxes give advices on programming methodology.

The book contains many figures. Rare are the pages left without a picture or a drawing. Colors are plentiful and character fonts plays an important role. The quality of the paper is high, making the tossing pleasant.

The book has a website (touch.ethz.ch), which contains supplementary material. At the time of writing this review, the website is announced but not yet available.

Coming from a father of object-orientation and software quality, it is not a surprise to find Touch of class an excellent book. It makes «the difference between a programmer who just “hacks code” and one who is able to produce correct, robust and durable software elements.»

jeudi 27 août 2009

Object Oriented Simulation -- A modeling and programming perspective




The objective of this work is best described with the first sentence of the preface: “The primary goal of this book is to introduce students to the basic principles of object-oriented modeling, design and implementation of simulation models.” The book succeeds in it. It further states “For undergraduate students, another goal is to provide relevant material for easy understanding of object orientation and simulation”. As described further down in this review, the book does not completely fulfill this second objective.

When skimming the content of the book, I enjoyed that a programming language stance has been adopted. However a deeper read may leave one on his hunger. The author remains shy on telling the limitation of general purpose programming languages for simulation. After having read the book, it is not clear whether I will loose something in adopting a language different from OOSimL for teaching Object Oriented Simulation.

The overall objective of the book is quite ambitious, and this is reflected by its content somehow. Part 2 is titled “Object Oriented Programming with OOSimL”. It covers using OOSimL the notion of software, program structure, object, classes, thread, exception and many more in only 200 pages. Motivating each of these topics in an assertive manner cannot be other than difficult and challenging. This part of the book can be easily shrunk. For example, the chapter 4 titled “Programs and Software Development” is rather superfluous. It is so light that it cannot be useful. A discussion and an enumeration of the points where OOSimL is superior than general purpose languages would have definitely consolidated the whole story.

The third part of the book, titled “discrete event simulation”, is didactic and clearly written. It covers and illustrate the important topics of the field such as multi-servers, event list, priorities, resources, waiting, interruptions and specification of input. The car-washing motivation is used as a recurrent example. It also provide a nice and concise introduction to distribution and confidence interval. The notion of clock is missing however.

All that said, this book deserves to be considered for teaching the modeling and programming of discrete event based simulations. Even if the part related to object-orientation is not optimal, it may be easily completed with dedicated manuel.

mercredi 22 avril 2009

Object Oriented JavaScript




Web 2.0 heavily relies on JavaScript. After being forgotten for a while, there is a tremendous interest in JavaScript and other web technologies. Real applications are now convoluted, which forces developers to follow a strict and disciplined programming style.

``Object Oriented JavaScript’’ nicely relates the large experience of Stoyan Stefanov in web programming. His book covers object-orientation in JavaScript and gives valuable information for both beginner and experienced practitioners. No prerequisite skill in both of these fields is assumed.

The first chapter helps the reader to set up a proper programming environment using Firefox and Firebug. This will help the reader to exercise along the reading. A brief introduction object-orientation is provided.

The second chapter enumerates important language constructs. This chapter is a bit unappetizing since it simply list syntactic constructions, without having a story to tell. Beginners will probably gain a quick grasp on the essential constructs (variable definition, loops, condition). Experienced programmers will not do more than quickly skimming.

Chapter 3 is much more interesting by reviewing different kinds of functions supported by JavaScript. Beginners will learn how to define and apply functions. Experienced readers will enjoy expressiveness of high-order functions (although this terms is not mentioned), self-modifying functions, and closures.

Chapter 4 is about objects. It shows the different ways to create objects and what are their associated operators. It also describes built-in objects, including RegExp, a linguistic construct to define regular expressions. Reader will probably miss the table of special characters that may be used in regular expressions.

Chapter 5 describes JavaScript’s prototype-based object model. It goes into deep details. However, the lack of motivating and useful examples has great potential for leaving JavaScript learners disoriented. It is like handing powerful tools to someone without explaining what they are good for. At the end of the chapter, it is still unclear when one should use ‘prototype’ instead of ‘__proto__’ or constructor’s prototype.

Chapter 6 deals about inheritance and brings to the light some uncertainties left by the precedent chapter. It reviews different ways to create and simulate inheritance, some having a heavy hackish flavor.
A wrong definition of what mixins are is unfortunately given. The first concrete example of the book comes at the end of this chapter. Readers will enjoy the JavaScript version of the ubiquitous geometrical shape example.

Chapter 7 is about the browser environment. It summarizes in 55 pages how your JavaScript program may retrieve information from a web browser, webpages, how it may attach an event to any piece of html code, and updates a subpart of html pages. This is at the very root of AJAX’ success.

The last chapter provides a nice set of JavaScript specific design patterns and good programming practices. One of these patterns is troubling. The Init-Time Branching pattern promotes the use of conditional statement to discriminate the version of the user web browser. A double dispatch would be more convenient.

Each chapter proposes few exercises and ends with a summary. References for further reading are provided time to time. More would have been welcome. The book uses a compilation of independent small do-it expressions and foobar examples. No construction of a useful application is presented. This is sad since readers will be left to themselves looking for a practical application. The few pictures are not always clear (e.g., Page 182).

This book is free from a serious Software Engineering consideration. This is a bit troubling since the book aims at focusing on creating scalable, reusable high-quality applications and libraries. No much is said regarding how the development phase of a multi-developpers project must be conducted, as well how to gain scalability and identity bottlenecks in web applications.

All that said, even if it will probably be complemented by other sources, I recommend ``Object-Oriented JavaScript’’ to people looking for a broad and deep presentation of JavaScript.

lundi 6 avril 2009

A comprehensive Introduction to Object-Oriented Programming with Java




This book introduces the basic concepts of object-orientation in Java. It is intended for beginners such as CS1 and CS2 classes. This book must not be taken as a reference by people seeking for deep explanations and motivation on key concepts. This book may not be used for more than giving an introduction.

This book is organized into 21 chapters (numbered from 0 to 20). Chapter 0 is an optional chapter. It provides a general background on computers and programming languages. Chapter 1 provides in 14 pages the essence of object orientation, software engineering and software development methodology. Chapter 2 covers the basics of file editing, compiling and program execution. Simple examples are clearly described. Chapter 3 is about numerical data.

Chapter 4 teaches the basic of creating programmer-defined classes. This chapter covers visibility modifiers, local variables, and passing data to messages. Chapter 5 presents the need of the if and switch statements. Chapter 6 explains the repetition statements while, do-while, and for. Pitfalls in writing repetition statements are presented. The author argues that one important pitfall is to avoid the use of float or double for the data type of a counter variable. Section 6.10 is about recursive methods. This section is marked as optional.

Chapter 7 is the second part of creating programmer-defined classes. It introduce the this pseudo variable. Chapter 8 is about exceptions. Chapter 9 covers non-numerical data types including characters and strings. Chapter 10 teaches arrays. Chapter 11 presents searching and sorting algorithms and provides background on algorithm complexity. Chapter 12 explains the file I/O (e.g., File, JFileChooser).

Chapter 13 discusses inheritance and polymorphism and how to use them effectively in program design. Chapter 14 covers GUI and event-driven programming. Chapter 15 covers recursions. Chapter 16 covers contiguous and noncontiguous memory allocation schemes and introduces the concept of linked lists. Chapter 17 covers generics. Chapters 18, 19 and 20 introduces the concepts of abstract data types such as lists, stacks, and queues.

Numerical operations and number manipulation is at the heart of Chapter 3. Solving mathematical equations are part of the proposed exercises. Putting this chapter so early in the book organization may hamper readers from entirely focusing on the Java language and object-orientation. In addition to solving these equations, difficult part of the Java language such as casting between numerical primitive types are presented in this chapter. People without a strong mathematical interest may find the need for this chapter at a so early stage irrelevant.

Inheritance and polymorphism are introduced in the book organization very lately (Chapter 13). Talking about the collections framework (Chapter 10), sorting and searching (Chapter 11) before having a clear description of inheritance is risky. Page 738 provides the following design guideline “Use the Java interface to share common behavior. Use the inheritance to share common code.” Hard to not see this guideline as misleading or wrong. Making classes use an interface guaranties that a common set of messages will be understood by instances of the classes at runtime. It has nothing to do with behavior sharing. Inheritance should not be used to share common code, but rather expressing specialization. This is quite surprising to have introduced the if and switch statement in Chapter 5 and presenting polymorphism in Chapter 13. One application of polymorphism is to prevent the usage of switch by applying the double dispatch design pattern.

Using this book as a lecture support must be done with care. The book has a strong mathematical focus and the presentation of the key concepts of object-orientation do not provide sufficient insight to fully convey the benefit of object-orientation and Java over procedural programming.

The SICS Java Port Project







This book relates the migration of a large Smalltalk system to Java. This migration was essentially based on a semi-automated source code translation: each Smalltalk class, method and instruction is translated into Java. This experience report presents challenges of this rewriting from a technical point of view. It basically compares the paradigm of Smalltalk and Java and presents translating rules and patterns.

After a brief introduction to Smalltalk, Chapter 3 provides the vocabulary to describes the types used by the type inferencer. Chapter 4 provides an extended description of typing issues that may occur when migrating (including generating casts and translating to generics). Mapping Smalltalk control flow construction into Java are covered in Chapter 5 until Chapter 9. The mapping is rather unsurprising. Mapping singular Smalltalk points (blocks in Chapter 8 and the numerical computational model in Chapter 9) are probably the most exiting chapters. Limitation of Java are clearly apparent. Remaining chapters (10 - 15) are about the Smalltalk features that are missing in Java (e.g., class extensions, intersession, advanced error handling mechanism). The mapping is essentially ad hoc in that case. Chapters 16 and 17 conclude.

Although it clearly emerges that a special care is given to be accurate, some points are left unclear. For example, a deeper analysis on the use of meta-classes in Smalltalk would be welcome. Smalltalk supports meta-classes and Java does not. As rightfully pointed out by the author, migrating a hierarchy of meta-classes to Java is not trivial. But it is left unclear why meta-classes in Smalltalk are essentially used to define constructor. Polymorphism involving meta-classes is rarely employed. Another point: Page 39 says “As Smalltalk is a dynamically typed language, there is not really any concept of types”. This is incorrect. In Smalltalk, type enforcement happens at runtime, instead of at compile-time. The whole discussion about types is done in a very informal way, which misses accuracy.

The translation strategies remains very technical without giving any high-level perspective. In particular, a software engineering perspective is missing. The book is about how the migration was conducted, and no indication is provided about why the migration was necessary. It seems to be taken for granted that adopting the Java platform is a step forward, but no discussion about long-term company strategy is provided. A discussion about the rational of such major decisions would have been of a great value, since chapters 10 until 15 are about Java limitations and weaknesses and Section 15.4 says the translated version is four time larger than the original Smalltalk application.

These criticisms aside, the book presents a well-thought semi-automated solution on how to translate a dynamically typed language into a statically typed one taking meta-classes and reflection into account.

Effective Java





Experienced object-oriented programmers eager to produce code of a better quality will greatly appreciate this book. Although the title mentions Java, the advices, discussions, and analyzes offered go well beyond the scope of Java. The content of this book provides coding recommendations for a wide spectrum of practices ranging from general programming (e.g., favoring interfaces over reflection) to Java-specific aspects (e.g., good use of annotation , enumeration, and generics). This book is not suitable for beginners since it requires a solid software engineering experience to fully grasp its content.

Each chapter consists of items, each item providing a well detailed coding style recommendation. The 11 chapters elaborates on 78 items in total. Chapter 2 is about objets creation and destruction. Favoring object factories instead of ad-hoc constructors and avoiding pitfall of obsolete references are the essence of this chapter. Chapter 3 discusses how and when to compare objects. It provides a comprehensible description of hashing functions and how to write them. It also makes a good case why hashCode() must be redefined when providing a new equals().

Chapter 4 is about classes and interfaces. Enforcing encapsulation is well exemplified. Chapter 5 is a more Java specific by being about Generics. It shows how to avoid code pollution with unchecked warnings and why lists should be favored over arrays. Chapter 6 is also very Java specific by discussing the usage of enums and annotations. Chapter 7 discusses several aspects of method design (how to treat parameters, return values, how to design and document method signature).

Chapter 8 discusses notions of general programming such as local variables, control structures, libraries and data types. Chapter 9 provides guidelines for using exceptions effectively. Among the different tackled items, it provides a nice discussion about the three kinds of throwables (checked exception, runtime exceptions, and errors) and the principle of failure atomicity. Chapter 10 contains advices to help you write clear, correct, well-documented concurrent programs. Concurrency is a hard topic that is addressed by providing reasonable, simple but effective advices. Chapter 11 discusses objects serialization. A notable feature of this chapter is the serialization proxy pattern which can help to avoid many of the pitfalls of object serialization.

The book is very pleasant to read. For example, most of items are introduced with a small code excerpt preceded with a “can you spot the bug?”. This raises the interactivity the book can have with its readers.

Most of the advices provided in this book are refreshing and some are though-provoking. Most of modern IDEs provides automated checks on source code. “Effective Java” will help programmers to understand the rational behind some of those checks.

All that said, this book is a must for Java and non-Java programmers. The significant amount of knowledge this book compiles makes its reading worth.