Tuesday 2 September 2008

A simple intorduction to using the MFC collections

CArray, CList and CMap, Free Source Code Download

John McTainsh
Introduction.

This turorial will demonstrate the the MFC collection classes CList, CArray and CMap. These classes are an excillent way to manage dynamic data in a type safe manner. They are very easy to use and mostly encourage solid code.

Quick Start.
Collection Data Types.
Using CArray.
Using CList.
Using CMap.
Using pointers to objects.
A Quick Start.

Lets just use a simple List collection to start with. This example demonstartes a que of shoe sizes held as doubles. Items are added to the Tail of the que and removed from the Head for processing.

#include // MFC suport for Collections
...
//Declare the que object
CList m_lstShoeSize;

//Add items to the que
m_lstShoeSize.AddTail( 10.5 );
m_lstShoeSize.AddTail( 8.0 );
m_lstShoeSize.AddTail( 9.5 );
m_lstShoeSize.AddTail( 9.0 );

//Process (show) the items in the list.
for( POSITION pos = m_lstShoeSize.GetHeadPosition(); pos != NULL; )
{
_tprintf( _T("Shoe size is %4.1lf\n"), m_lstShoeSize.GetNext( pos ) );
}

//Process (remove) the items from the que
while( !m_lstShoeSize.IsEmpty() )
{
double dRemovedShoe = m_lstShoeSize.RemoveHead();
_tprintf( _T("Removing Shoe Size(%4.1lf)\n"), dRemovedShoe );
}

Collection data types.

Jump ahead to using CArray if you just want to skip the theory. In the previous example you would note the use of a template . The two parameters are used to define how data is stored and retrieved from the collection.
TYPE.

This is the type of data that is used to hold the elements internally and RETURNED from the collection. Get returns this data type.
ARG_TYPE.

This type is use to specify the type of data used to write (STORE) data to the collection. Set uses this data type. Often this type is a reference to the TYPE value. Some examples follow;

CList< PERSON*, PERSON* > m_lstPeople; //1 List of pointers to struct
CList< CString, CString > m_lstNames; //2 List of CStrings
CList< CString, CString&> m_lstNames; //3 .. same using references
CList< CString, LPCSTR > m_lstNames; //4 .. using constant pointers

Note 1: With regard sample 1, the list contains pointer not objects, so the objects must be created with new and deleted when no longer required.

Note 2: With regard sample 3, the ARG_TYPE parameter is used to indicate how the value will be passed into the collection, ie in the Add() method. It does NOT indicate a collection of referances.
Using CArray.

CArray is a collection that is best used for data that is to be accessed in a random or non sequensial manner. The array can dynamically shrink and grow as necessary. Array indexes always start at position 0. You can decide whether to fix the upper bound or allow the array to expand when you add elements past the current bound. Memory is allocated contiguously to the upper bound, even if some elements are null.

The following example adds two CTime objects to the array and then displays the contents of the entire array. The key functions are SetAtGrow which adds an item and increases the array size and the [] operator which is used to retrieve data from the array.

#include // MFC suport for Collections
...
CArray m_aryTime;

m_aryTime.SetAtGrow( 3, CTime::GetCurrentTime() );
m_aryTime.SetAtGrow( 5, CTime( 1999, 6, 12 ) );

for( int nCnt = 0; nCnt < m_aryTime.GetSize(); nCnt++ )
{
if( m_aryTime[nCnt].GetTime() != 0 )
{
_tprintf( _T("Time is %s\n"),
m_aryTime[nCnt].Format( _T("%d/%b/%y %H:%M") ) );
}
else
{
_tprintf( _T("Invalid Time\n") );
}
}

Using CList.

Lists are simular to arrays but are optimised for data that is read in a more sequensial manner such as ques and lists. See the example in Quick Start. earlier for a simple list example. Note items are added at the head or tail of the list. Retrival is from the head or tail of the list and via an iterative process.

#include // MFC suport for Collections
...
//Declare the que object
CList m_lstDepth;

//Add items to the que
m_lstDepth.AddTail( 100 );
m_lstDepth.AddTail( 85 );
m_lstDepth.AddTail( 95 );
m_lstDepth.AddTail( 90 );

//Process (show) the items in the list.
for( POSITION pos = m_lstDepth.GetHeadPosition(); pos != NULL; )
{
_tprintf( _T("Dive depth is %4d\n"), m_lstDepth.GetNext( pos ) );
}

Using CMap.

The CMap object is an simple collection, but unlike arrays and lists, which index and order the data they store, maps associate keys and values. To access a value stored in a map, specifying the value¢Î associated key. This is simular to a hash table.

#include // MFC suport for Collections
...
CMap m_mapAddress;

m_mapAddress[_T( "10.1.1.102" )] = _T("BILL");
m_mapAddress[_T( "10.1.1.108" )] = _T("MAILSERVER");
m_mapAddress[_T( "10.1.1.112" )] = _T("DevLaptop01");
m_mapAddress[_T( "10.1.1.10" )] = _T("PALEALE");
m_mapAddress[_T( "10.1.3.1" )] = _T("PTRAK");

CString sMachine;
CString sUnknownIP = _T( "?0.?.?.112" );
sUnknownIP.Replace( _T("?"), _T("1") );
m_mapAddress.Lookup( sUnknownIP, sMachine );

_tprintf( _T("Machine at IP %s is %s\n"), sUnknownIP, sMachine );

Using pointers to objects.

In all the previous examples the items in the list all supported the assigment = operator. This makes it possible to add and retrieve data from the collection. Items that do not support the assignment operator can still be saved to a collection but must be created and destroyed manualy. The objects must be dynamically allocated using the new operator, ie the "free store" or "heap" this ensures they are not deleted once they go out of scope. Therefore when removed from the list they must be manually deleted. A destructor is often good place to perform this task. The following example shows a list of PERSON structures that are created, displayed and deleted.

NOTE: Unlike other collections, pointers return the actual object rather than a copy, so changes made to the returned object are perminent.

#include // MFC suport for Collections
...
//Person structure
#define LEN_CLOTH_SIZE (5) //Max cloth size length
typedef struct _PERSON
{
int nHeight; //in cm
CString sFullName; //Name
COleDateTime tmBirthDate; //Birthday
TCHAR szShirt[LEN_CLOTH_SIZE]; //Shirt size
} PERSON, *LPPERSON;
...

CList< LPPERSON, LPPERSON > m_lstPeople;

//Bilbos details
LPPERSON lpPerson = new PERSON;
lpPerson->nHeight = 95;
lpPerson->sFullName = _T("Bilbo Baggins");
_tcscpy( lpPerson->szShirt, _T("XOS") );
lpPerson->tmBirthDate = COleDateTime( 1965, 6, 22, 3, 0, 0 );
m_lstPeople.AddTail( lpPerson );

//Fredo details
lpPerson = new PERSON;
lpPerson->nHeight = 49;
lpPerson->sFullName = _T("Fredo Frog");
_tcscpy( lpPerson->szShirt, _T("OS") );
lpPerson->tmBirthDate = COleDateTime( 1965, 1, 5, 18, 0, 0 );
m_lstPeople.AddTail( lpPerson );

//Display the People in the que
POSITION posPerson = m_lstPeople.GetHeadPosition();
while( posPerson != NULL )
{
LPPERSON lpDisplayPerson = m_lstPeople.GetNext( posPerson );
_tprintf( _T("Name .........%s\n"), lpDisplayPerson->sFullName );
_tprintf( _T("Height %d\n"), lpDisplayPerson->nHeight );
_tprintf( _T("Shirt size %s\n"), lpDisplayPerson->szShirt );
_tprintf( _T("Birthday %s\n\n"), lpDisplayPerson->tmBirthDate.
Format( _T("%d/%b/%y %H:%M") ) );
}

//Free out the list
while( !m_lstPeople.IsEmpty() )
{
LPPERSON lpLostPerson = m_lstPeople.RemoveHead();
delete lpLostPerson;
}

Tuesday 24 June 2008

CMake, cross-platform make

Welcome to CMake, the cross-platform, open-source build system. CMake is a family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. CMake is quite sophisticated: it is possible to support complex environments requiring system introspection, pre-processor generation, code generation and template instantiation. In addition to controling the build process, CMake includes CTest for testing and CPack for packaging. Please go here to learn more about CMake.
CMake was developed by Kitware as part of the NLM Insight Segmentation and Registration Toolkit project. The ASCI VIEWS project also provided support in the context of their parallel computation environment.

http://www.cmake.org/HTML/index.html

Sunday 15 June 2008

15 Tools to Help You Develop Faster Web Pages

Response times, availability, and stability are vital factors to bear in mind when creating and maintaining a web application. If you’re concerned about your web pages’ speed or want to make sure you’re in tip-top shape before starting or launching a project, here’s a few useful, free tools to help you create and sustain high-performance web applications.

I’ve tried to include a wide variety of tools that are easy to use, and have tried to keep them as OS and technology-independent as possible so that everyone can find a tool or two.
http://sixrevisions.com/tools/faster_web_page/

Friday 13 June 2008

Debugging Windows Error Reporting

If you’re a software developer, chances are that you have written an application, and this application has crashed. When this happened, it probably put up a dialog that looks something like this:



How do you figure out what went wrong?

Strategy #1: Extract the minidump from Windows Error Reporting
Windows Error reporting has already created a minidump of the crash. So one way to find out what went wrong is just to look at the minidump. This works really well if your application is written in native code and there is no debugger on the machine where the crash occurs. You can use it for managed code too, but you will need to use sos.dll to analyze the dump (see MSDN). Open a command prompt (Start->Run, cmd.exe), and switch to your temp directory:

C:\Documents and Settings\greggm>cd /d %tmp%


Look for the dump file that Windows Error Reporting produced. It will have a '.dmp' or '.mdmp' extension and the date should be shortly after the crash happened:


C:\DOCUME~1\greggm\LOCALS~1\Temp>dir *.*dmp
Volume in drive C has no label.
Volume Serial Number is 70E3-6676

Directory of C:\DOCUME~1\greggm\LOCALS~1\Temp

05/24/2007 08:54 AM 109,570 4A88835.dmp
1 File(s) 109,570 bytes
0 Dir(s) 25,379,823,616 bytes free

Mark the file as read-only. This will prevent Windows Error Reporting from deleting the file after you dismiss the dialog:

C:\DOCUME~1\greggm\LOCALS~1\Temp>attrib +r 4A88835.dmp

Now dismiss windows error reporting and copy the dump file wherever you want. You can analyze the dump in Visual Studio by opening the dump file as a project (File->Open Project), and start debugging (F5).



Strategy #2: Access the dump from Online Crash Analysis
Microsoft has a program to allow ISVs to access the crashes in their applications that have been submitted by users. If the person experiencing the crash is a customer, this is a great way to find out what happened. See the winqual site for more information.



Strategy #3: Debug the crash through Just-In-Time Debugging
Probably everyone already knows about this, so I won’t spend much time discussing it. However, as long as the application is crashing on a computer that has a debugger installed, this is the easiest option. The only thing tricky that I will mention is that in Windows Vista, depending on your computers Windows Error Reporting settings, you might actually need to click the 'Send information' button before Windows Vista will present you with a second dialog that allows you to debug.

Tuesday 10 June 2008

Watir - Automated testing that doesn’t hurt

Watir is a simple open-source library for automating web browsers. It allows you to write tests that are easy to read and easy to maintain. It is optimized for simplicity and flexibility.

Watir drives browsers the same way people do. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text appears on the page.

Watir is a Ruby library that works with Internet Explorer on Windows. Watir is currently being ported to support Firefox and Safari.

Like other programming languages, Ruby gives you the power to connect to databases, read data files, export XML and structure your code into reusable libraries. Unlike other programing languages, Ruby is concise and often a joy to read.

Watir stands for “Web Application Testing in Ruby”. It is pronounced water.

http://wtr.rubyforge.org/

Tuesday 3 June 2008

The 100 top Web apps for 2008

These are the 100 best Web 2.0 applications, chosen by Webware readers and Internet users across the globe. Over 1.9 million votes were cast to select these Webware 100 winners: http://www.webware.com/html/ww/100/2008/winners.html

Tuesday 27 May 2008

Speed Up Your Website - By Example

Introduction
"We live only to discover beauty, all else is a form of waiting. Khalil Gibran", if you agree with this saying, then you are well aware of what it mean to minimize wait for your web audiences.Building an HTML page, adding images, CSS and JS has become piece of cake over last few years, but delivering these rich-contents with a Performance to client browser is still a daunting task. This narrow down check list will help you to review your web site to minimize download time.
Note: This article describes only Front-End engineering issues, No Programming/CGI scripting/Data Structure/Database/Multimedia optimization techniques are discussed in this article.

http://www.codeproject.com/KB/HTML/SpeedUpWebsite.aspx

Tuesday 20 May 2008

Best Programming Jokes

How can you tell when a programmer has had sex?When he's washing the pepper spray out of his eyes.
~~~~~~~~~~~~~~~~~~~~~~~~~
Two bytes meet. The first byte asks, "Are you ill?" The second byte replies, "No, just feeling a bit off."
~~~~~~~~~~~~~~~~~~~~~~~~~
Eight bytes walk into a bar. The bartender asks, "Can I get you anything?"
"Yeah," reply the bytes. "Make us a double."
~~~~~~~~~~~~~~~~~~~~~~~~~
Q. How did the programmer die in the shower?A. He read the shampoo bottle instructions: Lather. Rinse. Repeat.
~~~~~~~~~~~~~~~~~~~~~~~~~
How many programers dose it take to change a light bulb?None - It's a hardare problem
~~~~~~~~~~~~~~~~~~~~~~~~~
Why do programmers always mix up Halloween and Christmas? Because Oct 31 equals Dec 25.
~~~~~~~~~~~~~~~~~~~~~~~~~
There are only 10 kinds of people in this world: those who know binary and those who don't.
~~~~~~~~~~~~~~~~~~~~~~~~~
A programmer walks to the butcher shop and buys a kilo of meat. An hour later he comes back upset that the butcher shortchanged him by 24 grams.
~~~~~~~~~~~~~~~~~~~~~~~~~
"Knock, knock.""Who's there?"very long pause…."Java."
~~~~~~~~~~~~~~~~~~~~~~~~~
Programming is 10% science, 20% ingenuity, and 70% getting the ingenuity to work with the science.
~~~~~~~~~~~~~~~~~~~~~~~~~
Programming is like sex:One mistake and you have to support it for the rest of your life.
~~~~~~~~~~~~~~~~~~~~~~~~~
A man is smoking a cigarette and blowing smoke rings into the air. His girlfriend becomes irritated with the smoke and says, "Can't you see the warning on the cigarette pack? Smoking is hazardous to your health!"
To which the man replies, "I am a programmer. We don't worry about warnings; we only worry about errors."
~~~~~~~~~~~~~~~~~~~~~~~~~
There are three kinds of lies: Lies, damned lies, and benchmarks.
~~~~~~~~~~~~~~~~~~~~~~~~~
A programmer is walking along a beach and finds a lamp. He rubs the lamp, and a genie appears. "I am the most powerful genie in the world. I can grant you any wish, but only one wish."
The programmer pulls out a map, points to it and says, "I'd want peace in the Middle East."
The genie responds, "Gee, I don't know. Those people have been fighting for millenia. I can do just about anything, but this is likely beyond my limits."
The programmer then says, "Well, I am a programmer, and my programs have lots of users. Please make all my users satisfied with my software and let them ask for sensible changes."
At which point the genie responds, "Um, let me see that map again."
~~~~~~~~~~~~~~~~~~~~~~~~~
All programmers are playwrights, and all computers are lousy actors.
~~~~~~~~~~~~~~~~~~~~~~~~~
Have you heard about the new Cray super computer? It's so fast, it executes an infinite loop in 6 seconds.
~~~~~~~~~~~~~~~~~~~~~~~~~
The generation of random numbers is too important to be left to chance.
~~~~~~~~~~~~~~~~~~~~~~~~~
"I just saw my life flash before my eyes and all I could see was a close tag…"
~~~~~~~~~~~~~~~~~~~~~~~~~
The computer is mightier than the pen, the sword, and usually, the programmer.
~~~~~~~~~~~~~~~~~~~~~~~~~
Debugging: Removing the needles from the haystack.
~~~~~~~~~~~~~~~~~~~~~~~~~
Two strings walk into a bar and sit down. The bartender says, "So what'll it be?"
The first string says, "I think I'll have a beer quag fulk boorg jdk^CjfdLk jk3s d#f67howe%^U r89nvy~~owmc63^Dz x.xvcu"
"Please excuse my friend," the second string says, "He isn't null-terminated."
~~~~~~~~~~~~~~~~~~~~~~~~~
From the Random Shack Data Processing Dictionary:
Endless Loop: n., see Loop, Endless.Loop, Endless: n., see Endless Loop.
~~~~~~~~~~~~~~~~~~~~~~~~~
The three most dangerous things in the world are a programmer with a soldering iron, a hardware engineer with a software patch, and a user with an idea. - The Wizardry Compiled by Rick Cook
~~~~~~~~~~~~~~~~~~~~~~~~~
One hundred little bugs in the codeOne hundred little bugs.Fix a bug, link the fix in,One hundred little bugs in the code.
~~~~~~~~~~~~~~~~~~~~~~~~~
A computer science student is studying under a tree and another pulls up on a flashy new bike. The first student asks, "Where'd you get that?"
The student on the bike replies, "While I was studying outside, a beautiful girl pulled up on her bike. She took off all her clothes and said, 'You can have anything you want'."
The first student responds, "Good choice! Her clothes probably wouldn't have fit you."
~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~
CIA - Computer Industry Acronyms
CD-ROM: Consumer Device, Rendered Obsolete in MonthsPCMCIA: People Can't Memorize Computer Industry AcronymsISDN: It Still Does NothingSCSI: System Can't See ItMIPS: Meaningless Indication of Processor SpeedDOS: Defunct Operating SystemWINDOWS: Will Install Needless Data On Whole SystemOS/2: Obsolete Soon, TooPnP: Plug and PrayAPPLE: Arrogance Produces Profit-Losing EntityIBM: I Blame MicrosoftMICROSOFT: Most Intelligent Customers Realize Our Software Only Fools TeenagersCOBOL: Completely Obsolete Business Oriented LanguageLISP: Lots of Insipid and Stupid ParenthesesMACINTOSH: Most Applications Crash; If Not, The Operating System HangsAAAAA: American Association Against Acronym Abuse.WYSIWYMGIYRRLAAGW: What You See Is What You Might Get If You're Really Really Lucky And All Goes Well.
~~~~~~~~~~~~~~~~~~~~~~~~~
Funny Error Messages
~~~~~~~~~~~~~~~~~~~~~~~~~
God as a Programmer
~~~~~~~~~~~~~~~~~~~~~~~~~
Computer Stupidities
~~~~~~~~~~~~~~~~~~~~~~~~~
Comedy Code is syntactically correct programming code written just for fun. The code doesn't actually have to do anything if it's executed, but it should look like regular code.
~~~~~~~~~~~~~~~~~~~~~~~~~
Why computers are like men:
In order to get their attention, you have to turn them on.
They have a lot of data, but are still clueless.
They are supposed to help you solve problems, but half the time they are the problem.
As soon as you commit to one, you realize that if you had waited a little longer, you could have had a better model.
Why computers are like women:
No one but the Creator understands their internal logic.
The native language they use to communicate with other computers is incomprehensible to everyone else.
Even your smallest mistakes are stored in long-term memory for later retrieval.
As soon as you make a commitment to one, you find yourself spending half your paycheck on accessories for it.
~~~~~~~~~~~~~~~~~~~~~~~~~
Laws of Computer Programming
Any given program, when running, is obsolete.
Any given program costs more and takes longer.
If a program is useful, it will have to be changed.
If a program is useless, it will have to be documented.
Any program will expand to fill available memory.
The value of a program is proportional to the weight of its output.
Program complexity grows until it exceeds the capabilities of the programmer who must maintain it.
Any non-trivial program contains at least one bug.
Undetectable errors are infinite in variety, in contrast to detectable errors, which by definition are limited.
Adding manpower to a late software project makes it later.
~~~~~~~~~~~~~~~~~~~~~~~~~
Lubarsky's Law of Cybernetic Entomology: There's always one more bug.
Shaw's Principle: Build a system that even a fool can use, and only a fool will want to use it.
Woltman's Law: Never program and drink beer at the same time.
Gallois' Revelation: If you put tomfoolery into a computer, nothing comes out but tomfoolery. But this tomfoolery, having passed through a very expensive machine, is somehow enobled, and no one dares to criticize it.
~~~~~~~~~~~~~~~~~~~~~~~~~
A programmer finds himself in front of a committee that decides whether he should go to Heaven or Hell. The committee tells the programmer he has a say in the matter and asks him if he wants to see either Heaven or Hell before stating his preference.
"Sure," the programmer replies. "I have a pretty good idea what Heaven is like, so let's see Hell." So an angel takes the programmer to a sunny beach, full of beautiful women in skimpy bikinis playing volleyball, listening to music and having a great time. "Wow!" he exclaims, "Hell looks great! I'll take Hell!"
Instantly the programmer finds himself in red-hot lava with demons tearing at his flesh. "Where's the beach? The music? The women?" he screams frantically to the angel.
"That was the demo," the angel replies as she vanishes.
~~~~~~~~~~~~~~~~~~~~~~~~~
Jesus and Satan have an argument as to who is the better programmer. This goes on for a few hours until they come to an agreement to hold a contest with God as the judge. They set themselves before their computers and begin. They type furiously, lines of code streaming up the screen, for several hours straight.
Seconds before the end of the competition, a bolt of lightning strikes, taking out the electricity. Moments later, the power is restored, and God announces that the contest is over. He asks Satan to show his work. Visibly upset, Satan cries and says, "I have nothing. I lost it all when the power went out."
"Very well," says God, "let us see if Jesus has fared any better."
Jesus presses a key, and the screen comes to life in vivid display, the voices of an angelic choir pour forth from the speakers.
Satan is astonished. He stutters, "B-b-but how?! I lost everything, yet Jesus’ program is intact! How did he do it?"
God chuckles, "Everybody knows… Jesus saves."
~~~~~~~~~~~~~~~~~~~~~~~~~
Redneck Computer Terms
LOG ON: Makin' a woodstove hot.LOG OFF: Don't add no more wood.MONITOR: Keepin' an eye on the wood stove.DOWNLOAD: Gittin' the farwood off the truck.MEGA HERTZ: When you're not keerfull gittin' the farwood.FLOPPY DISC: Whutcha git from trying to tote too much farwood.RAM: That thar thing whut splits the farwood.HARD DRIVE: Gittin' home in the winter time.WINDOWS: Whut to shut when it's cold outside.SCREEN: Whut to shut when it's black fly season.BYTE: Whut them dang flys do.CHIP: Munchies fer the TV.MICRO CHIP: Whut's in the bottom of the munchie bag.MODEM: Whutcha do to the hay fields.DOT MATRIX: Old Dan Matrix's wife.LAP TOP: Whar the kitty sleeps.KEYBOARD: Whar you hang the dang truck keys.SOFTWARE: Them dang plastic forks and knifes.MOUSE: Whut eats the grain in the barn.MOUSE PAD: That's hippie talk fer the mouse hole.MAINFRAME: Holds up the barn roof.PORT: Fancy Flatlander wine.ENTER: Northerner talk fer, "C'mon in, y'all."CLICK: Whut you hear when you cock your gun.DOUBLE CLICK: When the dang gun don't far when you pull the trigger.REBOOT: Whut you have to do at bedtime when you forgot the kitty's still outside.
~~~~~~~~~~~~~~~~~~~~~~~~~
Software Development Cycles
Programmer produces code he believes is bug-free.
Product is tested. 20 bugs are found.
Programmer fixes 10 of the bugs and explains to the testing department that the other 10 aren't really bugs.
Testing department finds that five of the fixes didn't work and discovers 15 new bugs.
Repeat three times steps 3 and 4.
Due to marketing pressure and an extremely premature product announcement based on overly-optimistic programming schedule, the product is released.
Users find 137 new bugs.
Original programmer, having cashed his royalty check, is nowhere to be found.
Newly-assembled programming team fixes almost all of the 137 bugs, but introduce 456 new ones.
Original programmer sends underpaid testing department a postcard from Fiji. Entire testing department quits.
Company is bought in a hostile takeover by competitor using profits from their latest release, which had 783 bugs.
New CEO is brought in by board of directors. He hires a programmer to redo program from scratch.
Programmer produces code he believes is bug-free…
~~~~~~~~~~~~~~~~~~~~~~~~~
Top 10 phrases spoken by a Klingon Programmer
A TRUE Klingon Warrior does not comment his code!
By filing this bug report you have challenged the honor of my family. Prepare to die!
You question the worthiness of my code? I should kill you where you stand!
Our competitors are without honor!
Specifications are for the weak and timid!
This machine is GAGH! I need dual Pentium processors if I am to do battle with this code!
Perhaps it IS a good day to die! I say we ship it!
Our users will know fear and cower before our software! Ship it! Ship it and let them flee like the dogs they are!
My program has just dumped Stova Core!
Behold, the keyboard of Kalis! The greatest Klingon code warrior that ever lived!
~~~~~~~~~~~~~~~~~~~~~~~~~
The programmer compiled an array of reasons as to why he can't find a girlfriend with a good \ on her \, reason 0 being that he has limited cache. So he searches his memory to recall connecting to the TCP/IP tunnel of his last girlfriend — sometimes even without a secure socket. His last girlfriend always complained about his lack of comments. He fumed, "I hate commenting!" Realizing it was a program requirement, he told her she had nice bits. This resulted in a Syntax Error. Now she demanded a massage, but this was rejected as "Feature Creep." He smacked her back-end and shouted, "Who's your parent node?!" He scanned for open ports. He attempted to install a backdoor worm but her response was 403. While his data uploaded into her input device, she considered terminating the process. But instead she initiated a Do While loop where she recalled a previous boyfriend with a larger pointer. To expedite the routine routine, she screamed, "Hack into my system! Hack deep into my system! You're 1337, baby!" This caused his stack to overflow, and he shot his GUI on her interface. (Source)
~~~~~~~~~~~~~~~~~~~~~~~~~
What's the difference between drug dealers and computer programmers?
Drug Dealers
Computer Programmers
Refer to their clients as "users".
Refer to their clients as "users".
"The first one's free!"
"Download a free trial version…"
Have important South-East Asian connections (to help move the stuff).
Have important South-East Asian connections (to help debug the code).
Strange jargon: "Stick," "Rock," "Dime bag," "E".
Strange jargon: "SCSI," "RTFM," "Java," "ISDN".
Realize that there's tons of cash in the 14- to 25-year-old market.
Realize that there's tons of cash in the 14- to 25-year-old market.
Job is assisted by the industry's producing newer, more potent mixes.
Job is assisted by industry's producing newer, faster machines.
Often seen in the company of pimps and hustlers.
Often seen in the company of marketing people and venture capitalists.
Their product causes unhealthy addictions.
DOOM. Quake. SimCity. Duke Nukem 3D. 'Nuff said.
Do your job well, and you can sleep with sexy movie stars who depend on you.
Damn! Damn! DAMN!!!
Popularity: 87% [?]

http://www.devtopics.com/best-programming-jokes/

C++ Coding Practices Guide

Introduction
To write consistent code comprehended by other developers, you are supposed to follow some coding styles and practices, rather than inventing your own ones. These include naming conventions (on how you name your variables and functions), code and class layout (including tabs, whitespace, brackets placement), imperative const correctness etc... To follow this article, you are supposed to know the basics of OOP and C++. There are some great online resources you may use in addition to this article:
C++ FAQ lite
Artistic style code formatter
Coding standards
C and C++ style guides

http://www.codeproject.com/KB/cpp/cppstyle.aspx

Artistic Style - A Free, Fast and Small Automatic Formatter

Artistic Style is a source code indenter, formatter, and beautifier for the C, C++, C# and Java programming languages.

When indenting source code, we as programmers have a tendency to use both spaces and tab characters to create the wanted indentation. Moreover, some editors by default insert spaces instead of tabs when pressing the tab key, and other editors (Emacs for example) have the ability to "pretty up" lines by automatically setting up the white space before the code on the line, possibly inserting spaces in a code that up to now used only tabs for indentation.

Since the NUMBER of space characters showed on screen for each tab character in the source code changes between editors (unless the user sets up the number to his liking...), one of the standard problems programmers are facing when moving from one editor to another is that code containing both spaces and tabs that was up to now perfectly indented, suddenly becomes a mess to look at when changing to another editor. Even if you as a programmer take care to ONLY use spaces or tabs, looking at other people's source code can still be problematic.

To address this problem, Artistic Style was created - a filter written in C++ that automatically re-indents and re-formats C / C++ / C# / Java source files. It can be used from a command line, or it can be incorporated as classes in another C++ program.
http://astyle.sourceforge.net/

Friday 11 April 2008

Microsoft Excel: Revolutionary 3D Game Engine?

Introduction

Cutting-edge computer games use different graphics subsystems -- so-called 3D graphics engines. Source (used in Half Life 2), Unreal Engine (Unreal Tournament), idTech 4 (Doom 3), CryENGINE2 (Crysis) or Clever's Paradox engine are well-known among the players and the game industry experts.

It's time to learn a new 3D game engine name: Microsoft Excel.

It is understood that Excel is an all-round office tool, but probably it is unknown that it has a bunch of features that makes Excel a high-class 3D graphics engine.

In this article I will demonstrate Excel's arithmetical facilities, the embedded rendering subsystems (there are two of them!) and the revolutionary approach which might just cause a paradigm shift. I hope you will discover that Excel effectively and efficiently incorporates practicality, tons of features, the multi-platform portability and the high performance with the unique and futuristic 3D engine features.

The chapters even have demo programs and movies created with the Excel 3D engine.



http://www.gamasutra.com/view/feature/3563/microsoft_excel_revolutionary_3d_.php

Monday 24 March 2008

The Art of Project Management: How to Make Things Happen

One myth of project management is that certain people have an innate ability to do it well, and others do not. Whenever this myth came up in conversation with other project managers, I always asked for an explanation of that ability—how to recognize it, categorize it, and, if possible, develop it in others. After discussion and debate, the only thing we usually identified—after considering many of the other topics and skills covered elsewhere in this book—is the ability to make things happen. Some people are able to apply their skills and talents in whatever combination necessary to move projects forward, and others cannot, even if they have the same or superior individual skills. The ability to make things happen is a combination of knowing how to be a catalyst or driver in a variety of different situations, and having the courage to do so.

This ability to drive is so important to some that it's used as a litmus test in hiring project managers. Even if PMs can't precisely define what the ability is without making at least some references to other skills, they do feel that they can sense or measure it in others. For example, an interviewer needs to ask herself the following question about the candidate: "If things were not going well on some important part of the project, would I feel confident sending this person into that room, into that discussion or debate, and believe he'd help find a way to make it better, whatever the problem was?" If after a round of interviews the answer is no, the candidate is sent home. The belief is that if he isn't agile or flexible enough to adapt his skills and knowledge to the situations at hand, and find ways to drive things forward, then he won't survive, much less thrive, on a typical project. This chapter is about that ability and the skills and tactics involved.

http://msdn2.microsoft.com/en-us/library/aa480154.aspx
http://download.csdn.net/source/327929

Monday 10 March 2008

How They Hack Your Website: Overview of Common Techniques

We hear the same terms bandied about whenever a popular site gets hacked. You know… SQL Injection, cross site scripting, that kind of thing. But what do these things mean? Is hacking really as inaccessible as many of us imagine; a nefarious, impossibly technical twilight world forever beyond our ken?
Not really.
When you consider that you can go to Google right now and enter a search string which will return you thousands of usernames and passwords to websites, you realize that this dark science is really no mystery at all. You’ll react similarly when you see just how simple a concept SQL Injection is, and how it can be automated with simple tools. Read on, to learn the basics of how sites and web content management systems are most often hacked, and what you can do to reduce the risk of it happening to you.
http://www.cmswire.com/cms/web-cms/how-they-hack-your-website-overview-of-common-techniques-002339.php

Thursday 6 March 2008

Google Heathcare Strategy

Google's Healthcare Strategy. A looking glass for the near future.
http://www.longwoods.com/product.php?productid=18871&page=27

Wednesday 5 March 2008

Frequently Asked Questions in SQL Server 2005 - Programmer Perspective

Introduction
[ Back To Top ]
According to Wikipedia, "Microsoft SQL Server is a relational database management system (RDBMS) produced by Microsoft. Its primary query language is Transact-SQL, an implementation of the ANSI/ISO standard Structured Query Language (SQL) used by both Microsoft and Sybase." However, SQL server 2005 is much more than a RDBMS. It has a rich business intelligence features like Analysis services, Integration services, Data mining services, reporting services, Integration with Microsoft office and much more. Probably the biggest advantage of choosing SQL server 2005 is the integration of .NET Framework.
In this article we will discuss all the questions that a .NET programmer can encounter in an interview. These questions should help .NET programmers who are using SQL Server 2005.
Frequently Asked Questions
[ Back To Top ]
1. What does integration of .NET Framework mean for SQL Server 2005?
This feature enables us to execute C# or VB.NET code in the DBMS to take advantage of the .NET functionality. This feature gives more flexibility in writing complex stored procedures, functions, and triggers that can be written in .net compatible language.
2. What is SSIS?
According to Microsoft SQL Server Integration Services, "(SSIS) is an effective set of tools for both the traditional demands of ETL operations, as well as for the evolving needs of general purpose data integration." In short, it is the next version of DTS (Data Transformation Services). ETL stands for Extract, Transform and Loading. In short it is a data migration tool that is flexible, fast, and has scalable architecture that enables effective data integration in current business environments.
3. What is MARS?
In previous versions of SQL Server, applications had to process or cancel all result sets from one batch before it could execute any other batch on that connection. SQL Server 2005 introduces a new connection attribute that allows applications to have more than one pending request per connection, and in particular, to have more than one active default result set per connection. Multiple Active Result Sets (MARS) is the ability to have more than one pending request under a given SQL Server connection. MARS is a programming model enhancement that allows multiple requests to interleave in the server. We need to note that it is not a parallel execution in the server. However, it may benefit us with some performance benefits if used correctly. By default, this feature is not set in SQL Server 2005.
4. What are the Security Enhancements in SQL Server 2005?
SQL Server 2005 enables administrators to manage permissions at a granular level.
· In the new SQL Server 2005, we can specify a context under which statements in a module can execute.
· SQL Server 2005 clustering supports Kerberos authentication against a SQL Server 2005 virtual server.
· Administrators can specify Microsoft Windows-style policies on standard logins so that a consistent policy is applied across all accounts in the domain.
· SQL Server 2005 supports encryption capabilities within the database itself, fully integrated with a key management infrastructure. By default, client-server communications are encrypted.
5. What is new with the Reporting services in SQL server 2005?
SQL Server 2005 Reporting Services is a key component of SQL Server 2005 that provides customers with an enterprise-capable reporting platform. This comprehensive environment is used for authoring, managing, and delivering reports to the entire organization. SQL Server 2005 reporting services have some major changes when compared with the previous version.
· Changes to the core functionality of the Reporting services in the design of the report, processing, and interactivity
· Better Integration with other components – Enhanced integration with other components within SQL Server 2005 like SSIS, SSAS and SQL Server Management studio
· Report Builder – A new reporting tool that enables business users to create their own reports
6. What is OLAP?
Online Analytical Processing (OLAP) allows us to access aggregated and organized data from business data sources, such as data warehouses, in a multidimensional structure called a cube. The arrangement of data into cubes avoids a limitation of relational databases which are not well suited for near instantaneous analysis of large amounts of data. OLAP cubes can be thought of as extensions to the two-dimensional array of a spreadsheet.
7. What is Data Mining?
According to MSDN Data, mining is "the process of extracting valid, authentic, and actionable information from large databases." Microsoft data mining tools are different from traditional data mining applications in significant ways. Data Mining is a platform for developing intelligent applications, not a stand-alone application. You can build custom applications that are intelligent because the data mining models are easily accessible to the outside world. Further, the model is extensible so that third parties can add custom algorithms to support particular mining needs.
8. What is new with the Analysis Services (SSAS) in SQL Server 2005?
SQL Server 2005 Analysis Services (SSAS) delivers online analytical processing (OLAP) and data mining functionality through a combination of server and client technologies, further reinforced through the use of a specialized development and management environment coupled with a well-defined object model for designing, creating, deploying, and maintaining business intelligence applications. The server component of Analysis Services is implemented as a Microsoft Windows service. Clients communicate with Analysis Services using the public standard XML for Analysis (XMLA), a SOAP-based protocol. Let us see the enhancements of made to SSAS.
· Supports up to 16 instances of Analysis Services Service.
· As discussed above, the Analysis Services service fully implements the XML for Analysis (XMLA) 1.1 specification. All communication with an instance of Analysis Services is handled through XMLA commands in SOAP messages.
· Uses the Proactive caching.
9. What is Information Schema in SQL Sever 2005?
Information Schema is the part of the SQL- 92 standard which exposes the metadata of the database. In SQL server, a set of views are created in each of the databases which exposes the metadata of the database. The information schema is kept in a separate schema - information schema - which exists in all databases, but which is not included in the search path by default. For more information regarding Information schema please read this article.
10. What is Full Text Search? How does it get implemented in SQL server 2005?
Full-text search allows fast and flexible indexing for keyword-based query of text data stored in a Microsoft SQL Server database. In contrast to the LIKE predicate which only works on character patterns, full-text queries perform linguistic searches against this data, by operating on words and phrases based on rules of a particular language.
11. What is integration of Microsoft Office System mean?
The integration with Microsoft Office system means the following.
· Table Analysis Tools for Excel: Provides an easy-to-use add-in that leverages SQL Server 2005 Data Mining behind the scenes to perform powerful end user analysis on spreadsheet data.
· Data Mining Client for Excel: Offers a full data mining model development lifecycle directly within Excel 2007.
· Data Mining Templates for Visio: Enables powerful rendering and sharing of mining models as annotatable Visio 2007 drawings.
12. What is the support of Web Services in SQL Server 2005?
With this feature the database engine can be directly exposed as a web service without a middle tier or even an IIS. This will enable the user to directly call a stored procedure by calling a web method. This feature is designed with well-known standards such as SOAP 1.2, WSDL 1.1, and HTTP. With this new feature we can now connect to SQL Server not only with TDS- Tabular data stream (a binary protocol for connecting to SQL Server 2005) but also over SOAP/ HTTP.
13. What is OLTP?
Online Transaction Processing (OLTP) relational databases are optimal for managing changing data. When several users are performing transactions at the same time, OLTP databases are designed to let transactional applications write only the data needed to handle a single transaction as quickly as possible.
14. What is Snapshot in SQL Server 2005?
A database snapshot is a read-only, static view of a database, the source database. Each database snapshot is transaction-consistent with the source database as it existed at the time of the snapshot's creation.
15. What is snapshot isolation in SQL Server 2005?
SQL Server 2005 introduces a new "snapshot" isolation level that is intended to enhance concurrency for online transaction processing (OLTP) applications. In prior versions of SQL Server, concurrency was based solely on locking, which can cause blocking and deadlocking problems for some applications. Snapshot isolation depends on enhancements to row versioning and is intended to improve performance by avoiding reader-writer blocking scenarios.
16. What is Database Partitioning in SQL Server 2005?
SQL Server 2005 provides a new capability for the partitioning of tables across file groups in a database. Partitioning a database improves performance and simplifies maintenance. By splitting a large table into smaller, individual tables, queries accessing only a fraction of the data can run faster because there is less data to scan.
17. What is SQL Server Agent?
SQL Server Agent is a Microsoft Windows service that executes scheduled administrative tasks called jobs. SQL Server Agent uses SQL Server to store job information. Jobs contain one or more job steps. We generally schedule the backups on the production databases using the SQL server agent. In SQL Server 2005 we have roles created for using SQL Server agents.
· SQLAgentUserRole
· SQLAgentReaderRole
· SQLAgentOperatorRole
SQL Server Agent for SQL Server 2005 provides a more robust security design than earlier versions of SQL Server. This improved design gives system administrators the flexibility they need to manage their Agent service.
18. What is Replication? What is the need to have the replication? What are the enhancements made to SQL Server 2005 related to the replication?
"Replication is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency.” In short, replication is all about having multiple copies of the same database. We need replication when we need to distribute data to and from different locations. Generally we have a master copy of data. There will be multiple slaves (Clients) located at various locations which need to be replicated. We use replication for a variety of reasons. Load balancing is sharing the data among a number of servers and distributing the query load. Offline processing is one of the main reasons. In this scenario we need to modify the data on the database that is not connected to the network. The last reason may be to have a back-up to the database in case of failure to the existing database. Let us see the enhancements of SQL server 2005 database related to replication.
· Database Mirroring – Database Mirroring is moving the transactions of database from one SQL Server database to another SQL server database on a different SQL Server.
· Replication Management topology (RMO) – RMO is a new construct in SQL Server 2005. It is a .NET Framework library that provides a set of common language runtime classes for configuring, managing, and scripting replication, and for synchronizing Subscribers.
19. What are Business Logic Handlers?
Business logic handlers are written in managed code and allow us to execute custom business logic during the merge synchronization. We can invoke the business logic handler in case of non-conflicting data changes. Business logic handler can perform one of the following three actions.
· Reject Data
· Accept Data
· Apply Custom Data
20. What are different variants of SQL Server 2005?
There are different variants of SQL Server 2005 commercially available.
· Express – Free and only for one user
· Enterprise – 5 users apart from server
· Workgroup – 10 users apart from server
· Standard – 25 users apart from server
21. What are Various Service packs available for SQL Server 2005?
As of now there are two service packs available for the SQL Server 2005.
· Service Pack 1 – Has major changes or enhancements to SQL Server 2005 in Analysis Services, Data Programmability, SSIS, and reporting services.
· Service Pack 2 – Unlike Service Pack 2, this service pack enables SQL Server 2005 customers to take advantage of the enhancements within Windows Vista and the 2007 Office system.
22. What are the New Data types introduced in SQL Server 2005?
SQL Server 2005 has added some new data types to its existing data types.
XML Data type
· VARCHAR (MAX)
· NVARCHAR (MAX)
· VARBINARY (MAX)
As we can see, the new term MAX has been introduced in SQL Server 2005. This new specifier expands the storage capabilities of the varchar, nvarchar, and varbinary data types. Varchar(max), nvarchar(max), and varbinary(max) are collectively called large-value data types.
23. Does SQL Server 2005 support SMTP?
SQL Server 2005 now supports sending E-mail from the database. It is called as database mail and it uses DatabaseMail90.exe. Gone are the days when we were using a third party component for this. Receiving an e-mail was not supported in the previous versions of SQL Server.
24. What is SQL Management Object is SQL Server 2005?
These are collection of objects that are made for programming all aspects of managing Microsoft SQL Server 2005. SMO is a .NET based object model. It comes with SQL Server 2005 as a .Net assembly named Microsoft.SqlServer.Smo.dll. We can use these objects for connecting to a database, calling methods of the database that returns a table, using transactions, transferring data, scheduling administrative tasks, etc. The best part about SMO is that most of it can also be used with SQL server 2000.
25. What is SQL Service Broker in SQL Server 2005?
SQL Service broker is a new technology introduced in SQL Server 2005 for building database-intensive distributed applications. Basically, service broker has been built for developing applications that consist of individual components which are loosely coupled. Service broker supports asynchronous yet reliable messages that are passed between the components. These messages are called conversations.
References
[ Back To Top ]
SQL Server 2005 Book online
Conclusion
[ Back To Top ]
This article targets all the database users who are new to SQL Server 2005. The questions and answers in this article will give a basic understanding towards all the concepts of SQL Server 2005. Hopefully, this will help all those who are preparing for interviews.

Tuesday 4 March 2008

Scaling Out SQL Server 2005

http://msdn2.microsoft.com/en-us/library/aa479364.aspx
Summary: This article explains the different technologies that are available for scaling out a SQL Server 2005 database application, focusing on the factors that go into deciding which solution(s) to use in your application. (16 printed pages)

Monday 18 February 2008

Tcl Windows API and Inspection Tools

Provides high level bindings to Windows APIs from the Tcl scripting language. Includes a standalone program - WiTS - that provides cross-linked views into various Windows components (processes, network connections etc.) http://sourceforge.net/project/showfiles.php?group_id=90123

Thursday 31 January 2008

JDarkRoom : A simple full-screen text editor

About JDarkRoomJDarkRoom is a popular, simple full-screen text file editor with none of the usual bells and whistles that might distract you from the job in hand. If you are writing a novel, essay, thesis or just need to be able to concentrate on your writing, then JDarkRoom may help you. I have released JDarkRoom under the umbrella of CodeAlchemists. Please donate if you find this software useful - it encourages me to add features and fix bugs. The development of JDarkRoom was heavily inspired by DarkRoom, an implementation of WriteRoom (which is a Mac-only application) for Windows, but DarkRoom requires the Microsoft .NET framework. I decided to create my own implementation in Java for those that prefer not to use .NET.


Download
To run JDarkRoom, you need to have Java 1.4 or greater installed. Mac OS X comes pre-loaded with Java so you don't need to worry.
JDarkRoom version 12
Windows (installer)
(198KB)
Mac (application)
(245KB)
Mac / Linux (JAR file)
(119KB)Once the program has fully downloaded, you should be able to double-click on it and it should run straightaway. If you download the JAR version, an alternative is to open a command prompt, navigate to the directory where you downloaded the program, then type java -jar JDarkRoom.jarMac users: You should be able to double-click the downloaded ZIP file, open the JDarkRoom directory, then drag JDarkRoom to your Applications folder, or to the Dock.NB: Thanks to Dane Velasquez for preparing the .app file for the Mac.
Latest changes:
Adjustable margins to fit any screen resolution (F9 to reset)
Text search (F7 / Ctrl-F)
Colour selection mode now defaults to 'text' rather than 'dialog' (solving a problem for some Mac OS X users)
Auto-save backups - so you never lose your work again (applies to new and pre-existing files)
File names specified on the command line can now contain spaces
You can override the default 'conf' directory location (see below)

Wednesday 30 January 2008

10 ASP.NET Performance and Scalability Secrets

Introduction
ASP.NET 2.0 has many secrets, when revealed, can give you big performance and scalability boost. For instance, there are secret bottlenecks in Membership and Profile provider which can be solved easily to make authentication and authorization faster. Furthermore, ASP.NET Http pipeline can be tweaked to avoid executing unnecessary code that gets hit on each and every request. Not only that, ASP.NET Worker Process can be pushed to its limit to squeeze out every drop of performance out of it. Page fragment output caching on the browser (not on the server) can save significant amount of download time on repeated visits. On demand UI loading can give your site a fast and smooth feeling. Finally, Content Delivery Networks (CDN) and proper use of HTTP Cache headers can make your website screaming fast when implemented properly. In this article, you will learn these techniques that can give your ASP.NET application a big performance and scalability boost and prepare it to perform well under 10 times to 100 times more traffic.

http://www.codeproject.com/KB/aspnet/10ASPNetPerformance.aspx

Net Tools © 2008 Mohammad Ahmadi Bidakhvidi (

Net Tools is a comprehensive set of host monitoring, network scanning, security, administration tools and much more, all with a highly intuitive user interface. It's an ideal tool for those who work in the network security, administration, training, internet forensics or law enforcement internet crimes fields. Net Tools is mainly written in Microsoft Visual Basic 6, Visual C++, Visual C# and Visual Studio .NET.
[ download ]

Thursday 17 January 2008

DotNetReflection Concepts

Full article

Introduction

There are two concepts of learning. They are Deep and Surface. Deep learning focuses on "what is signified"; surface focuses on "signs". This article is trying to find the answer for signified questions like what, how, etc. It is intended for this audience.

Monday 14 January 2008

Excellent Software Testing Website

http://www.geocities.com/xtremetesting/

Sunday 13 January 2008

Interview Questions - .Net Remoting

.NET Remoting
1. What’s a Windows process? It’s an application that’s running and had been allocated memory.
2. What’s typical about a Windows process in regards to memory allocation? Each process is allocated its own block of available RAM space, no process can access another process’ code or data. If the process crashes, it dies alone without taking the entire OS or a bunch of other applications down.
3. Why do you call it a process? What’s different between process and application in .NET, not common computer usage, terminology? A process is an instance of a running application. An application is an executable on the hard drive or network. There can be numerous processes launched of the same application (5 copies of Word running), but 1 process can run just 1 application.
4. What distributed process frameworks outside .NET do you know? Distributed Computing Environment/Remote Procedure Calls (DEC/RPC), Microsoft Distributed Component Object Model (DCOM), Common Object Request Broker Architecture (CORBA), and Java Remote Method Invocation (RMI).
5. What are possible implementations of distributed applications in .NET? .NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.
6. When would you use .NET Remoting and when Web services? Use remoting for more efficient exchange of information when you control both ends of the application. Use Web services for open-protocol-based information exchange when you are just a client or a server with the other end belonging to someone else.
7. What’s a proxy of the server object in .NET Remoting? It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.
8. What are remotable objects in .NET Remoting? Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.
9. What are channels in .NET Remoting? Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.
10. What security measures exist for .NET Remoting in System.Runtime.Remoting? None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.
11. What is a formatter? A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.
12. Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs? Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.
13. What’s SingleCall activation mode used for? If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.
14. What’s Singleton activation mode? A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease.
15. How do you define the lease of the object? By implementing ILease interface when writing the class code.
16. Can you configure a .NET Remoting object via XML file? Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.
17. How can you automatically generate interface for the remotable object in .NET with Microsoft tools? Use the Soapsuds tool.

Use local scope to improve performance

Full article
IIS introduced the concept of Internet Server API filters that were used to enhance IIS applications with custom features such as enhanced processing of Http requests. These ISAPI filters were loaded by IIS when it started up and would remain in memory and process all incoming Http requests. While this was a powerful feature, writing ISAPI filters wasn’t exactly simple. This required knowledge of C++ and multithreaded programming and since these DLLs were loaded into the IIS address space, debugging filters was not simple. Further, since the DLLs were loaded into the IIS address space, it was possible for a filter to bring IIS down in the event of a crash. The .NET framework takes the concept of ISAPI filters one step further by introducing Http Handlers which are custom components that process Http requests. In this article we will cover some of the basic principles of Http Handlers and write custom Http Handlers to customize the processing of some Http requests.

Microsoft Network Monitor 3.1

Download
Overview
Network Monitor 3.1 is a protocol analyzer. It allows you to capture network traffic, view and analyze it. Version 3.1 is an update and replaces Network Monitor 3.0. Network Monitor 3.x is a complete overhaul of the previous Network Monitor 2.x version.

Saturday 12 January 2008

Python As an Integration Tool

Python can integrate a variety of disparate systems; you may hear it referred to as a glue language, because it's a powerful way to glue systems together. We have broken the basic integration technologies available on Windows into five groups: files, DLLs, COM, networking, and distributed objects. We'll take a quick look at the Python features that support each one.

Working with Files

The most fundamental technique for making systems talk is working with files. They are at the foundation of every operating system, and huge and reliable systems can be built and maintained by batch-processing files. Every programming language can work with files, but some make it easier than others. Here are some key features:

?Python can read a file into a string (or read a multiline text file into a list of strings) in one line. Strings have no limitations on what they can hold: null bytes and non-ASCII encodings are fine.

?Python can capture and redirect its own standard input and output; subroutines that print to standard output can thus be diverted to different destinations.

?It provides a platform-independent API for working with filenames and paths, selecting multiple files, and even recursing through directory trees.

?For binary files, Python can read and write arrays of uniform types.

?A variety of text-parsing tools are available, ranging from string splitting and joining operations and a pattern-matching language, up to complete data-driven parsers. The key parts of these are written in C, allowing Python text-processing programs to run as fast as fully compiled languages.

?When generating output, Python allows you to create multiline templates with formatting codes and perform text substitutions to them from a set of keys and values. In essence, you can do a mailmerge in one line at incredibly high speeds.

Chapter 17, Processes and Files, provides a comprehensive introduction to these features.

Working with DLLs and C Programs

Windows uses dynamic link libraries extensively. DLLs allow collections of functions, usually written in C or C++, to be stored in one file and loaded dynamically by many different programs. DLLs influence everything that happens on Windows; indeed, the Windows API is a collection of such DLLs.

Python is written in ANSI C, and one of its original design goals was to be easy to extend and embed at the C level. Most of its functionality lives in a DLL, so that other programs can import Python at runtime and start using it to execute and evaluate expressions. Python extension modules can also be written in C, C++, or Delphi to add new capabilities to the language that can be imported at runtime.

The Win32 extensions for Python, which we cover throughout this book, are a collection of such libraries that expose much of the Windows API to Python.

The basic Python distribution includes a manual called Extending and Embedding the Python Interpreter, which describes the process in detail. Chapter 22, Extending and Embedding with Visual C++ and Delphi, shows you how to work with Python at this level on Windows.

COM

The Component Object Model (COM) is Microsoft's newest integration technology and pervades Windows 95, 98, NT, and 2000. The DLL lets you call functions someone else has written; COM lets you talk to objects someone else has written. They don't even have to be on the same computer!

Windows provides a host of API calls to get things done, but using the calls generally requires C programming expertise, and they have a tortuous syntax. COM provides alternative, easier-to-use interfaces to a wide range of operating-system services, and it lets applications expose and share their functionality as well. COM is now mature, stable, and as fast as using DLLs, but much easier to use, and so opens up many new possibilities. Want a spreadsheet and chart within your application? Borrow the ones in Excel. To a programmer with a COM-enabled language (and most of them are by now), Windows feels like a sea of objects, each with its own capabilities, standing by and waiting to help you get your job done.

Python's support for COM is superb and is the thrust for a large portion of this book.

Networking

The fourth integration technology we'll talk about is the network. Most of the world's networks now run on TCP/IP, the Internet protocol. There is a standard programming API to TCP/IP, the sockets interface, which is available at the C level on Windows and almost every other operating system. Python exposes the sockets API and allows you to directly write network applications and protocols. We cover sockets in Chapter 19, Communications.

You may not want to work with sockets directly, but you will certainly have use for the higher-level protocols built on top of it, such as Telnet, FTP, and HTTP. Python's standard library provides modules that implement these protocols, allowing you to automate FTP sessions or retrieval of data from email servers and the Web. It even includes ready-made web servers for you to customize. Chapter 14, Working with Email, and Chapter 15, Using the Basic Internet Protocols, cover these standard library features.

Distributed Objects

The most sophisticated level of integration yet seen in computing is the field of distributed objects: essentially, letting objects on different machines (and written in different languages) talk to each other. Many large corporations are moving from two-tier applications with databases and GUIs to three-tier applications that have a layer of business objects in the middle. These objects offer a higher level of abstraction than the database row and can represent tangible things in the business such as a customer or an invoice. The two main contenders in this arena are COM, which is a Windows-only solution and Common Object Request Broker Architecture (CORBA), which is multiplatform. Python is used extensively with both. Our focus is on COM, and we show how to build a distributed Python application in Chapter 11, Distributing Our Application. Building a distributed applica-

tion is absurdly easy; COM does all the work, and it's a matter of configuring the machine correctly.

Python's support for all five technologies and the fact that it runs on many different operating systems are what makes it a superb integration tool. We believe that Python can be used to acquire data easily from anything, anywhere.

SQL Server Interview Questions - Part 1

Full article

Introduction

In this article we will go through the most basic and frequently asked interview questions on SQL Server. Please do not think that I am writing this article to show shortcuts to candidates who are searching for jobs on SQL Server. But I think no matter how much experience you have, an interview is a different ball game. A good project executioner can get knocked off on simple SQL Server questions. This article will be a complete series, so here's my first from the series - SQL Server Interview Questions Part 1.

Feel free to write to me at shiv_koirala@yahoo.com or else you can also visit my website for more such interview questions.

Happy job hunting....