Visual Programming: Jawad Rafeeq Jawadrafeeq@ciitvehari - Edu.pk

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 38

Visual Programming

Lecture 1

Jawad Rafeeq
[email protected]
Outline
• What is visual programming
• VPL’s languages
• History
• Features of .NET framework
• Why C#
• C# vs VB
• C# vs Java
What is a VPL?
• A programming language that uses a visual representation (such as
graphics, drawings, animation or icons, partially or completely)

• A visual programming language (VPL) is a programming language that


uses graphical elements (screens, user interactions, buttons, forms,
images, etc.) and figures to develop a program.

• Any system where the user writes a program using two or more
dimensions [Myers 90]
VPL’s
• There are hundreds of VPL’s
• But mainly:
• VB
• Java
• C#
• etc
History
• Few years back, Microsoft had Visual C++, and VB to compete with java
• Java was catching the market very fast
• Web development and java tools were becoming the most popular
• Microsoft was loosing the battle
• Thousands of programmers moved to java from VC++ and VB
• Then Microsoft put their best man at work for secret project called Next
generation windows services (NGWS) under the supervision of Bill gates
• Outcome of project is the .NET framework
• It has really outperformed their competitors, started late but catching up
quickly
History
• “The .Net framework is a software development platform developed by
Microsoft. The framework was meant to create applications, which would
run on the Windows Platform.”
• “It enables developers to build extensible markup language (XML) web
services and applications”
• Microsoft borrowed most of its idea from JAVA
Feature of .NET framework
• Platform neutral framework
• It is a layer between OS and Programming language
• It supports many programming languages. C#, VB, Asp.net
• It is the part of operating system.
Why C#?
• It is a modern programming language, widely spread, used by
millions of programmers around the entire world.
• C# or VB?
• C# is a language that becomes more and more complex, and there is
no end of aggressive adding complexity (“new features”) in sight.
• In early 2017 that VB .NET was significantly slower in grow, not new
features added to VB (A number of developers feel that VB is a bad
product because it makes development simpler. )
Why C#?
• C# or JAVA?
• C# is undisputedly the better, more powerful, richer and just better
engineered (Fundamentals of Computer Programming with C#)
• Java is just a most popular and widely used language
• C# is deeply integrated with Windows
• C# contain more primitive data types than Java
• C# support enumerations, type-safe data types, and structs
• C# support more useful features that we can overload operators
• And many more will be covered in this course
Why C#?
Getting Started
With C# .NET

• Install Visual Studio


Creating a New C# Project

• Creating a New C# Project


• We can create a project in Visual Studio by following these steps: -
File -> New Project … - The “New Project” dialog appears and lists all
the different types of projects we can create. We can choose a project
type (e.g. Console Application or WPF Application), programming
language (e.g. C# or VB.NET) and .NET Framework version (e.g. .NET
Framework 4.5)
Creating a New C# Project
Creating a New C# Project
Universal Windows Platform
(UWP) is an API created by
Microsoft and first introduced
in Windows 10. The purpose
of this platform is to help
develop universal apps that
run on Windows 10, Windows
10 Mobile, Xbox. You can
publish them to the Microsoft
Store.
Creating a New C# Project
You can build
apps for Android, iOS, and
Windows by using
C# (Visual Basic is not
supported at this time)
Creating a New C# Project
Windows Presentation
Foundation (WPF) is a UI
framework that creates
desktop client
applications
Creating a New C# Project

It also mainly used for the


same purpose for
developing and designing
the windows applications
Creating a New C# Project

It also mainly used for the


same purpose for
developing and designing
the windows applications
Windows forms VS WPF

Win forms vs
Winforms WPF
WPF

Windows form is an old concept for developing WPF is advance or latest concept for
Advance
desktop applications developing the applications
Windows forms are simple to use as controls can be WPF is complex to use as compared to
Simple
easily used. Windows Forms.
In windows forms, things are achieved at the slower In WPF things are mainly achieved at very
Performance
rate. fast rate comparatively.
Creating a New C# Project

Console applications that


can run on every platform
like windows, Linux, Mac
etc, when you want to run
your code on any platform
windows, mac, linux etc
Creating a New C# Project

Console applications that


can run on windows
platform
A Start with Console Application (.NET framework)

?
A Start with Console Application (.NET framework)
• A project is contained within a solution.
• Despite its name, a solution is not an "answer".

• It's simply a container for one or more related projects, along with build information, Visual
Studio window settings, and various files

• A solution is described by a text file (extension .sln) with its own unique format;
• it's not intended to be edited by hand.
Extension Name Description

.sln Visual Studio Solution Organizes project items, and solution items in the
solution.
Understanding the interface of Visual Studio
• Menu bar
• Tool bar
• Solution Explorer
• Server Explorer
First Program in C#
Solution Explorer Before understanding the Program
• The file called AssemblyInfo.cs contains
information about your programme. Double
click this file to open it up and see the code.
Here's just some of it:

Red color text is something you can change. You can add a Title, Description, Copyright, Trademark, etc.
Solution Explorer Before understanding the Program
• A reference contains the information
• .NET class libraries or assemblies
• COM components
• Other assemblies or class libraries of projects in
the same solution
• XML Web services

You can add a reference later when needed.


Solution Explorer Before understanding the Program
• App.config
• It is also a special type of configuration file which is basically used
with Windows application, Console Apps or it can be WPF
application or any others.
• Web.config
• It is a configuration file, which is used in web application and it can
be an ASP.NET project or MVC project.
• What Is It?
• The app.config file is an XML file whose goal it is to contain any
variable configuration of your application. It is a central place to put:
• Connection strings to databases
• Connection details to external services
• Application settings
• Other details on how the application should be run and/or hosted

https://blog.submain.com/app-config-basics-best-practices/
Solution Explorer Before understanding the Program
Namespaces (.NET namespaces)
Namespaces (User defined namespaces)
Second, declaring your own namespaces can help you control the scope of
classes/functions in larger programming projects.
• // defining the namespace name1
• namespace name1
•{

• // C1 is the class in the namespace name1


• class C1
• {
• // class code
• }
•}
How to define own name space
• Note:

• Two classes with the same name can be created inside 2 different
namespaces in a single program.
• Inside a namespace, no two classes can have the same name.
• Class can work without namespace, but better practice to work in
namespace
• In C#, the full name of the class starts from its namespace name
followed by dot(.) operator and the class name, which is termed as
the fully qualified name of the class.
How to define own name space (2 class in one namespace)
To make accessible in other namespace
namespace firstNS {
class A To make accessible without declaring object
{ public static void display()
{
System.Console.WriteLine("Hello 1!");
}
}
class B
{
public static void Main(String []args)
{
firstNS.A.display();
}
}
Two name spaces (2 classes in 2 namespaces)
namespace firstNS
{
class A
{
public static void display()
{
System.Console.WriteLine("Hello 1!");
}
}
}
namespace secondNS
{
class B
{
public static void Main(string [] args)
{
firstNS.A.display();
}
}
}
How to define own name space (1 class in namespace, 2nd
without namespace)
using System;
namespace FirstApp
{
class Program
{
public static void display()
{
System.Console.WriteLine("Helloworld");
}
}
}
class abc
{
public static void Main(String[] args)
{
FirstApp.Program.display();
}
}
How to define own name space (1 class without namespace, 2nd
with namespace)
namespace FirstApp
{
class Program
{
public static void Main()
{
abc.display();
System.Console.WriteLine("This is main class");
}
}
}
class abc
{
public static void display()
{
System.Console.WriteLine("Helloworld");
}
}
How to define own name space (Using namespace in program.cs file)
using System;
using ClassSE;
namespace ClassSE
{
class program2
{

public static void display()


{
Console.WriteLine("Display from other namespace");
}
}
}
class Program
{
static void Main(string[] args)
{
program2.display();
Console.WriteLine("C# class is very active class");
}
}
END

You might also like