Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

C# Programming: Object-Oriented Features and Component-Based Development, Slides of Advanced Computer Programming

An excerpt from the third edition of 'c# programming: from problem analysis to program design'. It covers the major features of object-oriented languages, component-based development methods, inheritance, abstract classes, interfaces, polymorphism, generics, static versus dynamic typing, and creating base classes for inheritance. It also explains how to override methods and call the base constructor, as well as the relationship between classes and making stand-alone components.

Typology: Slides

2012/2013

Uploaded on 04/30/2013

archa
archa 🇮🇳

4.3

(21)

143 documents

1 / 29

Toggle sidebar

Related documents


Partial preview of the text

Download C# Programming: Object-Oriented Features and Component-Based Development and more Slides Advanced Computer Programming in PDF only on Docsity! C# Programming: From Problem Analysis to Program Design 1 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program Design 3rd Edition 11 Docsity.com C# Programming: From Problem Analysis to Program Design 2 Chapter Objectives • Learn the major features of object-oriented languages • Design and develop multitier applications using component-based development methods • Use inheritance to extend the functionality of user- defined classes • Create abstract classes that include abstract methods Docsity.com C# Programming: From Problem Analysis to Program Design 5 Object-Oriented Language Features • Abstraction – Abstract or identify the objects involved in the problem • Encapsulation – Packaging data and behaviors into a single unit • Inheritance – Reuse of code through extending program units • Polymorphism – Multiple implementations of the same behaviors Docsity.com C# Programming: From Problem Analysis to Program Design 6 Component-Based Development Figure 11-1 Component-based development Docsity.com C# Programming: From Problem Analysis to Program Design 7 Component-Based Development (continued) • Multitier applications – Data access tier for accessing data from text files and databases – Graphical user interface tier for user interaction • Windows • Web • Components implemented through classes in C# • Class library files with a dynamic link library (DLL) extension Docsity.com C# Programming: From Problem Analysis to Program Design 10 Inheriting from Other .NET FCL Classes • Add functionality to programs with minimal programming • Extend System.Windows.Forms.Form class to build GUIs (Button, Label, TextBox, ListBox) Base class Derived class Figure 11-3 Derived class Docsity.com C# Programming: From Problem Analysis to Program Design 11 Creating Base Classes for Inheritance • Can define your own classes from which other classes can inherit • Base class is called the super or parent class • Data members are defined with a private access modifier • Constructors are defined with public access modifiers • Properties offer public access to data fields Docsity.com C# Programming: From Problem Analysis to Program Design 12 Overriding Methods • Replace the method defined at a higher level • Keyword override included in derived class – Base method includes virtual, abstract, or override keyword • Overriding differs from overloading a method – Overridden methods have exactly the same signature – Overloaded methods each have a different signature Figure 11-4 ToString( ) signature Docsity.com C# Programming: From Problem Analysis to Program Design 15 Using Members of the Base Class • Scope – Methods defined in subclass take precedence when named the same name as member of a parent class • Can call an overridden method of the base class – Use keyword base before the method name return base.GetSleepAmt( ) // Calls GetSleepAmt( ) in // parent class Docsity.com C# Programming: From Problem Analysis to Program Design 16 Relationship between the Person and Student Classes Figure 11-5 Inheritance class diagram Docsity.com C# Programming: From Problem Analysis to Program Design 17 Making Stand-Alone Components • Compile class and create an assembly – Assemblies are units configured and deployed in .NET • Classes can be compiled and stored as a dynamic link library (DLL) instead of into the EXE file type • Adds a reference to the DLL – That referenced file with the .dll extension becomes part of the application’s private assembly Docsity.com C# Programming: From Problem Analysis to Program Design 20 Add Reference to Base Class Figure 11-8 Adding a reference to a DLL One of the first things to do is Add a Reference to the Parent DLL Docsity.com C# Programming: From Problem Analysis to Program Design 21 Add Reference to Base Class (continued) Figure 11-9 Add Reference dialog box Use Browse button to locate DLL Docsity.com C# Programming: From Problem Analysis to Program Design 22 Add Reference to Base Class (continued) Figure 11-10 Locating the Person.dll component Docsity.com C# Programming: From Problem Analysis to Program Design 25 Creating a Client Application to Use the DLL • DLL components can be reused with many different applications • Two steps – Add a reference to the DLL components – Include a using statement with the namespace • Then declare an object of the component type(s) • Use members of the derived, base, or referenced classes Docsity.com C# Programming: From Problem Analysis to Program Design 26 Creating a Client Application to Use the DLL (continued) Figure 11-12 DLLs referenced in the PresentationGUI class Docsity.com C# Programming: From Problem Analysis to Program Design 27 Creating a Client Application to Use the DLL (continued) Figure 11-13 PresentationGUI output referencing two DLLs Docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved