12 iec t1_s1_oo_ps_session_17

692 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
692
On SlideShare
0
From Embeds
0
Number of Embeds
30
Actions
Shares
0
Downloads
63
Comments
0
Likes
0
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.
  • 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 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 12 iec t1_s1_oo_ps_session_17

    1. 1. Object-Oriented Programming Using C#Objectives In this session, you will learn to: Use delegate Types of delegates Use events with delegates Apply attributes Use predefined attributes Ver. 1.0 Session 17 Slide 1 of 27
    2. 2. Object-Oriented Programming Using C#Using Delegate You can call the delegate by giving the name of the delegate and by passing parameters, if required. Using delegates is similar to calling methods. Ver. 1.0 Session 17 Slide 2 of 27
    3. 3. Object-Oriented Programming Using C#Using Delegate (Contd.) The following example shows how to use a delegate: using System; using System.IO; // Program to write the data to the console and file namespace Chapter12_Ex1 { public class PrintToDevice { //Creating the variables of Stream classes static FileStream FStream; static StreamWriter SWriter; //Defining a Delegate //Method to send the string data to respective methods Ver. 1.0 Session 17 Slide 3 of 27
    4. 4. Object-Oriented Programming Using C#Using Delegate (Contd.) //removing the content from the buffer SWriter.Flush(); SWriter.Close(); FStream.Close(); } public delegate void PrintData(String s); //Method to print a string to the console public static void WriteConsole (string str) { Console.WriteLine("{0} Console", str); } //Method to print a string to a file public static void WriteFile (string s) Ver. 1.0 Session 17 Slide 4 of 27
    5. 5. Object-Oriented Programming Using C#Using Delegate (Contd.) { //Initializing stream objects FStream = new FileStream("c:StoreData.txt", FileMode.Append, FileAccess.Write); SWriter = new StreamWriter(FStream); s= s + " File"; //Writing a string to the file SWriter.WriteLine(s); } public static void DisplayData(PrintData PMethod) { PMethod ("This should go to the"); } public static void Main() Ver. 1.0 Session 17 Slide 5 of 27
    6. 6. Object-Oriented Programming Using C#Using Delegate { //Initializing the Delegate object PrintData Cn = new PrintData (WriteConsole); PrintData Fl = new PrintData (WriteFile); //Invoking the DisplayData method with the Delegate object as the argument //Using Delegate DisplayData (Cn); DisplayData (Fl); Console.ReadLine(); } } } Ver. 1.0 Session 17 Slide 6 of 27
    7. 7. Object-Oriented Programming Using C#Types of Delegates Delegates are of two types and depending upon the requirement of the application the suitable type of delegate is selected. Ver. 1.0 Session 17 Slide 7 of 27
    8. 8. Object-Oriented Programming Using C#Types of Delegates (Contd.) There are two types of delegates: Single-cast delegate Multicast delegate Ver. 1.0 Session 17 Slide 8 of 27
    9. 9. Object-Oriented Programming Using C#Single-Cast Delegate • A single-cast delegate derives from the System.Delegate class. • It contains reference to one method only at a time. Ver. 1.0 Session 17 Slide 9 of 27
    10. 10. Object-Oriented Programming Using C#Multicast Delegate A multicast delegate derives from the System.MulticastDelegate class. It contains an invocation list of multiple methods. In multicasting you create a single delegate that invokes multiple encapsulated methods. You need to ensure the return type of all these delegates is same. Multicast delegates hold the reference of more than one method therefore, if you call a multicast delegate it will executes all the methods it wraps in the calling order. The multiple methods called by the delegate in this case should not return any value. Several multicast delegates are called consecutively and you cannot wait to get the return value from each of these methods. Ver. 1.0 Session 17 Slide 10 of 27
    11. 11. Object-Oriented Programming Using C#Just a minute State whether the following statement is True or False. Multicast delegates inherit from the System.Delegate.MulticastDelegate class. Answer: False Ver. 1.0 Session 17 Slide 11 of 27
    12. 12. Object-Oriented Programming Using C#Working with Events An event is an action or occurrence, such as clicks, key presses, mouse movements, or system generated notifications. Applications can respond to events when they occur. Ver. 1.0 Session 17 Slide 12 of 27
    13. 13. Object-Oriented Programming Using C#Working with Events (Contd.) The following figure shows the alarm event and handling of the event. Clock Shows time. Time is 6 AM. Alarm plays a sound, notifying everyone that it is 6 AM. You hear the alarm. You get up and get ready For your school. Ver. 1.0 Session 17 Slide 13 of 27
    14. 14. Object-Oriented Programming Using C#Using Delegates with Events The events are declared and raised in a class and associated with the event handlers using delegates within the same class or other classes. Events are part of a class and the same class is used to publish its events. The other classes can, however, accept these events or in other words can subscribe to these events. Events use the publisher and subscriber model. – A publisher is an object that contains the definition of the event and the delegate. The association of the event with the delegate is also specified in the publisher class. – A subscriber is an object that wants to accept the event and provide a handler to the event. The delegate of the publisher class invokes the method of the subscriber class. Ver. 1.0 Session 17 Slide 14 of 27
    15. 15. Object-Oriented Programming Using C#Using Delegates with Events (Contd.) The following figure shows the mechanism used by the publisher and subscriber objects. Let us understand the using delegates with events in detail. Ver. 1.0 Session 17 Slide 15 of 27
    16. 16. Object-Oriented Programming Using C#Using Delegates with Events (Contd.) The implementation of an event includes: Events definition Events subscription Events notification Ver. 1.0 Session 17 Slide 16 of 27
    17. 17. Object-Oriented Programming Using C#Using Delegates with Events (Contd.) Defining an Event: The definition of the event in a publisher class includes the declaration of the delegate as well as the declaration of the event based on the delegate. The following code defines a delegate named TimeToRise and an event named RingAlarm, which invokes the TimeToRise delegate when it is raised: public delegate void TimeToRise(); private event TimeToRise RingAlarm; Ver. 1.0 Session 17 Slide 17 of 27
    18. 18. Object-Oriented Programming Using C#Using Delegates with Events (Contd.) Subscribing to an Event: – The event of the publisher class needs to be associated with its handler. – The event handler method is associated with the event using the delegate. – When the publisher object raises the event, the subscribing object associates the method, which needs to be called. – The requirement could be implemented using events. The following code shows how the Student class subscribes to the event named TimeToRise: Student PD= new Student(); RingAlarm = new TimeToRise(PD.WakeUp); Ver. 1.0 Session 17 Slide 18 of 27
    19. 19. Object-Oriented Programming Using C#Using Delegates with Events (Contd.) Notifying Subscribers to an Event: – The subscriber object notifies the subscriber object to the publisher object. The event is raised to notify the handler. – Write this block of code at a place from where you want to notify the event to the subscribers of the event: if (RingAlarm != null) { RingAlarm( ); } Ver. 1.0 Session 17 Slide 19 of 27
    20. 20. Object-Oriented Programming Using C#Passing Event Parameters • The methods that subscribe an event might expect some input to be passed. • The event class can have these inputs at runtime on which the subscribing method works. • You need to define the class that will pass the input to the event. • Derive this class from System.EventArgs. To pass values to a subscribing method, you need to enclose the parameters in a single class. • The single class supplies a special method called the accessor method to retrieve the value. • This method is used to examine or modify the members of a class. Ver. 1.0 Session 17 Slide 20 of 27
    21. 21. Object-Oriented Programming Using C#Demo: Attendance Log Problem Statement: In an air-conditioner manufacturing company, the working time is from 9 AM to 6 PM. The management of the company is flexible and it allows workers to arrive to work late by 1 hour. The entry time of workers is recorded electronically in a log file when they enter the premises of the company. The application used for recording the attendance of each worker needs to log the appropriate information. Help the company to design an application for logging attendance. Ver. 1.0 Session 17 Slide 21 of 27
    22. 22. Object-Oriented Programming Using C#Demo: Attendance Log (Contd.) Solution: To design the application, you need to perform the following tasks: 1. Identify the technique that you will use in the application. This technique will allow you to call the respective methods dynamically to log the attendance entry. 2. Create a console-based application to implement the attendance log of workers. 3. Compile and execute the application. Ver. 1.0 Session 17 Slide 22 of 27
    23. 23. Object-Oriented Programming Using C#Introducing Attributes • An object is described by the values of its attributes. • An attribute is a declarative tag that is used to convey information to runtime about the behavior of programmatic elements such as classes, enumerators, and assemblies. • A declarative tag is depicted by square ([ ]) brackets placed above the definition of an element such as a class or a method. • Attributes are used for adding metadata, such as compiler instructions and other information such as comments, description, methods, and classes to a program. • The .NET Framework is equipped with a number of predefined attributes. Ver. 1.0 Session 17 Slide 23 of 27
    24. 24. Object-Oriented Programming Using C#Applying Attributes Attributes are applied to different elements of the code. These elements include assemblies, modules, classes, structs, enums, constructors, methods, properties, fields, events, interfaces, parameters, return values, and delegates. Information about attributes is stored with the metadata of the elements they are associated with. The following syntax enables you to specify an attribute: [attribute(positional_parameters,name_parameter = value, ...)] element The .NET Framework supports two categories of attributes to be used in C# programs: Predefined Custom Ver. 1.0 Session 17 Slide 24 of 27
    25. 25. Object-Oriented Programming Using C#Using Predefined Attributes Some commonly used predefined attributes provided with .NET Framework are: Conditional WebMethod DLLImport Obsolete Ver. 1.0 Session 17 Slide 25 of 27
    26. 26. Object-Oriented Programming Using C#Summary In this session, you learned that: – There are two types of delegates, Single-cast delegate and Multicast delegate. – A single-cast cast delegate can call only one function. – Multicast delegate holds the reference of more than one method. – Single-cast delegate derives from the System.Delegate class and Multicast delegate derives from the System.MulticastDelegate class. – Events are the messages sent by an object to indicate the occurrence of an event. – Events use the publisher and subscriber model. – A publisher is an object that maintains its internal state. Ver. 1.0 Session 17 Slide 26 of 27
    27. 27. Object-Oriented Programming Using C#Summary (Contd.) – A subscriber is an object that registers an interest in an event. – An attribute is a declarative tag that is used to convey information to runtime about the behavior of programmatic elements such as classes, enumerators, and assemblies. – The .NET Framework supports two categories of attributes to be used in C# programs: predefined and custom. – Predefined attributes are supplied as part of the Common Language Runtime (CLR), and they are integrated into .NET. Ver. 1.0 Session 17 Slide 27 of 27

    ×