New Message on dotNET User Group Hyd

.net dilemma

Reply
  Recommend Message 8 in Discussion
From: Saradhi

Hi Vamsi,
I am back with an asnwer to your dilema again.

Wwhatever critics like you may say .NET has some real cool feature which as a MFC / COM developer you are definitely going to love. I have compiled a set of features that I think are really cool about the .NET. Here are these.

Debugging Support
You can attach and detach a debugger to a running application. In past there have been many occassions where you might have attached a debugged to your process on a user's or a tester's machine. After you have done whatever needed to be done or seen, you wish you could somehow remove your debugger and let the code run without debugger. But it was not possible until now. So I think this is one cool feature about .NET. Morever there are two different flavors of debugger - console and UI debugger.

CString class available in ATL projects
CString has been one of the most useful utility classes available to MFC programmers. CString class had around a hundred useful member functions. It supported almost all the string manipulation functions. But ATL components could not access the CString class because of its MFC dependency. .NET removed this dependency and made CString a template class CString<T> where T can be a char ,TCHAR , wchar_t etc.

DDX_DHtml_XXX macros
Until now manipulating the elements on an HTML view required the knowledge of COM ( using IHTMLElement interface). In order to access an element on HTML page, one needed to go through the regular DOM (document object model) and access the element's IHTMLElement interface. In MFC there was already a class CHtmlView used to wrap the web browser control and that was it. But now with new DDX style macro you can actually access individual controls on the html page. All you need to have is an ID associated with the element on HTML page. For example
DDX_DHtml_CheckBox(pDX, _T("buyItem"), m_buyItem); associates a check box with id buyItem with m_buyItem variable.
Also you can receive events in a very clean way. All you need to do is declare
a DHTML event map as:

BEGIN_DHTML_EVENT_MAP(CYourHtmlClass)
DHTML_EVENT_CLASS(DISPID_HTMLELEMENTEVENTS_ONMOUSEOVER,
T("hotElement"), OnMouseOverElement)
END_DHTML_EVENT_MAP()

C#'s case statement
Look at the following C++ code:

switch ( adwResult ){
case 10:DeclareGoodResult();
case -1:DeclareBadResult();
break;
case 0 : DecaleUnAvailablity();
}

See anything wrong. Compiler will compile this code happily but it will lead to unexpected functionality at runtime. All because you forgot to "break" from case 10.
Now you won't be able to do so in C#. In C# it is illegal to do so and compiler will tell you this by not compiling the code.
Also case statement does take String literals as argument.
switch(day) {case "sunday" : ....} is valid now.

VB.net
Declare and assign value in same go
Dim x As Integer = 10 as opposed to VB equivalent to
Dim x
x = 10

Class_Initialize takes parameters now
In VB 6 you could declare a class and (.cls) file and you could write Class_Initialize and this function would be called by VB runtime as and when you create an instance of this class. But the problem with this initializer was that you could not pass any parameters. But in VB.NET there is no Class_Initialize function available . Instead you can overload New and that is guaranteed to be called by CLR ( Common Language Runtime) whenever you New a class. Also you can overload the New method to have different flavors.For code click here

Delegates
I think this is a very powerful and cool feature that has been embedded into .NET platform. In very simple terms Delegates are callbacks. Almost all the Windows developers are familiar with the concept of callbacks. For example when you want to enumerate all the windows on the screen you make a call to EnumWindows passing the address of the callback function that is called by the windows passing in the handle of the window. That is callback. Similarly CListCtrl has a function where by you can pass a callback function for sorting. Even C qsort function had a callback. Delegates are little more advanced. Click here to know more about delegates


Documentation Made Easy
This is another cool feature in C#,C# compiler has built in capability to generate documentation of the source code.The documentation is based on XML .The trick is to use three slashes /// and you are opening doors to documentation feature of C# source code.Take a look at the example below.

public class MyClass{
/// <summary>
/// <param name = cszMessage> The message to be displayed.</param>
/// <param name = lDeviceNo> Device to be printed on</param>
///</summary>
public void DisplayMessages(string cszMessage,long lDeviceNo)
{
}
}

In the above piece of code, look at the comments above DisplayMessages function.There are three slashed comments.The tags are self-explanatory There are two <param> attributes which indicate the two parameters passed.You can add your description between tags.And finally you can use following menu item from VS.NET IDE to generate the documentation in XML format:
Build>Tools>Build Comment Web Pages...
or use the following command line to generate documentation to an xml file
csc /doc: Document.xml Prog.cs


As I said long time back on the same post, developing a GUI application in MFC takes hell lot of time , but it is easier to write a faster COM component. So if you want to create an application in MFC, you have to compromise for your GUI.

So why cant we take the fastness of MFC and at the same time develop well designed User-Friendly application???

-SARADHI

View other groups in this category.

baazee.com

Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.

If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.

Reply via email to