Technical Tips, Tricks and Articles

Posts Tagged ‘programming

Let’s get Familiar with Delphi Files

leave a comment »

Before starting writing something in the code window, it’ll be great to get some familiarity with Delphi file types. If you create a delphi project you’ll see files with different extensions. Here are their explanations.

  • .PAS – These are the main files in which you’ll write most of your code. The extension comes from the first three letters of the name of Delphi Ancestor "Pascal".

  • .DFM – These are the files in which your GUI based information is saved i.e; any form that you’ll create will have 2 files, 1 .dfm and other one .pas. the .dfm file will contain the information about controls, where those has been placed, their link and the .pas file will contain the code, you’ll wrote.

  • .DCU – Some sort of compiler specific files for debugging etc. Will be created each time you compile your project.

Written by ..alee

April 30, 2007 at 4:31 pm

Posted in Delphi, programming

Tagged with ,

Why Choose Delphi

leave a comment »

That was the very first thing that came in my mind when i started working on delphi. We have VB6, .NET, Java to make Desktop GUI then why Delphi?

I guess this will be the same question (if you are new to Delphi) thinking; why delphi?

The application that we were creating is for "all" users. So we can expect that a user may be having very good system or may be he is still on P-II or P-III. So, deploying an application which needs some extra SDK (.NET, Java) of some XXMB to run an application of size not more than 5MB is a hassle.

So, why we should not we choose VB6. Well, Microsoft is no longer providing support to it’s VB6 and descendant languages. The only focus of MS is now .NET platform. So choosing VB6 for a professional environment will be quite risky. Though i admit that there are enough things available on internet that can provide us enough support, but still the risk factor is there.

Hence, came the option to choose for Delphi. A language that was design to compete the increasing market of VB 6 for Windows platform and then continue its success towards Desktop application (Windows and *NIX). The language was initially designed/architect by Anders Hejlsberg. One of the architect of C# language.

Delphi, besides having all the necessary things required by a good programming language, is also full of enormous support of Windows Platform by using it’s ShellAPI. In simple words, if there is anything on your windows system accessible or usable by Visual C, it is achievable in Delphi as well. Your system level message, events, dlls, ActiveX, whatever that you can ever use in Visual C to make a good application is available here.

Written by ..alee

April 11, 2007 at 4:22 pm

Posted in Delphi, programming

Tagged with ,

A C Code, getting a string using gets();

leave a comment »

Hi,
last night one of my friend showed me a C code and told me that he was unable to get the string input using gets(); I am posting the code here.

char temp[50];
printf("Please enter your name: ");
gets(temp);
printf("%s", temp);

Now, he was very confused that why this simple code is not working. I asked him to put fflush() before calling to gets(). He did it and the code worked fine. Do you get the reason?

The printf does not flush the memory and when you call the gets() it use the buffer characters already in memory buffer thus returning empty string.

Written by ..alee

January 11, 2007 at 4:01 pm

Posted in C, code, programming

Tagged with , ,

Interview Questions (.NET)

leave a comment »

  1. What’s the difference of using System.Text.StringBuilder over System.String?
    Answer: System.String is immutable. System.StringBuilder was designed with the
    purpose of having a mutable string where a variety of operations can be performed.

  2. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
    Answer:
    The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements
    into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element’s object, resulting in a different, yet identical object.

  3. How can you sort the elements of the array in descending order?
    Answer:
    By calling Sort () and then Reverse () methods.
  4. What’s the .NET collection class that allows an element to be accessed using a unique key?
    Answer:
    Hashtable.

Written by ..alee

December 19, 2006 at 3:54 pm

Interview Questions (.NET)

leave a comment »

  1. What’s the difference of using System.Text.StringBuilder over System.String?
    Answer: System.String is immutable. System.StringBuilder was designed with the
    purpose of having a mutable string where a variety of operations can be performed.

  2. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
    Answer:
    The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements
    into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element’s object, resulting in a different, yet identical object.

  3. How can you sort the elements of the array in descending order?
    Answer: By calling Sort () and then Reverse () methods.

  4. What’s the .NET collection class that allows an element to be accessed using a unique key?
    Answer: Hashtable.

  5. Can you allow a class to be inherited, but prevent the method from being over-ridden?
    Answer: Yes. Just leave the class public and make the method sealed.

  6. When do you absolutely have to declare a class as abstract?
    Answer:
    1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
    2. When at least one of the methods in the class is abstract.
  7. What accessibility modifier for methods you may specify inside the interface?
    Answer:
    They all must be public, and are therefore public by default.
  8. What’s the implicit name of the parameter that gets passed into the set method/property of a class?
    Answer:
    Value. The data type of the value parameter is defined by whatever data type the property is declared as.
  9. What’s the difference between // comments, /* */ comments and /// comments?
    Answer:
    // is single-line comment, /**/ is multi-line comment & /// is document comment
  10. What is CorDBG and what is DbgCLR?
    Answer:
    Cordbg is a runtime debugger.
  11. What does assert() method do?
    Answer:
    In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
  12. What’s the difference between the Debug class and Trace class?
    Answer:
    Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
  13. What happens if you inherit multiple interfaces and they have conflicting method names?

    Answer: It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. You have to provide interfacename.methodname.

Written by ..alee

December 16, 2006 at 3:49 pm

OO Questions for .NET/Java

leave a comment »

  1. To which is protected class-level variable available to?
    Answer: It is available to any sub-class (a class inheriting this class).
  2. Are private class-levl variables inherited?
    Answer: Yes, but those are not accessible. Although those are not visible or accessible via the class interface, yet those are inherited.
  3. Describe the accessiblilty modifier "protected internal"?
    Answer: It is available to classes that are within the same assembly and derived from specific base class.

Written by ..alee

November 16, 2006 at 3:52 pm