1 / 17

Java vs. .NET

Java vs. .NET. Java vs. C# Swing vs. WinForms. Class Declaration .NET Types Event Handling Exception Handling Operation Parameters Operation Visibility. Component Assemblies Package Structure Class Properties and Structures Class Indexers Source Code Attributes.

Leo
Télécharger la présentation

Java vs. .NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java vs. .NET Java vs. C# Swing vs. WinForms The Object Services Company, Inc.

  2. Class Declaration .NET Types Event Handling Exception Handling Operation Parameters Operation Visibility Component Assemblies Package Structure Class Properties and Structures Class Indexers Source Code Attributes C# Language Differences The Object Services Company, Inc.

  3. Class Declaration • class SomeClass : ExtendedClass, Interface1, Interface2 • SomeClass extends ExtendedClass • SomeClass implements Interface1 and Inteface2 • More than one object can be declared inside the .cs file The Object Services Company, Inc.

  4. Package Structure • To import use ‘using’ keyword The Object Services Company, Inc.

  5. Value Types can be used as Objects Aliased to System types so that any .NET language can use them from any other .NET language (See column to the right)  Structures Can have constructors Java boolean bool (System.Boolean) Java bytes byte (System.Sbyte) Java char char (System.Char) Java int int (System.Int32) Java long long (System.Int64) Java float float (System.Single) Java double double (System.Double) .NET Types The Object Services Company, Inc.

  6. Exception Handling • Catch Block can trap no Exception or specific Exceptions The Object Services Company, Inc.

  7. Event Handling • .NET Delegates • Much different than Java The Object Services Company, Inc.

  8. Declare a variable Only a getter implies a read-only property Can use lazy initialization Can be defined in an Interface Class Properties The Object Services Company, Inc.

  9. Instances of a class can be referenced with Array notation on the class Class Indexers The Object Services Company, Inc.

  10. Operation Parameters • Undetermined Number of Parameters • public void methodCaller( params int[] a ); • methodCaller( 1 ); • methodCaller( 1, 2, 3, 4, 5 ); • Pass by Reference • public void increment( ref int a ) • Can possibly change the value of ‘a’ • Pass by Reference and Change Value • public void DoNothing( out int a ) • Ensures ‘a’ is changed The Object Services Company, Inc.

  11. Operation Visibility • Overriding Inherited Operations • Requires superclass method to be marked ‘virtual’ • Overriding method must be marked ‘override’ • public, protected, and private are the same as in Java • internal • Member is accessible from the entire assembly. • More than one object can be declared inside the .cs file. • Each object has a handle to the internal member • protected internal • A union of protected and internal. • Can be accessed from the entire assembly, or within objects which derive from this class The Object Services Company, Inc.

  12. Component Assemblies • Common Language Runtime (CLR) • Similar to Java VM • But multi-lingual, i.e. VB, C++, C# • Shareable Dynamic Link Libraries • Shareable Code Modules • Linked at compile-time • Transparency to all .NET languages • Should be aware of data types, naming and formatting standards The Object Services Company, Inc.

  13. Source Code Attributes • Used for compiler and runtime processing • Attributes are derived from System.Attribute • New and confusing for us Java Developers The Object Services Company, Inc.

  14. Swing and WinForms • .NET has the same GUI components as Swing • No Layout Managers • .NET has Data Binding! • DataProvider manages DataSources • DataSet is a disconnected, in-memory data cache • Lots of 3rd Party Controls converted from COM Components to .NET • Especially Tables and 2D Graphs • Extensible Application Markup Language (XAML) The Object Services Company, Inc.

  15. IDE’s • Visual Studio • Requires .NET Framework install first • Horrendously lengthy installation • SharpDevelop • Open Source • Improve C# Plugin • Eclipse • CodeWright • By Borland The Object Services Company, Inc.

  16. C# for Java Developers Allen Jones, Adam Freeman Microsoft Press C# Language Pocket Reference Peter Dayton, Ben Albahari, Ted Neward O’Reilly Books XAML C# Namespaces Doc .NET CodeDom GotDotNet How Do I?...Common Tasks .NET 24/7 Windows Forms QuickStart Tutorial References The Object Services Company, Inc.

  17. Conclusions • More web info for Java than .NET …for now… • Longhorn and XAML • XAML can be translated at run-time for WinForms or WebForms • If Windows is the only client platform for deployment…why not use .NET? • Front-end .NET and Back-end Java J2EE? The Object Services Company, Inc.

More Related