Thursday, December 27, 2007

Agile/Process Questions

1,What is a stand up meeting? Whats the duration of a standup meeting?

A stand-up meeting (or simply stand-up) is a daily team meeting held to provide a status update of the work done to the team members. The meetings are usually of 5-15 minutes and are held standing up to remind people to keep the meeting short and to the point. They are called morning rollcall or the dailyscrum.

2, What is a product backlog?(SCRUM)

A product backlog is a prioritised list of project requirements with estimated times to turn them into completed product functionality. Estimates are in days and are more precise the higher the item is in the Product Backlog priority. Priority should be assigned based on the items of most value to the business or that offer the earliest Return on Investment. This list should evolve, changing as the business conditions or technology changes.

3, What is a User Story?(XP)

User stories serve the same purpose as use cases but are not the same. They are used to create time estimates for the release planning. They are also used instead of a large requirements document. User Stories are written by customer as things that the system needs to do for them.

4. How is estimation done in agile process?
This is beyond the scope of the blog since estimation technique varies for different practices. Do a google search on it.http://agilealliance.com/system/article/file/1421/file.pdf is a good quick link.

5, What is a sprint backlog?(SCRUM)

The Sprint backlog is a list of tasks that defines a Team's work for a Sprint. The list emerges during Sprint planning

6. What is the difference between agile methodology and other methodologies?
Pls check http://www.agilemanifesto.org/

7. What is the maximum team size for an agile project.

It is a debated topic. Many blogs say 20 is the max size. But I personally know a project of team size 100 whicj is well executed. I don't know whether they are conducting a standup meeting every day:-) So be careful-you are free to answer above 20.

8. Given a choice, will you work in agile or waterfall process?

Normally the answer depends on which project are you going to get recruited for. You may not know it. So be cautious in answering it. Just mention that you are flexible and will work for the project not for the process. Process is a tool to achieve the project goals.

9. Who assigns the work to you?

Varies for different agile methodologies. Mostly people pick their own task after discussion.

10. Who decides how many features, stories should be completed in one iteration?

The team. Team includes customer also.

11. Why do you need a stand up meeting, sprint meeting etc?

Pls do a google search on it. There is a motive behind all the agile practices. Be conversant with the each one in your methodology.

Wednesday, December 19, 2007

Source Control Questions

1, What is the difference in file updating in VSS and CVS?

VSS follows "checkout-edit-checkin" doctrine ie; it is impossible for two people to modify a given file at the same time, thus avoiding the necessity of merging two versions of a file into one. Edit the working file as needed. Merge any recent changes from the server into the working file and commit the file to the repository.
CVS follows "edit-merge-commit" doctrine ie;files in the working folder are always writable. Nobody uses checkouts at all, so nobody knows who is editing which files. When a developer commits his changes, he is responsible for ensuring that his changes were made against the latest version in the repository

2, What are labels/tags?
Labels associate a name with a specific version of the product/software in the repository. If you label the code with a label at a particular point of time for a particular release, you can retrieve them by name later.

3, Give some situations where you use labels?
a.When you make a release
b.When something is about to change:Sometimes it is necessary to make a change which is widespread or fundamental. Before destabilizing your code, you may want to apply a label so you can easily find the version just before things started getting messed up.
c.When you do an automated build:Some automated build systems apply a label every time a build is done. The usual approach is to first apply the label and then do a "get by label" operation to retrieve the code to be used for the build.

4. What is label promotion? Why is it needed?

Label promotion is the process of including a higher version of file in a label than a lower version. This is done to accomodate a minor change to a label after it was originally created.

5. Explain branching.

Branching happens when the source code has to take paths/forks of development ie; for different products using the same basic mechanism, fundamentally different versions etc. Branching enables concurrent development of systems with common shared code history and merging the changes to the shared code history at a later point.

Friday, December 7, 2007

Debugging Questions

1, What is the difference between ASSERT and VERIFY macros?

Both the macros evaluates the expression, interrupt the program and give a diagnostic message in debug mode. ASSERT won't perform any of the above tasks in release mode but VERIFY evaluates the expression in release mode.

2. Your application crashes in a remote site. How are you going to get the error information?

So many ways. But a good choice is logging which gets enabled on setting an environment variable.

3. How do you debug a DLL?

Mention an executable for debug session in the project settings.

Thursday, December 6, 2007

Windows Programming Questions

SECTION- MESSAGE HANDLING

1, Explain the message routing mechanism in a windows application.

Every windows application has an application object which has a main thread. Remember CWinApp is derived from CWinThread. The main thread has a message queue associated with it. Summarize it like this - Every application has a message queue.Windows places the input messages to the application in this queue or sends it directly to the window procedure. So we have two types of messages based on queuing.

a. Queued Messages

Every thread has a message loop which pops the message from the queue, fill it in a MSG structure and dispatches to the appropriate window of the application. This is encapsulated in Run member function of CWinApp inherited from CWinThread. By dispatching I mean call the window procedure of the window class with message parameters. The window procedure handles the messages based on the message type.

A typical message loop implementation looks like this.

MSG msgstruct;
BOOL bResult;

while( (bResult = GetMessage( & msgstruct, NULL, 0, 0 )) != 0)//POPS from the queue
{
if (bRet == -1)
{
// error handling
}
else
{
TranslateMessage(&msgstruct); //Convert virtual key code to WM_CHAR
DispatchMessage(&msgstruct); //Fill MSG structure & calls the window procedure
}
}

b. Nonqueued Messages

Nonqueued messages are sent directly to the destination window procedure, bypassing the system message queue and thread message queue
Eg: WM_ACTIVATE

2. How to handle a message before it reaches TranslateMessage?

OverRide CWnd::PreTranslateMessage and handle the message in it.

3.What are the types of windows messages?

Based upon queuing there are two types of messages ie; queued and non-queued.
Based up on the definition there are two types of messages ie; System-Defined Messages and Application-Defined Messages(starts from WM_USER)

System defined Messages are classified into 3 categories again.
a.Windows messages
All messages beginning with the WM_ prefix, except for WM_COMMAND comes under this. Handled by windows and views. They have parameters that are used in determining how to handle the message.

b.Control notifications
These are WM_COMMAND notification messages from controls and other child windows to their parent windows.For example, an edit control sends its parent a WM_COMMAND message containing the EN_CHANGE control-notification code when the user has taken an action that may have altered text in the edit control. The window's handler for the message responds to the notification message in some appropriate way, such as retrieving the text in the control.
Routing is same as other WM_ messages except the BN_CLICKED notification message which is treated specially as a command message and routed like other commands.

c.Command messages
WM_COMMAND notification messages from user-interface objects: menus, toolbar buttons, and accelerator keys. There is a special order for handling these mesages called as Command Routing.

4. How Command messages are treated differently fro other messages?

Commands can be handled by a wider variety of objects: documents, document templates, and the application object itself in addition to windows and views. There is a standard routing order for handling command messages(Command Routing). The other messages are used to populate the MSG structure and passed to window procedure of the target window.

5. How does a window handles incoming messages?

At run time, each window is attached to a window object that has its own associated message map and handler functions. The framework uses the message map to map incoming messages to handlers.

6. Which is the MFC base class which implements the ability to send and recieve windows messages?


CCmdTarget

7. What is a message map?

A message map is a structure which routes commands or messages to a window to the member functions of the window class. (A command is a message from a menu item, command button, or accelerator key.)

8. How a messae map is different from virtual table mechanism in C++?

When ever a window recieves a message it chcks message map of itself to handle the message. If not found in its window class, it searches the immediate base classes message map for a handler. The virtual table of the window doesn't contain the pointer to the handler of the message if it is not overriden in the window class. In a virtual table mechanism in C++ the function pointer to a virtual function is in the virtual table even if it is not overriden in the derived class. The advantage of MFC message map mechanism is that with deep levels of class heirarchy it is able to provide a lot of functionality inhritance with out a virtual table bloat.

Windows Programming Questions

SECTION- GDI and DRAWING

1. What is the purpose of GDI?

It is a layer which enables applications to use graphics and formatted text on both the video display and the printer.
Windows-based applications do not access the graphics hardware directly. Instead, GDI interacts with device drivers on behalf of applications.

2. What is a device context (DC)?

In windows drawing operation is done on three types of devices ie; Screen, printer or metafile.
DC is a structure containing information about the drawing attributes of a device such as a display or a printer.
All drawing calls are made through a device-context object, which internally calls the Windows APIs for drawing lines, shapes, and text.
Device contexts allow device-independent drawing in Windows.(Drawing logic is same for all devices).

3. What are the types of windows system objects?

a. User objects - supports window management
Eg: Window, Window Position, Accelerator Keys, Cursor, Icon, Menu, Caret, DDE conversation

b. GDI objects - supports graphics
Eg: Bitmap, Brush, DC, Font, Palette, Pen, Regions

c. Kernel objects - support memory management, process execution, and interprocess communications (IPC).
eg:Acces Token,Files,File mapping,Heap,Desktop,Thread,Event,Mutex,Semaphore,Critical Section,Timer,Module

4. Explain the different device context classes.

a. CPaintDC
This can be used only when responding to a WM_PAINT message ie; OnPaint().
It calls CWnd::BeginPaint() in the constructor and CWnd::EndPaint at destruction time.
CView::OnDraw function is passed with a CPaintDC already prepared (via OnPrepareDC()).

b. CClientDC
Represents only the client area of a window.
Constructor calls GetDC() and destructor calls ReleaseDC()

c. CWindowDC
Represents entire screen area of a CWnd object (both client and nonclient areas).
Constructor calls GetWindowDC() destructor calls ReleaseDC().

d. CMetaFileDC
Represents Windows metafile, which contains a sequence of graphics device interface (GDI) commands that you can replay to create a desired image or text.
User is supposed to call OnPrepareDC() here.

5. Explain the steps to use a Graphic Object with a device context.

Define a graphic object on the stack frame. Initialize the object with the type-specific create function, such as CreatePen. Alternatively, initialize the object in the constructor. See the discussion of one-stage and two-stage creation, which provides example code.

Select the object into the current device context, saving the old graphic object that was selected before.

When done with the current graphic object, select the old graphic object back into the device context to restore its state.

Allow the frame-allocated graphic object to be deleted automatically when the scope is exited.

6. What is a mapping mode? Why is it needed?

A device context has the ability to maintain a coordinate system separate and distinct from the underlying device. The co-ordinate system of the device context is called “Logical Co-ordinates” where as the one of the device is called “Physical /Device Co-ordinates”. Mapping mode, view port origin and extents, maps the Logical co-ordinates to Physical one. Eg: One logical unit is equal to one pixel if the mapping mode of the DC is MM_TEXT. Check out for view port origin and extents. A detailed description of these details is out of the scope of this post (They are not asked generally)J.

7. How do you convert Logical Points to device points and vise versa?

The LPtoDP function converts logical coordinates into device coordinates. The DPtoLP function converts device coordinates into logical coordinates. The conversion depends on the mapping mode of the device context, the settings of the origins and extents for the window and viewport, and the world transformation. The ScreenToClient() function converts the screen coordinates of a specified point on the screen to client-area coordinates and ClientToScreen does the reverse.

8. What are co-ordinate spaces and transformations in GDI?

They are used to scale, rotate, translate, shear, and reflect graphics output by an application. A coordinate space is a planar space that locates two-dimensional objects by using two reference axes that are perpendicular to each other. There are four coordinate spaces: world, page, device, and physical device (client area, desktop, or page of printer paper).

A transformation is an algorithm that alters ("transforms") the size, orientation, and shape of objects. This includes Translation, Scaling, Rotation, Shear and Reflection . Transformations also transfer a graphics object from one coordinate space to another. Ultimately, the object appears on the physical device, which is usually a screen or printer.

8. When is CWnd::OnEraseBkgnd called?What is the significance of it?

It is called to prepare an invalidated region for painting. Usually it is overridden to avoid flickering. Flickering appears, because the complete control is erased and it needs some time to fill the control-area with some text/graphics or whatever. There is a really short moment, when nothing can bee seen, because the background was erased but nothing is written yet. That's why we don't erase the background of the control anymore. To do this, we have to override the OnEraseBkgnd() to return false. Over ride the parent’s OnEraseBkgnd() to avoid flicker fully using ExcludeClipRect() using the control’s rectangle as a parameter. Explore it and enjoy flicker free drawing.

9. How to load Bitmap as background for a dialog box in an MFC application?

In the OnInitDialog () of the Dialog Box perform the following steps
Declare a member variable m_bkGroundMemDC of type CDC
Create a CBitmap object and mention the resource
Select the bitmap into the m_bkGroundMemDC

In the OnPaint () of the Dialog Box perform the following steps .
Get the Dialog box DC
Do BitBlt or StretchBlt of the Dialog box DC with m_bkGroundMemDC as the source
Relaese Dialog box DC

What is #pragma directive?

The #pragma preprocessor directive allows each compiler implementation to implement compiler-specific features. Each implementation of C and C++ supports some features unique to its host machine or operating system. Some programs, for instance, need to exercise precise control over the memory areas where data is placed or to control the way certain functions receive parameters. The #pragma directives offer a way for each compiler to offer machine- and operating system-specific features while retaining overall compatibility with the C and C++ languages. Pragmas are machine- or operating system-specific by definition, and are usually different for every compiler.

Wednesday, December 5, 2007

How To Share Data Between Different Mappings of a DLL

#pragma data_seg(".shared")
int iSharedVar = 0;
#pragma data_seg()

In the .def file
SECTIONS
.shared READ WRITE SHARED