c for java developers
play

C# for Java Developers Patrick Linskey plinskey@gmail.com - PowerPoint PPT Presentation

C# for Java Developers Patrick Linskey plinskey@gmail.com @plinskey Who am I? Patrick Linskey 13 years of Java experience, 11 professionally 2 years of professional C# experience Who are you? Hopefully, Java developers who are


  1. C# for Java Developers Patrick Linskey plinskey@gmail.com @plinskey

  2. Who am I? • Patrick Linskey • 13 years of Java experience, 11 professionally • 2 years of professional C# experience

  3. Who are you? • Hopefully, Java developers who are interested in learning about C# • ... for client, server, or mobile deployment

  4. Apology to Readers Much of this talk happens in Visual Studio. Sorry about that. I will make the code available at http:// github.com/pcl -- the commit history provides some detail.

  5. [Anders Hejlsberg]

  6. Some Terminology • C ommon L anguage R untime, not JVM • I ntermediate L anguage, not Java bytecode • Assembly, not JAR • [Attribute], not @Annotation

  7. [Syntax]

  8. Coding Conventions • All methods use InitialCaps • Constants use InitialCaps instead of ALL_CAPS • Namespaces are not as consistently-scoped as are packages in the Java world • Assembly names are first-class constructs

  9. [Unit Testing]

  10. MSTest vs. NUnit • I use NUnit because it seems more familiar • Without ReSharper, NUnit / Visual Studio integration is a bit weak

  11. Visual Studio • Most people seem to use it • $$$ • ReSharper (plugin from JetBrains) is a must • #1 awesome Visual Studio feature: program counter manipulation during debug sessions

  12. [LINQ and Functions]

  13. LINQ • Can evaluate LINQ queries against database, XML, collections, etc. • Anything IEnumerable or IQueryable • Also: JOIN, GROUP BY, HAVING, ...

  14. Function Objects • We saw Func<int, int> in fib • Generally: Func<TArg1, TArg2, TReturn> • Support for up to 16 arguments!

  15. Action Objects • Action<TArg1, TArg2, ...> • Also supports 16 args! • Equivalent to a void method return type

  16. Tuples • Tuple<T1, T2, T3, ...> • Up to 8 items • Useful for easy multi-object returns, LINQ queries

  17. Anonymous Types • Predate tuples var ratio = new { Numerator = 2, Denominator = 3 }; Console.Out.WriteLine( ratio.Numerator / ratio.Denominator);

  18. [Object-Orientation]

  19. Virtual keyword • By default, methods are resolved at compile time • To get polymorphic method invocation, highlight the methods as ‘virtual’

  20. The Ecosystem

  21. Third-Party is Weak • Outside UI widgets, nowhere near as much activity as in the Java world • Few open-source projects • http://stackoverflow.com is your friend

  22. Spring.NET is great • Lags the Java Spring Framework a bit • I’ve only used dependency injection and lifecycle management features • WPF (and presumably Silverlight) have their own resource management • It’s possible to bridge the two

  23. Yay! • Generics are reified, and support covariance and contravariance • Dynamic method invocation with the ‘dynamic’ pseudo-type (akin to ObjC’s ‘id’) • += syntax for all delegate fields / properties • Func, Action, raw Delegate

  24. More Cool Stuff • @ strings • Indexers • Partial classes (UI and codegen) • Structs

  25. Some Missing Features • No anonymous inner classes (use closures / function objects instead) • All inner classes are static • Enums cannot have state or methods • Can emulate methods with extension methods

  26. Questions? Patrick Linskey plinskey@gmail.com code: http://github.com/pcl

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend