1. Object-Oriented Programming Using C#
Objectives
In this session, you will learn to:
Use static variables and static functions
Identify the components of the .NET Framework
Use the Visual Studio .NET IDE
Ver. 1.0 Session 5 Slide 1 of 35
2. Object-Oriented Programming Using C#
Static Variables and Static Functions
Each object has its own set of member variables.
To retain the value of a variable throughout the program,
you can declare the variable as a static variable.
To manipulate and use the values of static variables, you
can define a function as static function.
Ver. 1.0 Session 5 Slide 2 of 35
3. Object-Oriented Programming Using C#
Static Variables
• The keyword 'static' means that only one instance of a
given variable exists for a class.
• Static variables are used to define constants because their
values can be retrieved by invoking the class without
creating an instance of it.
• Static variables can be initialized outside the member
function or class definition.
• Unlike other member variables, only one copy of the static
variable exists in the memory for all the objects of that class.
Ver. 1.0 Session 5 Slide 3 of 35
4. Object-Oriented Programming Using C#
Static Functions
Static functions can access only static variables.
Static functions exist even before the object is created.
Ver. 1.0 Session 5 Slide 4 of 35
5. Object-Oriented Programming Using C#
Demo: Counting the Number of Times Function is Called by Using Static Functions
Problem Statement:
John a software developer in Zed Axsis Technology needs to
check how many times a function is called. For the same, he
has been asked to create the function called “CountFunction”.
Help John to create this function.
Ver. 1.0 Session 5 Slide 5 of 35
6. Object-Oriented Programming Using C#
Introducing the .NET Framework
The .NET Framework, introduced by Microsoft, aims at
integrating various programming languages and services.
The .NET Framework is designed to make significant
improvements in code reuse, code specialization, resource
management, multilanguage development, security,
deployment, and administration.
The .NET Framework consists of all the technologies that
help in creating and running robust, scalable, and
distributed applications.
Ver. 1.0 Session 5 Slide 6 of 35
7. Object-Oriented Programming Using C#
Introducing the .NET Framework (Contd.)
The .NET suite consists of:
.NET Products
.NET Services
.NET Framework
Let us understand each component of the .NET suite in
detail.
Ver. 1.0 Session 5 Slide 7 of 35
8. Object-Oriented Programming Using C#
Introducing the .NET Framework (Contd.)
.NET Products:
.NET products aim at allowing developers to create
applications, which are capable of interacting seamlessly with
each other.
All .NET products use eXtensible Markup Language (XML) for
describing and exchanging data between applications.
An example of a .NET product is Visual Studio .NET.
Ver. 1.0 Session 5 Slide 8 of 35
9. Object-Oriented Programming Using C#
Introducing the .NET Framework (Contd.)
.NET Services:
.NET helps you to create software as Web services. A Web
Service is an application or business logic that is accessible
through standard Internet protocols such as Hypertext Transfer
Protocol (HTTP) and Simple Object Access Protocol (SOAP).
You can identify the service by a Uniform Resource Locator
(URL).
Microsoft has come up with its own set of Web services, known
as My Services.
This service allows users to access data by linking calendars,
phonebooks, address books, and personal references to the
passport authentication service.
Ver. 1.0 Session 5 Slide 9 of 35
10. Object-Oriented Programming Using C#
Introducing the .NET Framework (Contd.)
• The .NET Framework:
It is the foundation for designing, developing, and deploying
applications.
It is the core of the .NET infrastructure because it exists as a
layer between the .NET applications and the underlying
operating system.
Let us understand the .NET Framework in detail.
Ver. 1.0 Session 5 Slide 10 of 35
11. Object-Oriented Programming Using C#
Components of the .NET Framework
The various components of the .NET Framework are:
Common Language Runtime
The .NET Framework Class Library
User and Program Interfaces
Ver. 1.0 Session 5 Slide 11 of 35
12. Object-Oriented Programming Using C#
Components of the .NET Framework (Contd.)
The following figure displays the various components of
the .NET Framework.
Common Language Runtime (CLR)
.NET Framework Class Libraries
Windows Console Web Forms and
Forms Applications Web Services
Ver. 1.0 Session 5 Slide 12 of 35
13. Object-Oriented Programming Using C#
Components of the .NET Framework (Contd.)
Common Language Runtime (CLR):
– CLR is the environment where all programs in .NET are
executed.
– CLR provides services such as code compilation, memory
allocation, and garbage collection.
– CLR allows the execution of code across different platforms by
translating code into Intermediate Language (IL).
– IL is a low level language that the CLR understands.
– IL is converted into machine language during execution by the
JIT compiler. During JIT compilation, code is also checked for
type safety.
– Type safety ensures that objects are always accessed in a
compatible way.
Ver. 1.0 Session 5 Slide 13 of 35
14. Object-Oriented Programming Using C#
Components of the .NET Framework (Contd.)
– CLR consists of a set of common rules followed by all the
languages of the .NET Framework. This set of rules is known
as Common Language Specification (CLS).
– CLS enables an object or application to interact with the
objects or applications of other languages.
– The classes that follow the rules specified by CLS are termed
as CLS-compliant classes. The classes defined in the .NET
Framework class library are CLS-compliant.
– One of the specifications defined in CLS is CTS, which
provides a type system that is common across all languages.
CTS define how data types are declared, used, and managed
in the code at run time.
– While executing the program, CLR:
Identifies the process of compilation
Identifies the process of code execution
Ver. 1.0 Session 5 Slide 14 of 35
15. Object-Oriented Programming Using C#
Components of the .NET Framework (Contd.)
The .NET Framework Class Library:
The .NET Framework class library works with any .NET
language, such as VB.NET, VC++ .NET, and VC#.
The .NET Framework class library provides classes that can
be used in the code to accomplish a range of common
programming tasks, such as string management, data
collection, database connectivity, and file access.
The .NET Framework class library comprises of:
Namespaces
Assemblies
Ver. 1.0 Session 5 Slide 15 of 35
16. Object-Oriented Programming Using C#
Components of the .NET Framework (Contd.)
User and Program Interfaces:
At the presentation layer, .NET provides three types of user
interfaces:
• Windows Forms
• Web Forms
• Console Applications
– .NET provides a program interface, Web Services, to
communicate with remote components.
Ver. 1.0 Session 5 Slide 16 of 35
17. Object-Oriented Programming Using C#
Components of the .NET Framework (Contd.)
Advantages of the .NET Framework:
– Consistent programming model
– Multi-platform applications
– Multi-language integration
– Automatic resource management
– Ease of deployment
Ver. 1.0 Session 5 Slide 17 of 35
18. Object-Oriented Programming Using C#
Using Visual Studio .NET IDE
The Visual Studio .NET IDE provides you with a common
interface for developing various kinds of projects for the
.NET Framework.
The IDE also provides you with a centralized location for
designing the user interface for an application, writing code,
and compiling and debugging the application.
Ver. 1.0 Session 5 Slide 18 of 35
19. Object-Oriented Programming Using C#
Creating Projects and Solutions
In Visual Studio .NET, an application can be made up of
one or more items, such as files and folders.
To organize these items efficiently, Visual Studio .NET has
provided two types of containers:
– Project: It typically contains items that make up the
application. These items are interrelated.
– Solution: It usually acts as a container for one or more
projects.
Ver. 1.0 Session 5 Slide 19 of 35
20. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
The following figure shows a solution with multiple projects.
Solution Project 1
Items
Project 1
Project 2
Project 2
Items
Miscellaneous
Files
Ver. 1.0 Session 5 Slide 20 of 35
21. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
To create a console application in Visual Studio, you need
to create a project. To create a project, you need to perform
the following steps:
– Select Start All Programs Microsoft Visual Studio
2005 Microsoft Visual Studio 2005. The
Start Page - Microsoft Visual Studio window will be
displayed.
Ver. 1.0 Session 5 Slide 21 of 35
22. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
– Select FileNewProject. The New Project dialog box will
be displayed.
Ver. 1.0 Session 5 Slide 22 of 35
23. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
– In the New Project dialog box, select Visual C# from the
Project Types pane and Console Application from the
Templates pane.
– Specify the name of the application in the Name text box.
– Specify the location where the new project is to be created in
the Location combo box. You can use the Browse button to
browse to the folder in which the new project is to be created.
– Click the OK button.
Ver. 1.0 Session 5 Slide 23 of 35
24. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
User Interface Elements of Visual Studio .NET IDE:
When you work with a console application project in Visual
Studio .NET, you can use the following main elements in
Visual Studio .NET IDE.
Ver. 1.0 Session 5 Slide 24 of 35
25. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
Standard Toolbar:
The Standard toolbar is located below the menu bar. It provides
shortcuts for menu commands.
Ver. 1.0 Session 5 Slide 25 of 35
26. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
The following table shows the various components of
Standard toolbar.
Name Button Function
NewProject Creates a new project
Add New Item Add new item in the
project
Save Saves the Program.
SaveAll Save all the unsaved
items of the application
Cut Places selected text or
objects on the Windows
Clipboard
Copy Places a copy of selected
text or objects on the
Windows Clipboard
Paste Pastes the contents of
the Clipboard on the
document.
Start Debugging Compiles and Executes
the current project.
Ver. 1.0 Session 5 Slide 26 of 35
27. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
– The Start Page:
When you start Visual Studio .NET, it displays the
Start Page- Microsoft Visual Studio.
The Start Page is the default home page for the browser provided
within the Visual Studio .NET IDE.
This tab displays some of the recent projects and the last date of
their modification. You can open any one of these projects.
Ver. 1.0 Session 5 Slide 27 of 35
28. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
The Solution Explorer Window:
• The Solution Explorer window lists the solution name, the project
name, and all the classes that are used in the project.
Ver. 1.0 Session 5 Slide 28 of 35
29. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
The Output Window:
• The Output window displays messages for the status of various
features provided in the Visual Studio .NET IDE.
Ver. 1.0 Session 5 Slide 29 of 35
30. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
The Error List Window:
The Error List window displays a list of errors along with the
source (the file and the line number) of the error. It helps you
identify and locate problems that are detected automatically as
you edit or compile code.
Ver. 1.0 Session 5 Slide 30 of 35
31. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
The Class View Window:
The Class View window displays the classes, methods, and
properties associated with a particular file. They are displayed in a
hierarchical tree-view depicting the containership of these items.
Ver. 1.0 Session 5 Slide 31 of 35
32. Object-Oriented Programming Using C#
Creating Projects and Solutions (Contd.)
The Code Editor:
The code editor allows you to enter and edit code. You may use
this editor to add code for your class.
Ver. 1.0 Session 5 Slide 32 of 35
33. Object-Oriented Programming Using C#
Compiling and Executing Project
To compile and execute the application, you need to
perform the following steps:
• Select BuildBuild Solution or press F6 to compile the
application.
• Select DebugStart Debugging or press F5 to execute the
application.
Ver. 1.0 Session 5 Slide 33 of 35
34. Object-Oriented Programming Using C#
Summary
In this session, you learned that:
The static variable retains its value even after the function to
which it belongs has been executed.
The static functions can access only static variables.
Non-static variables cannot be accessed by using static
functions.
The .NET Framework is made up of many components, such
as Common Language Specification (CLS), Common language
Runtime (CLR), and Just-In-Time (JIT) compiler.
CLS is a set of rules that are followed by all the languages of
the .NET Framework.
When a program is compiled using Visual Studio .NET the
compiler translates the code into the Intermediate Language
(IL) instead of machine language.
Ver. 1.0 Session 5 Slide 34 of 35
35. Object-Oriented Programming Using C#
Summary (Contd.)
The Just-In-Time (JIT) compiler is used to translate code from
IL into machine language.
The Common Language Runtime (CLR) is the environment
where all .NET applications are executed.
The Visual Studio .NET Integrated Development Environment
(IDE) provides you with a common interface for developing
various kinds of applications for the .NET Framework.
Visual Studio .NET provides two types of containers, projects
and solutions to organize the constituents of an application.
Ver. 1.0 Session 5 Slide 35 of 35
Notas del editor
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.
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.
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.
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.
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.
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.