Archive

Archive for the ‘General’ Category

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());
}

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

General

The Essence of Visual Basic

February 7th, 2007

Simplicity and ease of use, is what makes Visual Basic the most popular programming language in the World. Introduced as the Rapid Application Development (RAD) Tool, Visual Basic gained much fame because of the innovative features it pioneered:-

The name visual itself is very important, for the first time, people could drag and drop controls onto a design surface and see how a program would look without going through the lengthy edit-compile-test cycles required by other languages.

Stepping Through Code

Stepping through code while debugging – just ask any VB developer if they could do without it.

Stepping Through

The introduction of Active X Controls took the idea of code re-usability to a completely new level. VB was also the first popular general-purpose language to offer truly integrated database access. The IDE concept that VB revolutionized has now been incorporated by non Microsoft products too (Delphi, Java).

Intellisense

It speeds up software development by reducing the amount of keyboard input required and allows less reference to external documentation due to embedded function signatures and short descriptions.

Intellisense

Case Insensitivity

Nothing personal against the shift key, but holding it up and down is really annoying. Try typing miCRoSCoPiC^eaRthLinG for a change.

Shift Key

True it lacked the pure object oriented power of other languages, but hasn’t it caught up with the new .NET version? As we programmers grow lazier day by day, changes such as these are immensely welcome and with the further advent of hi-tech sidekicks, we will do so even more.

General

The .NET Framework & The CLR

February 6th, 2007


The .NET Framework is Microsoft’s answer to the JAVA platform. With heavy investments going into the development, one can’t question the push Microsoft is giving to this technology. Living in the hi-tech industry and not interacting with the .NET Framework is highly unlikely, considering the market share that Microsoft’s Operating Systems have. I am writing this article as a means to further the knowledge that I would be gaining while learning the MCAD Training Kit (maybe in the process, helping out some beginners). For those of you who don’t know what the MCAD is, its one of the certification program offered by Microsoft. Short for Microsoft Certified Application Developer, the MCAD is aimed at developers. The MCAD I would be trying, is for the .NET Framework. For further information on Microsoft’s certification programs, check out the following links:-

The .NET Framework

Basically the .NET Framework is comprised of two components: The CLR and the .NET Class Library. CLR stands for Common Language Runtime and allows the interoperability between the various .NET languages. The class library is comprised of a lot of reusable components (Classes, Functions, Methods etc) that aid us in doing common repetitive operations.

The CLR

The CLR sweeps away the traditional concept of the Application having to manage everything from Memory Allocation & Garbage Collection to Thread Management. The .NET Framework is responsible for performing the above mentioned operations. Its another excellent move as developers can now focus on matters concerning the application’s logic without having to waste time on managing these iterative issues.

What’s with the multiple programming languages?

Developers using Microsoft Application Development Tools, could be natively put into two categories – those from the C/C++ background and those with the history of the BASIC language. Packed with a lot of punch & power, C/C++ was the choice for making advanced programs. But it had its shortcomings too, most noticeably the complexities involved with the language itself. Case Sensitivity and type strictness are a few of them to be named. While these measures minimize the potentially dangerous bugs that would take us hours to determine and debug, they are annoying to some developers. BASIC was aimed at being a friendly, English like language that could be understood and mastered by the average human. Originally it was way behind its counterpart in terms of power, but with time it has been catching up.

With introduction of the CLR based .NET Framework, Microsoft has instilled the freedom of language to the developers. Developers with expertise in different .NET languages can now work together in projects, thus increasing productivity.

The .NET Languages

Apart from those offered by Microsoft – VB, C# & C++ there are other languages that target the .NET Framework. COBOL, PERL, FORTRAN are just a few to name. All .NET Languages follow the Common Language Specification (CLS) to facilitate this.

How does the Interoperability work?

Programs written in .NET Languages are not compiled to machine code, rather into an Intermediate Language known as MSIL (Microsoft Intermediate Language) or just IL. So, any assembly written in the .NET languages, are the same internally. This implies that the atomic data types such as Integer, Float, etc are now the same in VB, C# & C++.

Because of being compiled to MSIL, the reverse engineering of code becomes easier for .NET assemblies. It can seriously compromise security of a program, but thankfully there are obfuscation techniques to overcome it. Microsoft Visual Studio 2005 ships with a lite edition of dotfuscator. There are various other Obfuscators available in the market too.

Basic Structure of a .NET Application

.NET applications are comprised of assemblies. An assembly is a self-descriptive collection of codes, resources and metadata. Each assembly has a manifest which provides information pertaining to the assembly viz Assembly naming & versioning, list of all types exposed by the assembly, dependency on other assemblies & code security instructions. The manifest can exist externally or internally within a module of the assembly.

Compilation & Execution

As mentioned before, the .NET applications are compiled to the MSIL. During runtime, the MSIL is compiled into native binary code by the Just In Time (JIT) compiler. When the execution begins, the starting assembly is loaded and its manifest is validated. After all the security requirements are met, the assembly is executed. An important feature of the JIT compiler is that only the execution path of the assembly is compiled, thus maximizing performance.

General

The .NET Framework & The CLR

February 6th, 2007

Microsoft .NET Framework
The .NET Framework is Microsoft’s answer to the JAVA platform. With heavy investments going into the development, one can’t question the push Microsoft is giving to this technology. Living in the hi-tech industry and not interacting with the .NET Framework is highly unlikely, considering the market share that Microsoft’s Operating Systems have. I am writing this article as a means to further the knowledge that I would be gaining while learning the MCAD Training Kit (maybe in the process, helping out some beginners). For those of you who don’t know what the MCAD is, its one of the certification program offered by Microsoft. Short for Microsoft Certified Application Developer, the MCAD is aimed at developers. The MCAD I would be trying, is for the .NET Framework. For further information on Microsoft’s certification programs, check out the following links:-

The .NET Framework

Basically the .NET Framework is comprised of two components: The CLR and the .NET Class Library. CLR stands for Common Language Runtime and allows the interoperability between the various .NET languages. The class library is comprised of a lot of reusable components (Classes, Functions, Methods etc) that aid us in doing common repetitive operations.

The CLR

The CLR sweeps away the traditional concept of the Application having to manage everything from Memory Allocation & Garbage Collection to Thread Management. The .NET Framework is responsible for performing the above mentioned operations. Its another excellent move as developers can now focus on matters concerning the application’s logic without having to waste time on managing these iterative issues.

What’s with the multiple programming languages?

Developers using Microsoft Application Development Tools, could be natively put into two categories – those from the C/C++ background and those with the history of the BASIC language. Packed with a lot of punch & power, C/C++ was the choice for making advanced programs. But it had its shortcomings too, most noticeably the complexities involved with the language itself. Case Sensitivity and type strictness are a few of them to be named. While these measures minimize the potentially dangerous bugs that would take us hours to determine and debug, they are annoying to some developers. BASIC was aimed at being a friendly, English like language that could be understood and mastered by the average human. Originally it was way behind its counterpart in terms of power, but with time it has been catching up.

With introduction of the CLR based .NET Framework, Microsoft has instilled the freedom of language to the developers. Developers with expertise in different .NET languages can now work together in projects, thus increasing productivity.

The .NET Languages

Apart from those offered by Microsoft – VB, C# & C++ there are other languages that target the .NET Framework. COBOL, PERL, FORTRAN are just a few to name. All .NET Languages follow the Common Language Specification (CLS) to facilitate this.

How does the Interoperability work?

Programs written in .NET Languages are not compiled to machine code, rather into an Intermediate Language known as MSIL (Microsoft Intermediate Language) or just IL. So, any assembly written in the .NET languages, are the same internally. This implies that the atomic data types such as Integer, Float, etc are now the same in VB, C# & C++.

Because of being compiled to MSIL, the reverse engineering of code becomes easier for .NET assemblies. It can seriously compromise security of a program, but thankfully there are obfuscation techniques to overcome it. Microsoft Visual Studio 2005 ships with a lite edition of dotfuscator. There are various other Obfuscators available in the market too.

Basic Structure of a .NET Application

.NET applications are comprised of assemblies. An assembly is a self-descriptive collection of codes, resources and metadata. Each assembly has a manifest which provides information pertaining to the assembly viz Assembly naming & versioning, list of all types exposed by the assembly, dependency on other assemblies & code security instructions. The manifest can exist externally or internally within a module of the assembly.

Compilation & Execution

As mentioned before, the .NET applications are compiled to the MSIL. During runtime, the MSIL is compiled into native binary code by the Just In Time (JIT) compiler. When the execution begins, the starting assembly is loaded and its manifest is validated. After all the security requirements are met, the assembly is executed. An important feature of the JIT compiler is that only the execution path of the assembly is compiled, thus maximizing performance.

General