Archive

Archive for March, 2007

Linking: Static & Dynamic

March 6th, 2007

When we compile a program, the code for the various in-built functions are copied from the appropriate libraries. This process of linking of library functions during compilation is called Static Linking.

The process of linking of library functions during runtime is called Dynamic Linking. In Dynamic Linking, the code for the functions are not copied during compilation, rather only a reference to them is added. At runtime, the reference is resolved (when needed) and the code inside the library where the function definition exists is given the control. After completion the control is passed to the application.

Note:- Control here implies the flow of execution.

Dynamic Linking has various advantages when compared to static linking:-

  • Smaller Size of Compiled Application: The function definitions
  • Easy Updation: The program does not need recompilation if the library is updated.
  • Better Memory Usage: A Library can be shared by multiple programs, thus the memory requirement is reduced.

A compiled library file has an extension .dll which stands for Dynamic Link Library.

partho General

Linking: Static & Dynamic

March 6th, 2007

When we compile a program, the code for the various in-built functions are copied from the appropriate libraries. This process of linking of library functions during compilation is called Static Linking.

The process of linking of library functions during runtime is called Dynamic Linking. In Dynamic Linking, the code for the functions are not copied during compilation, rather only a reference to them is added. At runtime, the reference is resolved (when needed) and the code inside the library where the function definition exists is given the control. After completion the control is passed to the application.

Note:- Control here implies the flow of execution.

Dynamic Linking has various advantages when compared to static linking:-

  • Smaller Size of Compiled Application: The function definitions
  • Easy Updation: The program does not need recompilation if the library is updated.
  • Better Memory Usage: A Library can be shared by multiple programs, thus the memory requirement is reduced.

A compiled library file has an extension .dll which stands for Dynamic Link Library.

partho General

Event Driven Programming

March 5th, 2007

Prior to the Event Driven model, programming was procedural, where there would be an entry point for the application, typically known as the main function. From there, the flow of execution could be branched to different modules depending upon conditions such as inputs from the user. In an Event Driven Paradigm, the execution is not necessarily continuous. The statements that will be executed depend on the events. The events could be user generated: Clicking a Button, Closing a Window, Moving the mouse over a contol and so on, or system generated such as elapsing of a timer’s interval.

We write codes corresponding to these events which are executed when ever the event takes place. For example, the following code shows a dialog box with the message “Hello World” when the Show button is clicked:-

private void ShowMessage_Click(object sender, EventArgs e)
{
	MessageBox.Show("Hello World");
}

Notice the words object sender, EventArgs e, these are the parameters being passed along with the event. These parameters are used to determine the state of the control. In the following example, the KeyPressEventArgs being passed along with the event, is used to determine the key that was pressed in a text box.

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
	MessageBox.Show(e.KeyChar.ToString());
}

partho General

Introduction to User Interface

March 5th, 2007

User Interface is the layer between the User and the Application that enables the user to interact with the application. User Interfaces are either Console (CUI) or Graphical (GUI).

In a Console User Interface such as the one shown below, the user needs to use pre-defined commands to interact with the application. In general, the keyboard is used for input.

CUI

Unlike in a CUI, the user does not need to remember commands for interacting with the application, rather various controls are used for the same. Also, pointing devices such as the mouse are used along with the keyboard.

GUI

There are various types of controls to help us in enabling the User to interact with our application. Below is an image showing a few of the pre-defined controls.

GUI

Only container controls can exist on their own. All other controls have to reside inside containers.
Note: A container can also contain another container.

In the previous image, the Window which contains all the controls viz Label, Button, Text Box, etc, is the container we call Windows Form. A Dialog box is a special type of Form that is used to group related controls. Typically, the dialog boxes are used to notify an event or error, ask for an input, etc.

GUI

Dialog boxes are of three types:-

Modal

A modal dialog box does not allow you to switch focus to another area of the application (unless it is closed). For Example, the Save As Dialog box in Paint.

GUI

Modeless

A modeless dialog box allows you to switch focus to another area of the application. For Example, the Find & Replace dialog box in Notepad.

GUI

System Modal

A system modal dialog box is a system wide modal dialog box which does not allow the focus to be switched to any other application.

GUI

partho General