Presentation is loading. Please wait.

Presentation is loading. Please wait.

IEG 3080 Tutorial 2 Jack Chan. Prepared by Jack Chan, Spring 2007 Outline.Net Platform Object Oriented Concepts Encapsulation Inheritance Polymorphism.

Similar presentations


Presentation on theme: "IEG 3080 Tutorial 2 Jack Chan. Prepared by Jack Chan, Spring 2007 Outline.Net Platform Object Oriented Concepts Encapsulation Inheritance Polymorphism."— Presentation transcript:

1 IEG 3080 Tutorial 2 Jack Chan

2 Prepared by Jack Chan, Spring 2007 Outline.Net Platform Object Oriented Concepts Encapsulation Inheritance Polymorphism Delegation Something about course project

3 Prepared by Jack Chan, Spring 2007.Net Platform Class Library ADO.NET GUI XML/SOAP DirectX etc Common Language Runtime (CLR) Common Type System Common Language Spec C#VBC++PerlPythonCobolSmalltalk … Figure extracted from “M. Chang, Lecture Note 1, p.45”

4 Prepared by Jack Chan, Spring 2007.Net Platform Support a wide range of programming languages With CLR (Common Language Runtime) in the platform, to convert source code to intermediate language (MSIL) (in JAVA, JVM is used)

5 Prepared by Jack Chan, Spring 2007.Net Platform No DLL hell address reference to library functions are resolved by CLR dynamically (not preset by COM programmer) simplified software distribution Support cross-language inheritance (e.g. a VB class derived from a C# class)

6 Prepared by Jack Chan, Spring 2007.Net Platform Some disadvantages Take time to compile MSIL Not multi-platform Open source “Mono-project” under development http://www.mono-project.com/Main_Page Limitation in flexibility compared with J2EE …

7 Prepared by Jack Chan, Spring 2007 Object Oriented Concepts - Encapsulation Encapsulation Hide details from outside world Only expose user interface Examples: resistor in electronics, random number generator… Black Box (provide certain Service) InputOutput

8 Prepared by Jack Chan, Spring 2007 Object Oriented Concepts - Encapsulation Why? the less detailed implementation exposed, the easier it is when you want to change the implementation -> the user would not be affected e.g. USB port can support various devices, even the device which has not been invented yet as long as the interface is not changed, any change in implementation would not affect users

9 Prepared by Jack Chan, Spring 2007 Object Oriented Concepts - Encapsulation Encapsulation Easy for the maintenance of large program Different components provide different services, have different responsibilities clearly. Easier to extend the functionality of components Important to develop large complex software

10 Prepared by Jack Chan, Spring 2007 Object Oriented Concepts - Encapsulation Encapsulation concept in C# -> visibility public private protected internal protected internal Attributes are usually private Methods could be private or public

11 Prepared by Jack Chan, Spring 2007 Object Oriented Concepts - Inheritance Inheritance Objects have similar properties -> may belong to a more general object e.g. catdogsparroweagleMammalBirdAnimals with Backbone

12 Prepared by Jack Chan, Spring 2007 Object Oriented Concepts - Inheritance Why? Make better reuse of existing classes Better structured Use less code e.g. class Mammal { has 4 limbs has fur warm blood…} class Cat : Mammal{ meow } class Dog : Mammal{ bark } class Kitten : Cat{...}

13 Prepared by Jack Chan, Spring 2007 Object Oriented Concepts - Inheritance Inheritance in C# public class ChildClass : ParentClass { public ChildClass() { Console.WriteLine("Child Constructor."); } public static void Main() { ChildClass child = new ChildClass(); child.print(); } } Output: Child Constructor. I'm a Parent Class. public class ParentClass { virtual public void print() { Console.WriteLine("I'm a Parent Class."); } } Inheritance operator

14 Prepared by Jack Chan, Spring 2007 Object Oriented Concepts - Inheritance Override methods Use the same name to override the method Only virtual methods can be overrided public class ChildClass : ParentClass { public ChildClass() { Console.WriteLine("Child Constructor."); } virtual public void print() //override { Console.WriteLine(“I’m a child!”); } public static void Main() { ChildClass child = new ChildClass(); child.print(); } } Output: Child Constructor. I'm a child!

15 Prepared by Jack Chan, Spring 2007 Course Project “SuperPang” http://www.addictinggames.com/pang2004.html http://www.addictinggames.com/pang2004.html Specification: http://course.ie.cuhk.edu.hk/~ieg3080a/project/IEG3080_project.doc Phase 1: 23 February, 2007 (Fri) Phase 2: 23 March, 2007 (Fri) Phase 3 + Special features + Report: 13 April, 2007 (Fri) Demonstration: the week of 16 April, 2007

16 Prepared by Jack Chan, Spring 2007 Course Project Plan carefully before coding How many classes do you need? Do those objects have similar properties? How the special functions could be added easily in the future Flying Object BalloonStoneBullet

17 Prepared by Jack Chan, Spring 2007 Course Project Use Windows Form Application (Lecture Note, P.52) instead of Console Application (Lecture Note, P.50) Do not spend too much time on beautiful graphics No Plagiarism

18 Prepared by Jack Chan, Spring 2007 Chan An, Jack Office: SHB 825 Office Hour: Tuesdays 11:30am – 12:15pm


Download ppt "IEG 3080 Tutorial 2 Jack Chan. Prepared by Jack Chan, Spring 2007 Outline.Net Platform Object Oriented Concepts Encapsulation Inheritance Polymorphism."

Similar presentations


Ads by Google