Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
C#for Java Developersdhaval.dalal@software-artisan.com@softwareartisan
A Broad Overview.NET Platform JVM PlatformILIntermediateLanguageBytecodeC# F# VB.NET Java Groovy ScalaCLR(Common Language ...
Technology StackJava C#Data AccessClient Side GUIWeb Side GUIWeb ScriptingWeb HostingRemote InvocationMessagingNativeDirec...
Language ComparisonJava C#Program Entry PointNamespaceIncluding ClassesInheritanceOverridingAccessing Parent CtorAccessing...
Language ComparisonJava C#Abstract ClassNon-Extensible ClassNon-Writable FieldNon-Extensible MethodConstantChecking Instan...
Language ComparisonJava C#Method ParametersVariable ArgumentsExceptionsADT Meta TypeMeta InformationStatic classProperties...
Language ComparisonJava C#Deterministic Object CleanupGenericsClass Loadingsynchronized blocksynchronized methodThread Loc...
Specific to C#• Aliases• Verbatim Strings• var• Partial Class/Method• Object Initializer• Named Args• Optional Args• Value ...
Value TypeorRef Type?Value Typeuse ==Reference Type useReferenceEqualsSpecific to C#: Equality• ForValue Types, default Equ...
Equality Similarities• Define Equals(object other) and hashCode as apart of the contract• Define both in terms of immutable ...
Specific to C#: Equality• Use Exact object argument - Equals for use inCollections and for performance.• IEquatable<T>• Pre...
Implicit & ExplicitInterfaces01. interface Greet1 {02. public String greet();03. }04.05. interface Greet2 {06. public Stri...
Implicit & ExplicitInterfaces01. interface Greet1 {02. public String greet();03. }04.05. interface Greet2 {06. public Stri...
Implicit & ExplicitInterfaces01. interface Greet1 {02. public String greet();03. }04.05. interface Greet2 {06. public Stri...
Implicit & ExplicitInterfaces01. interface Greet1 {02. public String greet();03. }04.05. interface Greet2 {06. public Stri...
Specific to C#: ExplicitInterfaces
Specific to C#: ExplicitInterfaces01. interface Greet1 // v1.002. {03. string Greet();04. }05. interface Greet2 //v2.006. {...
Specific to C#: ExplicitInterfaces01. interface Greet1 // v1.002. {03. string Greet();04. }05. interface Greet2 : Greet1 //...
Specific to C#: ExplicitInterfaces01. interface Greet1 // v1.002. {03. string Greet();04. }05. interface Greet2 : Greet1 //...
Similarities• Immutable Strings• Serialization• Boxing• ConvertValue Type to a Reference Type• Unboxing• Convert Reference...
Similarities• Collections• C# - IList, IDictionary, Queue, Stack• Java - List, Map, Queue, Stack• for-each Collection Iter...
Specific to C#• Collection Initializer• Coroutines (more precisely Generators)• yield break• yield return01. public static ...
Specific to C#• Collection Initializer• Coroutines (more precisely Generators)• yield break• yield return01. class Fibonacc...
Covariance &Contravariance• Covariance• Pass collection of sub-class to a collection of base class• Contravariance• Pass c...
Arrays and GenericCollections• Arrays are Covariant in C# and Java• There is a hole in the type system and a runtime patch...
C# Example
C# Example01. abstract class Animal {02. public abstract string Speak();03. }04.05. class Cat : Animal {06. public string ...
C# Example01. abstract class Animal {02. public abstract string Speak();03. }04.05. class Cat : Animal {06. public string ...
Java Example
Java Example01. abstract class Animal {02. public abstract String speak();03. }04.05. class Cat extends Animal {06. public...
Java Example01. class TestCollections {02. public static void main(String []args) {03. Cat cat = new Cat();04. Animal anim...
Specific to C#• Anonymous Types• Anonymous Methods/Delegates• Pass Methods as Data• Action: No return values• Func: Non-voi...
Specific to C#• Events• Syntactic sugar over delegates, but with visibility• Events can only be invoked from within the cla...
Dynamic Runtime LibraryCLR(Common Language Runtime)DLR(Dynamic Language Runtime)C#VB.NETPythonRuby• Allows you to talk wit...
Specific to C#• Avoid Configuration hell• Single Configuration File (App.config)• Asynchronous Programming• BeginInvoke and E...
Specific to Java• Static Imports• Instance and Static Initializers• Interfaces Containing Fields• Anonymous Classes• Proxy ...
Specific to Java• Asynchronous Programming• Future Task• Poll Completion with isDone().• Execute callback upon completion• ...
Frameworks and ToolsJava C#Dependency InjectionFrameworksORM FrameworksProxying/AOP FrameworksTDD FrameworksMocking Framew...
References• MSDN Site• Venkat Subramaniam• http://agiledeveloper.com/presentations/CSharpForJavaProgrammers.zip• Wikipedia...
Upcoming SlideShare
Loading in …5
×

C# for-java-developers

4,367 views

Published on

Published in: Technology, News & Politics
  • Be the first to comment

C# for-java-developers

  1. 1. C#for Java Developersdhaval.dalal@software-artisan.com@softwareartisan
  2. 2. A Broad Overview.NET Platform JVM PlatformILIntermediateLanguageBytecodeC# F# VB.NET Java Groovy ScalaCLR(Common Language Runtime)Win Win Mac UnixLinuxcsc javacgroovycfscvbcscalacJRE(Java Runtime Environment)Mono
  3. 3. Technology StackJava C#Data AccessClient Side GUIWeb Side GUIWeb ScriptingWeb HostingRemote InvocationMessagingNativeDirectory AccessComponentizationJDBC ADO.NETAWT/Swing WinForms, WPFJSP, JavaFX, JSF ASP.NET, WebFormsServlets, FiltersISAPI, HttpHandler,HttpModuleTomcat, Jetty, Weblogicetc...IISRMI, Netty, AKKA Remoting, now part of WCFJMS, AKKA MSMQJNI PInvokeJNDI Active Directory (Ldap/ADSI)EJB (Entity/Session), SpringCOM+, Managed ExtensibilityFramework (MEF)
  4. 4. Language ComparisonJava C#Program Entry PointNamespaceIncluding ClassesInheritanceOverridingAccessing Parent CtorAccessing Parent MethodVisibilitymain(String ...args)Main() orMain(string [] args)package namespaceimport usingclass (extends),interface (implements)class and interface (:)virtual by defaultnon-virtual by defaultuse virtual keywordsuper(...) : base(...)super.method(...) base.Method(...)private, package,protected, publicprivate, protected, internal,internal protected, public
  5. 5. Language ComparisonJava C#Abstract ClassNon-Extensible ClassNon-Writable FieldNon-Extensible MethodConstantChecking Instance TypeEnumsfor-each constructSwitch-Caseabstract class X { ... } abstract class X { ... }final class X { ... } sealed class X { ... }final readonlyfinal sealedstatic final constinstanceof isenum, can have fields, methods andimplement interfaces and are typesafeenum, cannot have methods,fields or implementinterfaces, not typesafefor (item : collection){ ... }foreach(item in collection){ ... }numeric types (int,float...) enums, and nowstrings (in Java 7)numeric types, enums andstrings
  6. 6. Language ComparisonJava C#Method ParametersVariable ArgumentsExceptionsADT Meta TypeMeta InformationStatic classPropertiesNon-Deterministic ObjectCleanupObject References arepassed by Value onlyObject reference are passedby Value(default), ref & outmethod(type... args) Method(params type[] args)Checked and Unchecked(enforced by javac, not by JITcompiler)All Unchecked ExceptionsClassClass klass = X.class;TypeType type = typeof(X);@Annotation [Attribute]Simulated by private Ctorand static methodsStatic class and ctor withstatic methodsgetProperty(),setProperty()Property { get; set; }compiler generatedget_Property() andset_Property() methodsfinalize() destructor ~X()
  7. 7. Language ComparisonJava C#Deterministic Object CleanupGenericsClass Loadingsynchronized blocksynchronized methodThread Local StorageSmallest Deployment UnitSigningAutoCloseable or Closeabletry-with-resources (Java 7)try ( ... ) { ... }IDisposableusing ( ... ) { ... }<T>, <T extends Type>, <?>Type Erasure<T>, where T : type, new()Preserves Type InfoClass.forName(“fqn”)ClassLoader.getResources()Activator.CreateInstance<T>()Assembly.Load()synchronized (this) { ... } lock (this) { ... }synchronized method(){ ... }[MethodImpl(MethodImplOptions.Synchronized)]void Method() { ... }Thread relative static fieldsThread relative static fields[ThreadStatic] and Data SlotsJarEXE/DLLPrivate Assembly, Shared AssemblyJar Signing Assembly Signing
  8. 8. Specific to C#• Aliases• Verbatim Strings• var• Partial Class/Method• Object Initializer• Named Args• Optional Args• Value Types(struct)• Nullable Types• Safe Cast• Tuples• Extension Methods• Operator Overloading• Indexer
  9. 9. Value TypeorRef Type?Value Typeuse ==Reference Type useReferenceEqualsSpecific to C#: Equality• ForValue Types, default Equals implementation usesreflection on fields.• Override Equals for Reference Types• Use the same strategy forValue Types, it is moreperformant and consistent as well.
  10. 10. Equality Similarities• Define Equals(object other) and hashCode as apart of the contract• Define both in terms of immutable fields• It should be• Reflexive: x.Equals(x) => True• Symmetric: if x.Equals(y) then y.Equals(x) => True• Transitive: x.Equals(y) and y.Equals(z), then x.Equals(z) =>True
  11. 11. Specific to C#: Equality• Use Exact object argument - Equals for use inCollections and for performance.• IEquatable<T>• PreserveValue Semantics forValue Types• Overload == operator
  12. 12. Implicit & ExplicitInterfaces01. interface Greet1 {02. public String greet();03. }04.05. interface Greet2 {06. public String greet();07. }08.09. public class Greeter implements Greet1, Greet2 {10. //Implicit Implementation11. public String greet() {12. {13. return “Hello”;14. }15.16. public static void main(String ...args) {17. Greet1 greeter1 = new Greeter();18. greeter1.greet(); // Hello19.20. Greet2 greeter2 = new Greeter();21. greeter2.greet(); // Hello22.23. Greeter greeter = new Greeter();24. greeter.greet(); // Hello25. }26. }
  13. 13. Implicit & ExplicitInterfaces01. interface Greet1 {02. public String greet();03. }04.05. interface Greet2 {06. public String greet();07. }08.09. public class Greeter implements Greet1, Greet2 {10. //Implicit Implementation11. public String greet() {12. {13. return “Hello”;14. }15.16. public static void main(String ...args) {17. Greet1 greeter1 = new Greeter();18. greeter1.greet(); // Hello19.20. Greet2 greeter2 = new Greeter();21. greeter2.greet(); // Hello22.23. Greeter greeter = new Greeter();24. greeter.greet(); // Hello25. }26. }Java: Implicit means whether you use Greet1 orGreet2, it invokes the same implementation.
  14. 14. Implicit & ExplicitInterfaces01. interface Greet1 {02. public String greet();03. }04.05. interface Greet2 {06. public String greet();07. }08.09. public class Greeter implements Greet1, Greet2 {10. //Implicit Implementation11. public String greet() {12. {13. return “Hello”;14. }15.16. public static void main(String ...args) {17. Greet1 greeter1 = new Greeter();18. greeter1.greet(); // Hello19.20. Greet2 greeter2 = new Greeter();21. greeter2.greet(); // Hello22.23. Greeter greeter = new Greeter();24. greeter.greet(); // Hello25. }26. }Java: Implicit means whether you use Greet1 orGreet2, it invokes the same implementation.01. interface Greet102. {03. string Greet();04. }05. interface Greet206. {07. string Greet();08. }09. public class Greeter : Greet1, Greet210. {11. //Implicit Implementation12. public string Greet() //Note the Visibility here13. {14. return “Hello”;15. }16.17. public static void Main()18. {19. Greet1 greeter1 = new Greeter();20. greeter1.Greet(); // Hello21. Greet2 greeter2 = new Greeter();22. greeter2.Greet(); // Hello23. Greeter greeter = new Greeter();24. greeter.Greet(); // Hello25. }26. }
  15. 15. Implicit & ExplicitInterfaces01. interface Greet1 {02. public String greet();03. }04.05. interface Greet2 {06. public String greet();07. }08.09. public class Greeter implements Greet1, Greet2 {10. //Implicit Implementation11. public String greet() {12. {13. return “Hello”;14. }15.16. public static void main(String ...args) {17. Greet1 greeter1 = new Greeter();18. greeter1.greet(); // Hello19.20. Greet2 greeter2 = new Greeter();21. greeter2.greet(); // Hello22.23. Greeter greeter = new Greeter();24. greeter.greet(); // Hello25. }26. }Java: Implicit means whether you use Greet1 orGreet2, it invokes the same implementation.01. interface Greet102. {03. string Greet();04. }05. interface Greet206. {07. string Greet();08. }09. public class Greeter : Greet1, Greet210. {11. //Implicit Implementation12. public string Greet() //Note the Visibility here13. {14. return “Hello”;15. }16.17. public static void Main()18. {19. Greet1 greeter1 = new Greeter();20. greeter1.Greet(); // Hello21. Greet2 greeter2 = new Greeter();22. greeter2.Greet(); // Hello23. Greeter greeter = new Greeter();24. greeter.Greet(); // Hello25. }26. }C#: Implicit interface implementation
  16. 16. Specific to C#: ExplicitInterfaces
  17. 17. Specific to C#: ExplicitInterfaces01. interface Greet1 // v1.002. {03. string Greet();04. }05. interface Greet2 //v2.006. {07. string Greet();08. }09. public class Greeter : Greet1, Greet210. {11. //Explicit Implementations12. string Greet1.Greet() //Note the Visibility here13. {14. return “Hello from 1”;15. }16. string Greet2.Greet() //public not allowed for explicit17. {18. return “Hello from 2”;19. }20. public static void Main()21. {22. Greet1 greeter1 = new Greeter();23. greeter1.Greet(); // Hello from 124. Greet2 greeter2 = new Greeter();25. greeter2.Greet(); // Hello from 226. Greeter greeter = new Greeter();27. greeter. // No Greeters to Greet unless I cast28. }29. }
  18. 18. Specific to C#: ExplicitInterfaces01. interface Greet1 // v1.002. {03. string Greet();04. }05. interface Greet2 : Greet1 // v2.006. {07. new string Greet();08. }09. public class Greeter : Greet210. {11. //Explicit Implementations12. string Greet1.Greet() //Note the Visibility here13. {14. return “Hello from 1”;15. }16. string Greet2.Greet() //public not allowed for explicit17. {18. return “Hello from 2”;19. }20. public static void Main()21. {22. Greet1 greeter1 = new Greeter();23. greeter1.Greet(); // Hello from 124. Greet2 greeter2 = new Greeter();25. greeter2.Greet(); // Hello from 226. Greeter greeter = new Greeter();27. greeter. // No Greeters to Greet unless I cast28. }29. }01. interface Greet1 // v1.002. {03. string Greet();04. }05. interface Greet2 //v2.006. {07. string Greet();08. }09. public class Greeter : Greet1, Greet210. {11. //Explicit Implementations12. string Greet1.Greet() //Note the Visibility here13. {14. return “Hello from 1”;15. }16. string Greet2.Greet() //public not allowed for explicit17. {18. return “Hello from 2”;19. }20. public static void Main()21. {22. Greet1 greeter1 = new Greeter();23. greeter1.Greet(); // Hello from 124. Greet2 greeter2 = new Greeter();25. greeter2.Greet(); // Hello from 226. Greeter greeter = new Greeter();27. greeter. // No Greeters to Greet unless I cast28. }29. }
  19. 19. Specific to C#: ExplicitInterfaces01. interface Greet1 // v1.002. {03. string Greet();04. }05. interface Greet2 : Greet1 // v2.006. {07. new string Greet();08. }09. public class Greeter : Greet210. {11. //Explicit Implementations12. string Greet1.Greet() //Note the Visibility here13. {14. return “Hello from 1”;15. }16. string Greet2.Greet() //public not allowed for explicit17. {18. return “Hello from 2”;19. }20. public static void Main()21. {22. Greet1 greeter1 = new Greeter();23. greeter1.Greet(); // Hello from 124. Greet2 greeter2 = new Greeter();25. greeter2.Greet(); // Hello from 226. Greeter greeter = new Greeter();27. greeter. // No Greeters to Greet unless I cast28. }29. }01. interface Greet1 // v1.002. {03. string Greet();04. }05. interface Greet2 //v2.006. {07. string Greet();08. }09. public class Greeter : Greet1, Greet210. {11. //Explicit Implementations12. string Greet1.Greet() //Note the Visibility here13. {14. return “Hello from 1”;15. }16. string Greet2.Greet() //public not allowed for explicit17. {18. return “Hello from 2”;19. }20. public static void Main()21. {22. Greet1 greeter1 = new Greeter();23. greeter1.Greet(); // Hello from 124. Greet2 greeter2 = new Greeter();25. greeter2.Greet(); // Hello from 226. Greeter greeter = new Greeter();27. greeter. // No Greeters to Greet unless I cast28. }29. }Explicitly State the interface for which theimplementation is
  20. 20. Similarities• Immutable Strings• Serialization• Boxing• ConvertValue Type to a Reference Type• Unboxing• Convert Reference Type to aValue Type
  21. 21. Similarities• Collections• C# - IList, IDictionary, Queue, Stack• Java - List, Map, Queue, Stack• for-each Collection Iterators
  22. 22. Specific to C#• Collection Initializer• Coroutines (more precisely Generators)• yield break• yield return01. public static void Main() {02. foreach(int fiboSeq in new Fibonacci(5)) {03. Console.Out.WriteLine("{0}", fiboSeq);04. }05. }Output:011235
  23. 23. Specific to C#• Collection Initializer• Coroutines (more precisely Generators)• yield break• yield return01. class Fibonacci : IEnumerable<int> {02. private readonly int howMany;03. private int firstSeed, secondSeed = 1;04.05. public Fibonacci(int howMany)06. {07. this.howMany = howMany;08. }09.10. public IEnumerator<int> GetEnumerator()11. {12. if (howMany < 0)13. {14. yield break;15. }16. for (var i = 0; i <= howMany; i++)17. {18. yield return firstSeed;19. var sum = firstSeed + secondSeed;20. firstSeed = secondSeed;21. secondSeed = sum;22. }23. }24.25. IEnumerator IEnumerable.GetEnumerator()26. {27. return GetEnumerator();28. }29. }01. public static void Main() {02. foreach(int fiboSeq in new Fibonacci(5)) {03. Console.Out.WriteLine("{0}", fiboSeq);04. }05. }Output:011235
  24. 24. Covariance &Contravariance• Covariance• Pass collection of sub-class to a collection of base class• Contravariance• Pass collection of base class to a collection of sub-class• Invariance• Neither of the above applies
  25. 25. Arrays and GenericCollections• Arrays are Covariant in C# and Java• There is a hole in the type system and a runtime patch isapplied.• Generics are Invariant in Java.• In C#, use leniency offered by IEnumerable if youneed Covariance.• Only interfaces and delegates can be covariant (out) orcontravariant (in)
  26. 26. C# Example
  27. 27. C# Example01. abstract class Animal {02. public abstract string Speak();03. }04.05. class Cat : Animal {06. public string Speak() {07. return “Meow!”;08. }09. }10.11. class Dog : Animal {12. public string Speak() {13. return “Bark!”;14. }15. }16.17. class Printer {18. public static Print(Animal [] animals) {19. animals[0] = new Dog();20. for (var i = 0; i < animals.Length; i++) {21. System.out.println(animals[i].speak();22. }23. }24.25. public static Print(IList<Animal> animals) {26. for (var animal in animals) {27. System.out.println(animal.Speak());28. }29. }30.
  28. 28. C# Example01. abstract class Animal {02. public abstract string Speak();03. }04.05. class Cat : Animal {06. public string Speak() {07. return “Meow!”;08. }09. }10.11. class Dog : Animal {12. public string Speak() {13. return “Bark!”;14. }15. }16.17. class Printer {18. public static Print(Animal [] animals) {19. animals[0] = new Dog();20. for (var i = 0; i < animals.Length; i++) {21. System.out.println(animals[i].speak();22. }23. }24.25. public static Print(IList<Animal> animals) {26. for (var animal in animals) {27. System.out.println(animal.Speak());28. }29. }30.01. public static Print(IEnumerable<Animal> animals)02. {03. for (var animal in animals) {04. Console.Out.WriteLine(animal.Speak());05. }06. }07. }08. class TestCollections {09. public static void main(String []args) {10. Cat cat = new Cat();11. Animal animal = cat;12. animal.speak();13.14. animal = new Dog();15. animal.speak();16.17. Animal [] animals = new Animal [] { cat, dog };18. Cat [] cats = new Cat[] { cat };19. animals = cats;20. Print(animals); //Exposes Hole in Type System21.22. // In absence of above Print method, the code23. // does not compile as Generic Collections in24. // C# are Invariant.25. List<Animal> animals = new ArrayList<Dog>();2627. //We need Co-variance to allow this to compile28. Printer.Print(dogs);29.30. }31. }
  29. 29. Java Example
  30. 30. Java Example01. abstract class Animal {02. public abstract String speak();03. }04.05. class Cat extends Animal {06. public String speak() {07. return “Meow!”;08. }09. }10.11. class Dog extends Animal {12. public String speak() {13. return “Bark!”;14. }15. }16.17. class Printer {18. public static print(Animal [] animals) {19. animals[0] = new Dog();20. for (int i = 0; i < animals.length; i++) {21. System.out.println(animals[i].speak();22. }23. }24.25. public static print(List<Animal> animals) {26. for(Animal animal : animals) {27. System.out.println(animal.speak());28. }29. }30. }
  31. 31. Java Example01. class TestCollections {02. public static void main(String []args) {03. Cat cat = new Cat();04. Animal animal = cat;05. animal.speak();06.07. animal = new Dog();08. animal.speak();09.10. Animal [] animals = new Animal [] { cat, dog };11. Cat [] cats = new Cat[] { cat };12. animals = cats;13. print(animals); //Exposes Hole in Type System14.15. // Fails to compile as Generic Collections in16. // Java are Invariant17. List<Animal> animals = new ArrayList<Dog>();18.19. List<Dog> dogs = new ArrayList<Dog>();20. dogs.add(dog);21. dogs.add(dog);22. print(dogs);23. }24. }01. abstract class Animal {02. public abstract String speak();03. }04.05. class Cat extends Animal {06. public String speak() {07. return “Meow!”;08. }09. }10.11. class Dog extends Animal {12. public String speak() {13. return “Bark!”;14. }15. }16.17. class Printer {18. public static print(Animal [] animals) {19. animals[0] = new Dog();20. for (int i = 0; i < animals.length; i++) {21. System.out.println(animals[i].speak();22. }23. }24.25. public static print(List<Animal> animals) {26. for(Animal animal : animals) {27. System.out.println(animal.speak());28. }29. }30. }
  32. 32. Specific to C#• Anonymous Types• Anonymous Methods/Delegates• Pass Methods as Data• Action: No return values• Func: Non-void return values• Predicate: A Func that always returns a bool• Generally above suffice, but if not,then use Custom Delegates• Delegate Chaining• Compiler Eye Candy: +=, -= for Combine(), Remove()• Lambdas
  33. 33. Specific to C#• Events• Syntactic sugar over delegates, but with visibility• Events can only be invoked from within the class that declared it, whereas adelegate field can be invoked by whoever has access to it.• Events can be included in interfaces, delegates cannot be.• Built-in EventHandler and EventArgs• Compiler generated add_ and remove_ methods forthe event.• dynamic• ExpandoObject
  34. 34. Dynamic Runtime LibraryCLR(Common Language Runtime)DLR(Dynamic Language Runtime)C#VB.NETPythonRuby• Allows you to talk withimplementations in otherlanguages• C#/VB.NET with Python, Ruby• Also with Silverlight etc..Dynamically TypedStatically Typed01. using IronPython.Hosting;02. using Microsoft.Scripting.Hosting;03.04. var python = Python.CreateRuntime();05. dynamic script = python.UseFile(“Calculator.py”);06.07. // Get PythonType08. dynamic Calculator = script.GetVariable(“Calculator”);09. dynamic calc = Calculator(); // Instantiate Object10.11. //Invoke method12. dynamic result = calc.add(2, 3); // 5
  35. 35. Specific to C#• Avoid Configuration hell• Single Configuration File (App.config)• Asynchronous Programming• BeginInvoke and EndInvoke• Wait with EndInvoke• Wait with WaitHandle• Poll for Async call completion• Execute a callback upon completion• Task Parallel Library (TPL)
  36. 36. Specific to Java• Static Imports• Instance and Static Initializers• Interfaces Containing Fields• Anonymous Classes• Proxy Support through Interceptor
  37. 37. Specific to Java• Asynchronous Programming• Future Task• Poll Completion with isDone().• Execute callback upon completion• Using ListenableFuture and FutureCallback - Google Guava Library• Or roll your own result completion callback.• Akka Actors
  38. 38. Frameworks and ToolsJava C#Dependency InjectionFrameworksORM FrameworksProxying/AOP FrameworksTDD FrameworksMocking FrameworksBDD FrameworksBuild ToolsCoverage ToolsProfilerCode Analysis ToolsSpring, Guice, PicoContainer etc...Spring.NET, Unity ContainerHibernate, iBatis etc...NHibernate, EntityFrameworkJDK Proxy, Spring AOP, CGLibAspectJ, AspectWerkzCastle Proxy, Rhino Proxy,Unity InterceptorJUnit, TestNG NUnit, MSTestJMock2, Mockito, EasyMock Rhino Mocks, Moq, TypeMockCucumber, JBehave, Spock,EasybNBehave, SpecFlow, NSpecAnt, Maven, Gradle, Ivy NAnt, MSBuild, NMavenCobertura, Emma, Clover NCover, OpenCoverJProfiler, YourKit dotTrace, YourKit.NETFindBugs, PMD, Checkstyle,JDependFxCop, NDepend, ReSharper,Simian
  39. 39. References• MSDN Site• Venkat Subramaniam• http://agiledeveloper.com/presentations/CSharpForJavaProgrammers.zip• Wikipedia• http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java• Dare Obasanjo• http://www.25hoursaday.com/CsharpVsJava.html• Scott Hanselman• http://www.hanselman.com/blog/C4AndTheDynamicKeywordWhirlwindTourAroundNET4AndVisualStudio2010Beta1.aspx

×