Inversion of Control IoC
Inversion of Control (IoC) means that objects do not create other objects on which they rely to do their work. Instead, they get the objects that they need from an outside source (for example, an xml configuration file).
Threading in C# - Basic Synchronization
Locking Constructs
Construct
Purpose
Cross-Process?
Speed
Ensures just one thread can access a resource, or section of code.
no
fast
Ensures just one thread can access a resource, or section of code.
Can be used to prevent multiple instances of an application from starting.moderate
Ensures not more than a specified number of threads can access a resource, or section of code.
yes
moderate
Java Collection Interfaces and Classes Hierarchy

The collection interfaces are laid out as follows:
* The Collection interface is a group of objects, with duplicates allowed
* Set extends Collection but forbids duplicates
* List extends Collection also, allows duplicates and introduces positional indexing
* Map extends neither Set nor Collection
What is Windows Azure?
Amazing hand drawn video. The screen capture was done with Community Clips, and believe it or not, recorded in PowerPoint!
How to Design a Good API by Josh Bloch
This is a must read for every Sr Developer / Architect.
What is Functional Programming?
What is Functional Programming?
If you have been writing code for a long time with an object-oriented language (such as Java or C#) it may be difficult to imagine a different way to approach programming. Functional programming does just that. At the heart of functional programming is a new way to address a software problem- by focusing on the function decomposition of the algorithm(s). With functional programming, functions are first class citizens. If you come from the Java world, you can already appreciate the difference. In Java, the only way to express a method is as a component of a class.
Although a recent uptick in special purpose languages has gotten all the attention, functional programming is a technique and not necessarily a language. It is possible to write in a functional way with a general purpose or object-oriented language (in a later section we examine a functional example written in C#). Although it is possible, for anything significant, the lack of expressiveness quickly becomes apparent and anti-patterns start to crop up. Imagine trying to write an object-oriented program of any significant size using Java without the keywords extend or implements. These difficulties naturally lead to the need for a new language; a functional language.
Brief History of Scala by Martin Odersky
This is my first blog at Artima.com. I'll be writing mostly about language design and the Scala programming language.
But first, let me introduce myself. At university, I had my first programming class (in Algol60, no less! -- I believe we were the last class to be taught in that language). Whenever my program had a syntax error, the TA of the course mumbled something about my program not passing the compiler. I deduced that a compiler would be a sort of small computer that would be sitting between my teletype and the real computer. Its task would be to prepare my program so that the real computer could concentrate on the hard part, which would be executing the program I wrote. It seemed to me at the time that compilation was much simpler than, say, evaluating a polynomial with Horner's rule.
When I found out what a compiler really was, I was hooked. I went on to write compilers for Pascal and Modula-2. Afterwards, I joined Niklaus Wirth's group at ETH Zuerich as a Ph.D. student, working on Modula-2 and Oberon. After that, I fell in love with functional programming and wrote a lot of papers on calculi and type systems for functional programming languages (most of them are on my www.epfl.ch/%7Eodersky/papers" class="reference">website).
In 1995 I learned about Java and teamed up with Philip Wadler to write a functional language that compiles to Java bytecodes. This work on Pizza led eventually to GJ, the new javac compiler, and Java generics. It was exciting to do work on Java because of its huge impact, but it was also very difficult because Java is a rich language with many features which often conflict with extensions in unforeseen ways.
In 1999, I joined EPFL. I thought that I would now use my academic freedom to do language design starting from a clean sheet. I still wanted to combine functional and object-oriented programming, but without the restrictions imposed by Java. I had found out about join calculus, and believed that this would be a great foundation on which to base such a unification. The result was www.epfl.ch/funnel" class="reference">Funnel, a programming language for www.epfl.ch/%7Eodersky/papers/esop2000.html" class="reference">functional nets. This was a beautifully simple design, with very few primitive language features. Almost everything, including classes and pattern matching, would be done by libraries and encodings.
However, it turned out that the language was not very pleasant to use in practice. Minimalism is great for language designers but not for users. Non-expert users don't know how to do the necessary encodings, and expert users get bored having to do them over and over again. Also, it became quickly apparent that any new language has a chance of being accepted only if it comes with a large set of standard libraries.
Funnel led to Scala, whose design began in 2001, and which was first released in 2003. Scala is not an extension of Java, but it is completely interoperable with it. Scala translates to Java bytecodes, and the efficiency of its compiled programs usually equals Java's. A second implementation of Scala compiles to .NET. (this version is currently out of date, however).
Scala was designed to be both object-oriented and functional. It is a pure object-oriented language in the sense that every value is an object. Objects are defined by classes, which can be composed using mixin composition. Scala is also a functional language in the sense that every function is a value. Functions can be nested, and they can operate on data using pattern matching.
The Scala user community is still relatively small, but it's growing. We currently see about 1000 downloads per month of the Scala distribution on our website.
I'll write more about specific aspects of Scala in the coming blogs. For now I log off with the "hello-world" program written in Scala:
object HelloWorld extends Application { Console.println("Hello World") }
QCon San Francisco 2009 Conference

A Strategy for Defining Immutable Objects in Java
The following rules define a simple strategy for creating immutable objects. Not all classes documented as "immutable" follow these rules. This does not necessarily mean the creators of these classes were sloppy — they may have good reason for believing that instances of their classes never change after construction. However, such strategies require sophisticated analysis and are not for beginners.
- Don't provide "setter" methods — methods that modify fields or objects referred to by fields.
- Make all fields
finalandprivate.- Don't allow subclasses to override methods. The simplest way to do this is to declare the class as
final. A more sophisticated approach is to make the constructorprivateand construct instances in factory methods.- If the instance fields include references to mutable objects, don't allow those objects to be changed:
- Don't provide methods that modify the mutable objects.
- Don't share references to the mutable objects. Never store references to external, mutable objects passed to the constructor; if necessary, create copies, and store references to the copies. Similarly, create copies of your internal mutable objects when necessary to avoid returning the originals in your methods.
Applying this strategy to
SynchronizedRGBresults in the following steps:After these changes, we have
- There are two setter methods in this class. The first one,
set, arbitrarily transforms the object, and has no place in an immutable version of the class. The second one,invert, can be adapted by having it create a new object instead of modifying the existing one.- All fields are already
private; they are further qualified asfinal.- The class itself is declared
final.- Only one field refers to an object, and that object is itself immutable. Therefore, no safeguards against changing the state of "contained" mutable objects are necessary.
:ImmutableRGBfinal public class ImmutableRGB { //Values must be between 0 and 255. final private int red; final private int green; final private int blue; final private String name; private void check(int red, int green, int blue) { if (red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255) { throw new IllegalArgumentException(); } } public ImmutableRGB(int red, int green, int blue, String name) { check(red, green, blue); this.red = red; this.green = green; this.blue = blue; this.name = name; } public int getRGB() { return ((red << 16) | (green << 8) | blue); } public String getName() { return name; } public ImmutableRGB invert() { return new ImmutableRGB(255 - red, 255 - green, 255 - blue, "Inverse of " + name); } }




