Visual studio
W
Description
its all for educational purpose
Shared by: yaaritoall
-
Stats
- views:
- 16
- posted:
- 3/3/2013
- language:
- pages:
- 40
Document Sample


Visual Programming
Instructor: Fahad Hassan
Lecture # 02
1 Fahad Hassan | The University of Lahore
Outline
Visual Programming
Advantages & Disadvantages of Visual Programming
.NET Framework Overview
Managed VS Un-managed Code
.NET Framework Components
Languages and the .NET Framework
.NET Program Structure
Types in .NET
Compilation & Execution of a .NET Application
Visual C# .NET
Reading Suggestions
2 Fahad Hassan | The University of Lahore
Visual Programming
A programming language that uses a visual representation
(such as graphics, drawings, animation or icons, partially or
completely)
A visual language manipulates visual information or
supports visual interaction, or allows programming with
visual expressions [Golin 90]
Any system where the user writes a program using two
or more dimensions [Myers 90]
A visual language is a set of spatial arrangements of text-
graphic symbols with a semantic interpretation that is
used in carrying out communication actions in the world
3 Fahad Hassan | The University of Lahore
What are NOT VPLs?
Visual Basic, Visual C++, Delphi, etc.
Still primarily textual languages with a graphical GUI builder
User interface portion of the language is visual, the rest is not
4 Fahad Hassan | The University of Lahore
Motivations - Visual Programming
Many people think in pictures.
Textual programming languages have proven to be difficult
for many people to learn to use effectively.
Some applications are very well suited to graphical
development approaches.
Scientific visualization
System simulation
5 Fahad Hassan | The University of Lahore
Disadvantages of Visual Programming
As the name implies the entire process of developing an
application is Visual therefore the development
environment is highly graphical and requires more
memory and high speed processor
Visual development environment can only be used with
Graphical User Interface operating system like windows
6 Fahad Hassan | The University of Lahore
.NET Framework
The .NET Framework (pronounced dot net) is a software
framework developed by Microsoft that runs primarily on
Microsoft Windows. It includes a large library and
provides language interoperability (each language can use
code written in other languages) across several
programming languages.
7 Fahad Hassan | The University of Lahore
.NET Framework (Cont…)
The .NET Framework is a managed, type-safe
environment for application development and execution.
The framework manages all aspects of the execution of
your program: it allocates memory for the storage of data
and instructions, grants or denies the appropriate
permissions to your application, initiates and manages
application execution, and manages the reallocation of
memory for resources that are no longer needed.
8 Fahad Hassan | The University of Lahore
Managed VS Un-managed Code
Managed code is what Visual Basic .NET and C#
compilers create. It runs on the CLR (Common Language
Runtime), which, among other things, offers services like
garbage collection, run-time type checking, and reference
checking. So, think of it as, "My code is managed by the
CLR.“
Visual Basic and C# can only produce managed code, so, if
you're writing an application in one of those languages
you are writing an application managed by the CLR. If you
are writing an application in Visual C++ .NET you can
produce managed code if you like, but it's optional.
9 Fahad Hassan | The University of Lahore
Managed VS Un-managed Code (Cont…)
Unmanaged code compiles straight to machine code. So,
by that definition all code compiled by traditional C/C++
compilers is 'unmanaged code'. Also, since it compiles to
machine code and not an intermediate language it is non-
portable.
No free memory management or anything else the CLR
provides.
Since you cannot create unmanaged code with Visual
Basic or C#, in Visual Studio all unmanaged code is
written in C/C++.
10 Fahad Hassan | The University of Lahore
.NET Framework Components
The .NET Framework consists of two main components:
the common language runtime (CLR) and the .NET
Framework class library.
11 Fahad Hassan | The University of Lahore
Common Language Runtime
The common language runtime can be thought of as the
environment that manages code execution. It provides
core services, such as code compilation, memory
allocation, thread management, and garbage collection.
Through the common type system (CTS), it enforces
strict type safety, and it ensures that code is executed in a
safe environment by enforcing code access security.
12 Fahad Hassan | The University of Lahore
.NET Framework class library
The .NET Framework class library provides a collection
of useful and reusable types that are designed to integrate
with the common language runtime.
The types provided by the .NET Framework are object-
oriented and fully extensible, and allow you to seamlessly
integrate your applications with the .NET Framework.
13 Fahad Hassan | The University of Lahore
Languages and the .NET Framework
The .NET Framework is designed for cross-language
compatibility.
.NET components can interact with each other no matter
what language they were originally written in.
So, an application written in Microsoft Visual Basic .NET
might reference a DLL file written in Microsoft C#, which
in turn might access a resource written in managed
Microsoft C++ or any other .NET language.
14 Fahad Hassan | The University of Lahore
.NET Program Execution
This level of cross-language compatibility is possible
because of the common language run time.
When a .NET application is compiled, it is converted from
the language it was written in (Visual Basic .NET, C#, or
any other .NET compliant language) to Microsoft
Intermediate Language (MSIL or IL).
MSIL/IL is a low-level language designed to be read and
understood by the common language run time.
15 Fahad Hassan | The University of Lahore
.NET Program Execution (Cont…)
Because all .NET executables and DLLs exist as
intermediate language, they can freely interoperate.
The Common Language Specification defines the minimum
standards that .NET language compilers must conform to,
and thus ensures that any source code compiled by a
.NET compiler can interoperate with the .NET
Framework.
16 Fahad Hassan | The University of Lahore
.NET Program Execution (Cont…)
The CTS ensures type compatibility between .NET
components. Because .NET applications are converted to
IL prior to deployment and execution, all primitive data
types are represented as .NET types. Thus, a Visual Basic
Integer and a C# int are both represented in IL code as a
System.Int
Because both languages use a common and
interconvertable type system, it is possible to transfer
data between components and avoid time-consuming
conversions or hard-to-find errors. 32.
17 Fahad Hassan | The University of Lahore
.NET Program Execution (Cont…)
18 Fahad Hassan | The University of Lahore
19 Fahad Hassan | The University of Lahore
.NET Program Structure
The primary unit of a .NET application is the assembly.
An assembly is a self-describing collection of code, resources, and
metadata. The assembly manifest contains information about what is
contained within the assembly.
The assembly manifest provides
Identity information, such as the name and version number of the
assembly.
A list of all types exposed by the assembly.
A list of other assemblies required by the assembly.
A list of code access security instructions for the assembly. This includes
a list of permissions required by the assembly and permissions to be
denied the assembly.
20 Fahad Hassan | The University of Lahore
.NET Program Structure (Cont…)
Each assembly has one and only one assembly manifest,
and it contains all the description information for the
assembly.
The assembly manifest can be contained in its own
separate file, or it can be contained within one of the
assembly's modules.
21 Fahad Hassan | The University of Lahore
22 Fahad Hassan | The University of Lahore
.NET Program Structure (Cont…)
An assembly also contains one or more modules.
A module contains the code that makes up your application or
library, and metadata that describes that code.
When you compile a project into an assembly, your code is
converted from high-level code to IL. Because all managed
code is first converted to IL code, applications written in
different languages can easily interact.
For example, one developer might write an application in
Visual C# that accesses a DLL in Visual Basic .NET. Both
resources will be converted to IL modules before being
executed, thus avoiding any language incompatibility issues.
23 Fahad Hassan | The University of Lahore
Types in .NET
Each module also contains a number of types.
Types are templates that describe a set of data
encapsulation and functionality.
There are two kinds of types: reference types (classes) and
value types (structures).
24 Fahad Hassan | The University of Lahore
Types in .NET (Cont…)
A type can contain fields, properties, and methods, each
of which should be related to a common functionality.
For example, you might have a class that represents a
bank account. It would contain fields, properties, and
methods related to the functions needed to implement a
bank account.
25 Fahad Hassan | The University of Lahore
A field represents storage of a particular type of data. You
might have a field that stores the name of an account holder.
Properties are similar to fields, but usually provide some kind
of validation when the data is set or retrieved. You might have
a property that represents the balance available in an account.
When an attempt is made to change the value, the property
could check to see if the attempted change was greater than a
predetermined limit, and if so, could disallow the change.
26 Fahad Hassan | The University of Lahore
Methods represent behavior, such as actions taken on
data stored within the class or changes to the user
interface.
Continuing with the bank account example, you might
have a Transfer method that transfers a balance from a
checking account to a savings account, or an Alert method
that warns the user when his balance has fallen below a
predetermined level.
27 Fahad Hassan | The University of Lahore
Compilation & Execution of a .NET App.
A .NET executable is stored as an IL file. When loaded,
the assembly is checked against the security policy of the
local system. If it is allowed to run, the first assembly is
loaded into memory and JIT compiled into native binary
code where it is stored for the remainder of the
program's execution.
28 Fahad Hassan | The University of Lahore
Problem Solving Techniques
How to solve any programmatic problem?
Decompose the problem
Make a flow chart for better understanding
Write Pseudocode
Translate this code to the actual programming language
29 Fahad Hassan | The University of Lahore
Console Application – Tutorial
30 Fahad Hassan | The University of Lahore
Console Application – Tutorial (Cont…)
31 Fahad Hassan | The University of Lahore
32 Fahad Hassan | The University of Lahore
Solution Explorer
It allows you to navigate around the various files and
other items that make up your projects and your
solution.
Generally, double‐clicking on a file will open that file,
either in a text editor or perhaps some kind of visual
design surface. Some files can be edited in various ways.
33 Fahad Hassan | The University of Lahore
Error List
Shows compile time errors, warnings and other related
messages
34 Fahad Hassan | The University of Lahore
Output
Displays the output of the program other than the
console
35 Fahad Hassan | The University of Lahore
How to add/remove any section?
36 Fahad Hassan | The University of Lahore
Console Output
37 Fahad Hassan | The University of Lahore
Visual C# .NET
Visual C# .NET is part of the Visual Studio family.
Visual Studio is a complete development environment,
and it's called the IDE (short for Integrated Development
Environment). The IDE is the design framework in which
you build applications; every tool you'll need to create
your Visual C# .NET projects is accessed from within the
Visual Studio IDE.
C# is designed to be a platform-independent language in
the tradition of Java (although it is implemented primarily
on Windows).
38 Fahad Hassan | The University of Lahore
Visual C# .NET
It's syntax is similar to C and C++ syntax, and C# is
designed to be an object-oriented language.
Another helpful feature of C# is garbage collection.
Therefore, it is unnecessary to include a destructor for
each class unless a class handles unmanaged resources; if
so, it's necessary to release control those resources from
within the class (The Finalize function is used to clear up
these unmanaged resources; it can even be abbreviated
with the same syntax as a C++ destructor). Of course,
C# also provides direct access to memory through C++
style pointers, but these pointers are not garbage
collected until specifically released by the programmer.
39 Fahad Hassan | The University of Lahore
Reading Suggestions
Consult the course site, under Lect 02 folder.
https://sites.google.com/a/cs.uol.edu.pk/visual-programming/
Note: You only need to read page 2 to 8 for
ProblemSolving.pdf. Rest you need to study all the
documents.
40 Fahad Hassan | The University of Lahore
Get documents about "