Presentation is loading. Please wait.

Presentation is loading. Please wait.

IS437: Fall 2004 Instructor: Dr. Boris Jukic Object Oriented Programming.

Similar presentations


Presentation on theme: "IS437: Fall 2004 Instructor: Dr. Boris Jukic Object Oriented Programming."— Presentation transcript:

1

2 IS437: Fall 2004 Instructor: Dr. Boris Jukic Object Oriented Programming

3 Learning Objectives Object-oriented concepts Implementation of object-oriented concepts in Visual Basic.Net

4 Limitations Of Conventional Languages o Small Vocabulary o Highly Procedural o Logic Buried In Long Lines Of Code o Difficult To Re-Use Code o Costly To Build And Modify o Allow Only Simple Data Structures

5 Object-Oriented Approach PROGRAMMING LANGUAGES : SMALLTALK, C++, Java, Visual Basic.Net

6 To Achieve Greater Semantic Expressiveness - Complex Structure - A Variety Of Relationships - Natural Representation To Reduce Use of Procedural Blocks of Code To Enhance Re-Usability Goals

7 Objects Correspond to Real World Constructs studentuniversity cashier carATM radio sales report ….

8 Object Encapsulation Class Class Hierarchy And Inheritance Message And Polymorphism Key OO Concepts

9 Everything Is Modeled As Object: Millie Buddy Snoopy Dog Cashier A Tax Return Each Object Has A Name (External Identifier) An Object Has Two Components : - Properties (To Store Information) Can Take On Complex Structure : E.G. : Widget_A (Acquisition_Date, Quantity On Hand) (( 3/10/92 $100) ( 3/20/92 $150) ( 3/25/92 $200)) - Methods (Behavior Encapsulation) Object & Encapsulation

10 Record structure in COBOL John Smith 445-09-2049 Swimming Mary Scott 670-37-4095 Bridge Bill Shoemaker 888-92-9104 Dancing John Smith 123-87-3094 Painting Name Social Security # Hobby Records have no common external identifiers. Attributes are single-valued.

11 DOG Class Example DOG(COLOR, SPEED) MILLEPUPPY SNOOPY instance-of relationship

12 Class Hierarchy Example ANIMAL BIRDDOG FISH POLLY MILLIEMOBY IS-A-Kind of relationship GENERALIZATION-SPECIALIZATION RELATIONSHIP instance-of relationship

13 STUDENT UNDER- GRADUATE STUDENT MBA STUDENT PH.D. STUDENT IS-A-Kind of relationship Class Hierarchy: Another Example

14 Inheritance ANIMAL BIRD DOG FISH POLLY MILLIE MOBY (COLOR, SPEED) (Beak, Fly) (Bark, Ears)

15 Polymorphism Ability to take on many shapes and forms Many classes can provide the same property or method, without having to worry what type of class it is: Dog class (eat() method) Mosquito class (eat() method)  Of course, same method would be implemented in a very different way Same class can have multiple versions of the method  Overloaded methods

16 - Greater Semantic Expressiveness Can Represent Is_A Relationships Support Complex Data Structure - Behavior Encapsulation Facilitates The Modeling Of Real-World Objects - Object Library (Re-Use) - Reduce Procedurality Through An Enlarged Vocabulary Benefits Of OO Approach:

17 Difficulties Different Programming Paradigm  Resistance, Requires a shift in thinking) Increased Complexity:  Takes time to become acquainted with the library of objects

18 Implementation of OO in Visual Basic.Net Object Encapsulation (property and method) Classes: over 6,000 in number Class hierarchy and inheritance Polymorphism Visual Basic.Net supports all of the key OO concepts. It is a full-fledged OO system.

19 Textbox TextBox1 instance-of relationship class object Object, Class, Encapsulation in VB.Net New keyword: creates a new instance of an object class

20 New Method in VB.Net Also called constructor It is the method that classes use to instantiating objects. Dim label1 as Label Label1 = New Label Dim label1 as New Label or

21 Add a control to a form Me.controls.add(label1) Collections of controls on a form Add to the collection The control to be added Represents this form

22 A Simplified View of Class Hierarchy in VB.Net Object Component ControlData Adapter Label DateTimePicker PictureBox IS-A-Kind of relationship

23 Polymorphism in VB.Net Functionally equivalent methods can have the same name VB.Net implements polymorphism in various ways: - overloading - overriding - method hiding

24 Polymorphism in VB.Net: Overloading Messagebox.Show(“Enter numeric data.”) Messagebox.Show(“Enter numeric data.”, “Data entry error”) Messagebox.Show(“This is a message.”, “This is a title bar”, MessageBoxButtons.OK) … Overloading: methods sharing the same name, for the same object, but with different signatures (argument lists)

25 MessageBox General Form Messagebox.Show(TextMessage) Messagebox.Show(TextMessage, TitlebarText) Messagebox.Show(TextMessage, TitlebarText, MessageBoxButtons) Messagebox.Show(TextMessage, TitlebarText, MessageBoxButtons, MessageBoxIcons)

26 Polymorphism in VB.Net: Overriding Animal Dog Snoopy Talk method:“I cannot talk” Talk method: “Bark Bark” Snoopy.Talk “Bark Bark” Parent class and child class may have methods with the same name. The method in child class can override the method in parent class.

27 Polymorphism: method hiding Button1.Click CustomerForm.Click Checkbox1.Click …

28 Namespaces Namespaces are file cabinets for classes, similar to the concept of folders. Namespaces can contain classes, other namespaces, etc. Namespaces help organize the vast number of classes into a neat structure. To make use of a class, we need to reference or import the namespace that contains the class.

29 Namespace Hierarchy System namespace System Windows.Forms namespace System.Windows.Forms Button Label TextBox Data namespace System.Data Drawing namespace System.Drawing OleDb namespace System.Data.OleDb OleDb provides interaction with MS Access.


Download ppt "IS437: Fall 2004 Instructor: Dr. Boris Jukic Object Oriented Programming."

Similar presentations


Ads by Google