0% found this document useful (0 votes)
5 views21 pages

Lecture 1

The document introduces a course on Visual Programming taught by Junaid Siddiqui, who has a PhD in Program Analysis. The course covers graphical user interfaces, event-driven models, and programming for desktop, web, and mobile platforms, with prerequisites in C++ and Data Structures. It includes hands-on examples, assignments, and focuses on event processing and Windows Presentation Foundation (WPF) concepts, along with introducing AJAX for web programming and mobile event-driven programming later in the course.

Uploaded by

Aamir Shahzad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views21 pages

Lecture 1

The document introduces a course on Visual Programming taught by Junaid Siddiqui, who has a PhD in Program Analysis. The course covers graphical user interfaces, event-driven models, and programming for desktop, web, and mobile platforms, with prerequisites in C++ and Data Structures. It includes hands-on examples, assignments, and focuses on event processing and Windows Presentation Foundation (WPF) concepts, along with introducing AJAX for web programming and mobile event-driven programming later in the course.

Uploaded by

Aamir Shahzad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

Visual

Programming
Junaid Haroon Siddiqui
Welcome

• My name is Junaid Siddiqui


• I have a PhD in Program Analysis
from the University of Texas at
Austin
• and I will be teaching you the
course on “Visual Programming”
What this course is
about?
• Graphical user interfaces
• event-driven model
• desktop / web / mobile

• ground up approach from what you


know
Pre-requisites
• C++ Programming
• Data Structures

• will introduce new languages and


concepts
Examples/
Assignments

• Hands on course
• in class examples
• assignments
Books
• 2 books

• Event Processing in Action


• Windows Presentation Foundation
Unleashed
Event Processing
in Action
• by Opher Etzion and Peter Niblett
• very few books on event
processing
• often taught as a side-concept
• we will focus on it
Windows Presentation
Foundation Unleashed
• the other book by Adam Nathan
• or WPF in short
• use it as our gui example with C#
• introduce C# concepts and WPF
concepts
• not a pre-req
Later in the course

• We will touch event-driven


programming in the browser
• In particular made possible by
techniques called AJAX
• Again no pre-req, I will introduce
all the concepts
Towards the very
end

• Event driven programming on


mobiles
• No pre-req, I will introduce all the
tools etc
Visual
Programming
• What you will learn in this course
• Event driven concepts
• Application of these concepts on
GUI programs on desktop, web,
and mobile
Our first example
#include <iostream>

int main()

char a;

do {

a = std::cin.get();

std::cout << a;

} while (a!='x');

return 0;

}
• lets compile and run
• g++ -o example1 example1.cc
• ./example1
Our second
#include <iostream>

#include <fstream>
example
int main()

char a = '-';

do {

std::ifstream f("test.txt", std::ifstream::in);

if (f.good() && a != f.peek()) {

a = f.get();

std::cout << a << std::endl;

f.close();

} while (a!='x');

return 0;

}
• lets compile and run
• what does echo command do
• few issues like busy wait but lets
leave them on a side for now
So far so good

• Why we saw these two very basic


examples
• Very easy to write --- no issues
• Can we combine them with an
OR ?
#include <iostream>
#include <fstream>

int main()
{
char a = '-', b;
do {
if (IsKeyboardPressed()) {
b = std::cin.get();
std::cout << b << std::endl;
}
std::ifstream f("test.txt", std::ifstream::in);
if (f.good() && a != f.peek()) {
a = f.get();
std::cout << a << std::endl;
}
f.close();
} while (a!='x' && b!='x');
return 0;
}

int onKeyPress()

Refactore
{
char b = std::cin.get();
std::cout << b << std::endl;
return b == 'x';

d
}
int onFileChanged()
{
char a = f.get();
std::cout << a << std::endl;
return a == 'x';
}
int main()
{
char a = '-', b;
do {
if (IsKeyboardPressed()) {
if (onKeyPress())
return 0;
}
std::ifstream f("test.txt", std::ifstream::in);
if (f.good() && a != f.peek()) {
if (onFileChanged())
return 0;
}
f.close();
} while (true);
return 0;
}
Pros and Cons of
this approach
• One thing at a time (more focused)
• Blocking is a huge issue
• Nothing is parallel
• Once you understand the
approach, it scales well
Revise
Next time

• Define events, event loops, and


different terms in the event driven
model

You might also like