Object-Oriented Programming Using C#Objectives               In this session, you will learn to:                  Implemen...
Object-Oriented Programming Using C#Implementing Constructors               A constructor is a special type of method that...
Object-Oriented Programming Using C#The Need of Constructors               A constructor is special member function within...
Object-Oriented Programming Using C#Types of Constructors               The two types of constructors are:                ...
Object-Oriented Programming Using C#Constructors with Parameters               A constructor can be modified to accept the...
Object-Oriented Programming Using C#Implementing Destructors               Destructors are special methods that are used t...
Object-Oriented Programming Using C#Declaration of Destructors               A destructor has the same name as its class b...
Object-Oriented Programming Using C#Declaration of Destructors (Contd.)               C# provides the following methods to...
Object-Oriented Programming Using C#Identifying the Life Cycle of an Object                Let us understand the life cycl...
Object-Oriented Programming Using C#Identifying the Life Cycle of an Object (Contd.)                 ~TestCalculator()    ...
Object-Oriented Programming Using C#Identifying the Life Cycle of an Object (Contd.)                ~Console.WriteLine("In...
Object-Oriented Programming Using C#Introducing Polymorphism               In Object-Oriented Programming (OOPs), polymorp...
Object-Oriented Programming Using C#Static Polymorphism               Static polymorphism refers to an entity, which exist...
Object-Oriented Programming Using C#Dynamic Polymorphism               In dynamic polymorphism, the decision about functio...
Object-Oriented Programming Using C#Implementing Function Overloading               Function overloading is implemented by...
Object-Oriented Programming Using C#Function Signature               The signature of a function is defined by:           ...
Object-Oriented Programming Using C#Constructor Overloading               Constructors can also be parameterized, and ther...
Object-Oriented Programming Using C#Demo: Displaying Days Using Function Overloading               Problem Statement:     ...
Object-Oriented Programming Using C#Demo: Displaying Days Using Function Overloading (Contd.)               Solution:     ...
Object-Oriented Programming Using C#Operator Overloading               Operator overloading provides additional capabiliti...
Object-Oriented Programming Using C#Need for Operator Overloading               To use operators with user-defined data ty...
Object-Oriented Programming Using C#Summary              In this lesson, you learned that:                 Constructors ar...
Object-Oriented Programming Using C#Summary (Contd.)               – The Finalize() destructor is called after the last re...
Object-Oriented Programming Using C#Summary (Contd.)               Function overloading is the process of using the same n...
Upcoming SlideShare
Loading in …5
×

06 iec t1_s1_oo_ps_session_08

579 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
579
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
68
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Students have learnt the structure of different types of dimensions and the importance of surrogate keys in Module I. In this session, students will learn to load the data into the dimension tables after the data has been transformed in the transformation phase. In addition, students will also learn to update data into these dimension tables. Students already know about different types of dimension tables. Therefore, you can start the session by recapitulating the concepts. Initiate the class by asking the following questions: 1. What are the different types of dimensions? 2. Define flat dimension. 3. What are conformed dimension? 4. Define large dimension. 5. Define small dimension. 6. What is the importance of surrogate key in a dimension table? Students will learn the loading and update strategies theoretically in this session. The demonstration to load and update the data in the dimension table will be covered in next session.
  • Students know the importance of surrogate keys. In this session students will learn the strategy to generate the surrogate key. Give an example to explain the strategy to generate the surrogate keys by concatenating the primary key of the source table with the date stamp. For example, data from a Product table has to be loaded into the Product_Dim dimension table on Feb 09, 2006. The product_code is the primary key column in the Product table. To insert the surrogate key values before loading the data into the dimension table, you can combine the primary key value with the date on which the data has to be loaded. In this case the surrogate key value can be product_code+09022006.
  • Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  • Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  • Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  • Student already have learnt about type 2 SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 2 SCDs? Given an example to explain type 2 SCDs. This will recapitulate what they have learnt about type 2 SCD in Module 1. Now explain the strategy to update the data into these dimension tables with help the example given in SG. After explaining the examples, you can ask students to think of an example of a type 2 SCD and then tell the strategy to update the data into this dimension table.
  • Student already have learnt about type 2 SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 2 SCDs? Given an example to explain type 2 SCDs. This will recapitulate what they have learnt about type 2 SCD in Module 1. Now explain the strategy to update the data into these dimension tables with help the example given in SG. After explaining the examples, you can ask students to think of an example of a type 2 SCD and then tell the strategy to update the data into this dimension table.
  • Student already have learnt about type 2 SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 2 SCDs? Given an example to explain type 2 SCDs. This will recapitulate what they have learnt about type 2 SCD in Module 1. Now explain the strategy to update the data into these dimension tables with help the example given in SG. After explaining the examples, you can ask students to think of an example of a type 2 SCD and then tell the strategy to update the data into this dimension table.
  • Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  • Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  • Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  • Students know the importance of surrogate keys. In this session students will learn the strategy to generate the surrogate key. Give an example to explain the strategy to generate the surrogate keys by concatenating the primary key of the source table with the date stamp. For example, data from a Product table has to be loaded into the Product_Dim dimension table on Feb 09, 2006. The product_code is the primary key column in the Product table. To insert the surrogate key values before loading the data into the dimension table, you can combine the primary key value with the date on which the data has to be loaded. In this case the surrogate key value can be product_code+09022006.
  • Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  • Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  • Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
  • Student already have learnt about type 2 SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 2 SCDs? Given an example to explain type 2 SCDs. This will recapitulate what they have learnt about type 2 SCD in Module 1. Now explain the strategy to update the data into these dimension tables with help the example given in SG. After explaining the examples, you can ask students to think of an example of a type 2 SCD and then tell the strategy to update the data into this dimension table.
  • Student already have learnt about type 2 SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 2 SCDs? Given an example to explain type 2 SCDs. This will recapitulate what they have learnt about type 2 SCD in Module 1. Now explain the strategy to update the data into these dimension tables with help the example given in SG. After explaining the examples, you can ask students to think of an example of a type 2 SCD and then tell the strategy to update the data into this dimension table.
  • Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  • Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  • Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  • Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
  • You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.
  • You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.
  • You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.
  • 06 iec t1_s1_oo_ps_session_08

    1. 1. Object-Oriented Programming Using C#Objectives In this session, you will learn to: Implement constructors Implement destructors Identify the life cycle of an object Describe polymorphism Implement function overloading Identify need for operator overloading Ver. 1.0 Session 8 Slide 1 of 24
    2. 2. Object-Oriented Programming Using C#Implementing Constructors A constructor is a special type of method that is invoked when you create a new instance of a class. A constructor is used to initialize the members of the class. The name of a constructor is the same as the name of the class that contains it. Ver. 1.0 Session 8 Slide 2 of 24
    3. 3. Object-Oriented Programming Using C#The Need of Constructors A constructor is special member function within the class which is executed when an object of the class is created. Ver. 1.0 Session 8 Slide 3 of 24
    4. 4. Object-Oriented Programming Using C#Types of Constructors The two types of constructors are: – Instance constructors: They are called whenever an instance of a class is created. These constructors are used to initialize the data members of the class. – Static constructors: They are used to initialize the static variables of a class. These variables are created using static keyword and they store values that can be shared by all the instances of a class. Ver. 1.0 Session 8 Slide 4 of 24
    5. 5. Object-Oriented Programming Using C#Constructors with Parameters A constructor can be modified to accept the user-supplied values at run time. Objects can be initialized using the default constructor with values hard-coded in the program. But there might be a requirement where the variables need to be initialized with user supplied values. Ver. 1.0 Session 8 Slide 5 of 24
    6. 6. Object-Oriented Programming Using C#Implementing Destructors Destructors are special methods that are used to release the instance of a class from memory. A class can have only one destructor. The purpose of the destructor is to perform the required memory cleanup action. The .NET Framework automatically runs the destructor to destroy objects in the memory. Ver. 1.0 Session 8 Slide 6 of 24
    7. 7. Object-Oriented Programming Using C#Declaration of Destructors A destructor has the same name as its class but is prefixed with a ~ , which is the symbol of tilde. Destructors cannot be inherited or overloaded. Garbage collection is a process that automatically frees the memory of objects that are no more in use. The decision to invoke the destructor is made by a special program of C# known as the garbage collector. The process of garbage collection happens automatically. It ensures that: Objects get destroyed Only unused objects are destroyed Ver. 1.0 Session 8 Slide 7 of 24
    8. 8. Object-Oriented Programming Using C#Declaration of Destructors (Contd.) C# provides the following methods to release the instance of a class from memory: – Finalize(): It is a special method that is called from the class to which it belongs or from the derived classes. The Finalize() destructor is called after the last reference to an object is released from the memory. – Dispose(): This method is called to release a resource, such as a database connection, as soon as the object using such a resource is no longer in use. The IDisposable interface contains the Dispose() method. Therefore, to call the Dispose() method, the class must implement the IDisposable interface. Ver. 1.0 Session 8 Slide 8 of 24
    9. 9. Object-Oriented Programming Using C#Identifying the Life Cycle of an Object Let us understand the life cycle of an object with the help of the following code: using System; //Life Cycle of an Object namespace Objects { class TestCalculator { TestCalculator() { Console.WriteLine("Constructor Invoked"); } Ver. 1.0 Session 8 Slide 9 of 24
    10. 10. Object-Oriented Programming Using C#Identifying the Life Cycle of an Object (Contd.) ~TestCalculator() The destructor of all { the object is invoked Console.WriteLine when the garbage ("Destructor Invoked"); collector is invoked. } public static void The Calc1 object has Main(string[] args) function scope. { Therefore, its Console.WriteLine("Main() constructor is executed Begins"); after the execution of TestCalculator Calc1 = Main() begins. new TestCalculator(); Ver. 1.0 Session 8 Slide 10 of 24
    11. 11. Object-Oriented Programming Using C#Identifying the Life Cycle of an Object (Contd.) ~Console.WriteLine("Inner Block The Calc2 object has Begins "); block scope. TestCalculator Calc2 = new Therefore, its TestCalculator(); constructor is executed after the inner block Console.WriteLine("Inner Block begins. Ends"); } Console.WriteLine("Main() ends"); } } } Ver. 1.0 Session 8 Slide 11 of 24
    12. 12. Object-Oriented Programming Using C#Introducing Polymorphism In Object-Oriented Programming (OOPs), polymorphism allows one interface to be used for multiple functions. Polymorphism reduces the complexity within the functions of a class of a program. Polymorphism can either be static or dynamic. Ver. 1.0 Session 8 Slide 12 of 24
    13. 13. Object-Oriented Programming Using C#Static Polymorphism Static polymorphism refers to an entity, which exists in various forms simultaneously. C# uses two approaches to implement static polymorphism. These are: – Function overloading: This approach allows using the same name for two or more functions. Each redefinition of a function must use different types of parameters, sequence of parameters, or a number of parameters. – Operator overloading: This approach allows user-defined types such as structures and classes, to use overloaded operators for easy manipulation of their objects. Ver. 1.0 Session 8 Slide 13 of 24
    14. 14. Object-Oriented Programming Using C#Dynamic Polymorphism In dynamic polymorphism, the decision about function execution is made at run time. Dynamic polymorphism is more useful than static polymorphism as it provides much more flexibility for manipulating the objects. C# uses two approaches to implement dynamic polymorphism: – Abstract classes: Are the special type of base classes that consist of abstract class members. – Virtual functions: Are the functions that do not really exist, however, appear to be present in some parts of the program. Ver. 1.0 Session 8 Slide 14 of 24
    15. 15. Object-Oriented Programming Using C#Implementing Function Overloading Function overloading is implemented by defining two or more functions in a class sharing the same name. In function overloading, each definition of a function must differ in its function signature. Ver. 1.0 Session 8 Slide 15 of 24
    16. 16. Object-Oriented Programming Using C#Function Signature The signature of a function is defined by: – The number of parameters – The data types of parameters – The sequence of the parameters Ver. 1.0 Session 8 Slide 16 of 24
    17. 17. Object-Oriented Programming Using C#Constructor Overloading Constructors can also be parameterized, and therefore, they can be overloaded. Overloaded constructors are commonly used in C# to provide flexibility while creating an object. Ver. 1.0 Session 8 Slide 17 of 24
    18. 18. Object-Oriented Programming Using C#Demo: Displaying Days Using Function Overloading Problem Statement: Tim has to develop a software application for a primary school. The application should accept the month entered by the student and display the total number of days of that month. Ver. 1.0 Session 8 Slide 18 of 24
    19. 19. Object-Oriented Programming Using C#Demo: Displaying Days Using Function Overloading (Contd.) Solution: To develop the required application, Tim needs to perform the following tasks: 1. Create a console-based application. 2. Build and execute an application. Ver. 1.0 Session 8 Slide 19 of 24
    20. 20. Object-Oriented Programming Using C#Operator Overloading Operator overloading provides additional capabilities to C# operators when they are applied to user-defined data types. Only the predefined set of C# operators can be overloaded. Ver. 1.0 Session 8 Slide 20 of 24
    21. 21. Object-Oriented Programming Using C#Need for Operator Overloading To use operators with user-defined data types, they need to be overloaded according to a programmer’s requirement. The following table describes the overload ability of the operators in C#. Operators Description +, -, ! , ~, ++ , -- These unary operators take one operand and can be overloaded. +, -, * , /, % These binary operators take two operands and can be overloaded. ==, !=, <, >, <=, >= The comparison operators can be overloaded. &&, || The conditional logical operators cannot be overloaded directly, but they are evaluated using & and | which can be overloaded. +=, -=, *=, /=, %= The assignment operators cannot be overloaded. =, ., ?:, ->, new, is, These operators cannot be overloaded. sizeof, typeof Ver. 1.0 Session 8 Slide 21 of 24
    22. 22. Object-Oriented Programming Using C#Summary In this lesson, you learned that: Constructors are member functions of a class and are invoked when an instance of the class to which they belong is created. A constructor has the same name as its class. A destructor is invoked when any instance of a class ceases to exist. A destructor has the same name as its class, but it is prefixed with a ~ (tilde). Constructors are special methods that allow control over the initialization of objects. Destructors are special methods that are used to release the instance of a class from memory. Garbage collection is a process that automatically frees the memory of objects that is no more in use. Ver. 1.0 Session 8 Slide 22 of 24
    23. 23. Object-Oriented Programming Using C#Summary (Contd.) – The Finalize() destructor is called after the last reference to an object is released from the memory. – The Dispose() method is called to release a resource, such as a database connection, when the object using such a resource is no longer in use. – The term polymorphism has been derived form the Greek words ‘poly’ and ‘morphos’, which mean ‘many’ and ‘forms’, respectively. – Polymorphism allows one interface to be used for multiple functions. – Static polymorphism refers to an entity, which exists in different forms simultaneously. – In dynamic polymorphism, the decision about function execution is made when code is executed. Ver. 1.0 Session 8 Slide 23 of 24
    24. 24. Object-Oriented Programming Using C#Summary (Contd.) Function overloading is the process of using the same name for two or more functions in a class. The number, type, or sequence of parameters of a function is called its function signature. Overloaded constructors are commonly used in C# to provide flexibility while creating an object. Operator overloading provides additional capabilities to C# operators when they are applied to user-defined data types. The predefined C# operators can be overloaded by using the operator keyword. Operators may be considered as functions internal to the compiler. Ver. 1.0 Session 8 Slide 24 of 24

    ×