Wednesday, September 15, 2010

Are you CTO Material?

from Time to Vanquish the Mythical Man Month:
"You have probably read this book. At a recent gathering of 25 CTO's, I asked who had read The Mythical Man Month, and 23 hands went up."
TLDR ...


sdf

Wednesday, September 8, 2010

Concurrency Quiz Based on Chapters 1 - 4 of Concurrency In Practice

The following quiz was compiled from keywords encountered in the first four chapters of Java Concurrency in Practice, a book I'm currently reading. If you find it to be interesting, hard, or new material, then maybe you should check it out! (You can download chapter 6 for free from the book website. I found it interesting enough to ear-beat one of my co-workers about it yesterday :-)

Quiz (all questions concern concurrent programming in Java 1.5+):

  1. What is thread-safety?
  2. Give an example of a check-then-act operation.
  3. What's a data race?
  4. What's a race condition? Describe a non-computer race condition.
  5. What's a liveness failure?
  6. Give an example of a read-modify-write operation.
  7. Which operations on primitives are not atomic?
  8. What's an intrinsic lock? A monitor lock?
  9. What's a mutex (mutual exclusion) lock?
  10. What is reentrancy? Are Java locks reentrant? Why?
  11. What is shared state? What effect does it have on thread-safety?
  12. Give an example of a compound operation in Java. What does it mean for thread-safety?
  13. What's a critical section? What's a best practice concerning them?
  14. What is memory visibility?
  15. What is statement reordering?
  16. How can a buggy concurrent program encounter stale data?
  17. What is out-of-thin-air safety?
  18. What does the 'volatile' keyword do?
  19. How is using the "-server" JVM command line switch helpful for debugging concurrent code?
  20. What does it mean to publish an object?
  21. What's an escaped reference?
  22. What's an alien method?
  23. What is thread confinement?
  24. What is ad-hoc thread confinement?
  25. What is stack confinement (also within-thread or thread-local confinement)? Why is it useful?
  26. What's the ThreadLocal class good for?
  27. How can you ensure the immutability of an object? What does immutability do for thread-safety?
  28. How can you get a reference to a partially constructed object?
  29. What can make the assertion below fail?
    public class Holder {
        private int n;
    
        public Holder(int n) { this.n = n; }
    
        public void assertSanity() {
            if (n != n)
                throw new AssertionError("This statement is false.");
        }
    }
    
  30. How do you ensure the safe publication of an object?

Sunday, September 5, 2010

The Case for Readable Code

The Case for Readable Code :
Readable code is the key to correct and maintainable programs.
...
Subclassing is evil

Saturday, September 4, 2010

Tony Hoare on the value of readable code

In his 1991 Turing Award Lecture, Tony Hoare succinctly stated the value of readable code
[Hoare-81]:
“There are two ways of constructing a software design:
One way is to make it so simple that there are obviously no deficiencies
and the other is to make it so complicated that there are no obvious deficiencies.
Reenskaug, Trygve. "The Common Sense of Object Orientated Programming"

The DCI Architecture: A New Vision of Object-Oriented Programming

The DCI Architecture: A New Vision of Object-Oriented Programming:
"Object-oriented programming was supposed to unify the perspectives of the programmer and the end user in computer code: a boon both to usability and program comprehension. While objects capture structure well, they fail to capture system action. DCI is a vision to capture the end user cognitive model of roles and interactions between them."