0% found this document useful (0 votes)
15 views2 pages

CS411 Midterm CheatSheet

The cheat sheet covers core concepts of event-driven programming, including event loops, synchronous vs asynchronous processing, and types of events. It provides basic C++ and C# code examples for input loops and GUI applications, as well as explanations of events, delegates, and exception handling in C#. Additionally, it includes quick definitions of key terms related to visual programming.

Uploaded by

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

CS411 Midterm CheatSheet

The cheat sheet covers core concepts of event-driven programming, including event loops, synchronous vs asynchronous processing, and types of events. It provides basic C++ and C# code examples for input loops and GUI applications, as well as explanations of events, delegates, and exception handling in C#. Additionally, it includes quick definitions of key terms related to visual programming.

Uploaded by

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

CS411 Visual Programming Midterm Cheat Sheet

Core Concepts

1. Event-Driven Programming: Programs respond to events like button clicks, keypresses, etc.
2. Event Loop: Continuously checks for events and handles them.
3. Synchronous vs Asynchronous:
- Sync: Waits for task to finish before moving on.
- Async: Can handle multiple tasks at the same time.
4. Event Types: Raw Event, Derived Event, Event Stream, Stateless Agent.
5. Event-Based vs Request-Based:
- Event-Based: Push, loosely coupled (e.g., GUI).
- Request-Based: Pull, tightly coupled (e.g., Web).

C++ Basics

Simple Input Loop:


#include <iostream>
using namespace std;
int main() {
char a;
do {
a = cin.get();
cout << a;
} while (a != 'x');
return 0;
}

C# Basics & Windows Forms

Hello World (Console):


using System;
class Program {
static void Main() {
Console.WriteLine("Hello world!");
}
}

Hello World (GUI):


using System.Windows.Forms;
class Program {
static void Main() {
MessageBox.Show("Hello world!");
}
}

Events and Delegates (C#)


CS411 Visual Programming Midterm Cheat Sheet

public delegate void MyEventHandler();


public class MyForm : Form {
public event MyEventHandler myEvent;
public MyForm() {
myEvent += new MyEventHandler(MyEventFunction);
myEvent(); // fire event
}
public void MyEventFunction() {
MessageBox.Show("Event Fired!");
}
}

Exception Handling (C#)

try {
File.OpenRead("file.txt");
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
} finally {
Console.WriteLine("Cleanup done");
}

Quick Definitions

- Event: An occurrence like a click or file change.


- Event Producer: Source that generates event.
- Event Consumer: Component that reacts to event.
- Delegate: Reference to a method.
- MessageBox: GUI pop-up alert.
- Polymorphism: Ability to call derived class methods using base class reference.

You might also like