Wednesday, February 19, 2014

Can Software Developers enjoy their personal life?

Can Software Developers enjoy their personal life?

Normally in any job around the world, you have to work for 40-45 hours a week. But is this really true for a software developer? As a software developer, if you have to grow in your professional life, you have to sacrifice your personal life. This statement is intimidating, but true to some extent. Mainly, the initial years of a software developer are very crucial and you have to work extensively to thrive in your career. Only the lucky software developers get flexible working hours in the office otherwise most of the software developers have to compromise their personal life.

In a software industry, you will have to face:

1. Tight Deadlines
2. Excessive Work Load
3. Staying Late Nights
4. Working on Weekends
5. Code quality and code delivery at same time
6. Bug fixing

If you are a software developer, you have to try hard to maintain work-life balance. Software development is full of uncertainties. Any time any thing can happen in your project and then you have to sit to solve that issue. You always have to think twice before planning your evenings, weekends and holidays as these uncertain and untimely issues can destroy them easily. If you are planning to go for a long holiday, you will have to plan that according to the situation in the project. If you are running through a lot of issues, forget that you will get leaves. You have to inform your manager months ago for your holiday plans otherwise just forget it.

Single vs Married vs Parent Developers

If you are still single, that's fine. You can stay late evenings, you can come on weekends etc. You can also take excessive work load and pressure because at this stage of life you don't have to care about other troubles of your life (except your girlfriend, if you have :) ) as your personal life is smooth till now. But once you get married, you get extra personal life responsibilities on your shoulder. Now you also have to care about your life partner. You also have to give sufficient amount of your time to her/him. You cannot come stay late in office every evening, cannot come to office every weekend etc. etc. The situation becomes worst after kids. At this stage of life, you really have to struggle hard to maintain work life balance otherwise you will not be able to see your kids growing.

Advice to software developers:

1. It depends on how you handle the situation and your skill. However, to survive in the any kind of stream, you should invest your time for atleast 2 to 3 years in that domain and understand clearly. Then you will go into a better position in that stream and you can do well with balanced life. I mean, after you understand clearly about what you do, then only you can prioritize the work properly and can live balanced life with work and family. There are lot of companies which expects only 40 hours of work. Even there, if you fail to deliver, you should put more time and complete the work.

2. Companies take advantage of eager graduates and workaholic tendencies. Just refuse to fall into the pressure to extend hours. If companies can't deal with that, then your better off looking for a new employer. When interviewing at new jobs, it would be good to find out what their overtime policies are. If they have real overtime policies that involve giving you respectable amounts of money for working late, they're probably not as likely to ask for 60-hour work weeks (though I would try to talk to other employees there to get an idea of what actually goes on).

3. Product companies have better working hours compared to Service Oriented companies. So try to get into product companies. But product companies are limited as compared to software oriented companies. 

Sunday, February 16, 2014

Tips to make Interview comfortable for Interviewee

Tips to make Interview comfortable for Interviewee

Job interviews can be intimidating and uncomfortable for applicants. People enter an interview unsure of what is expected and nervous about their performance. The more you, as the employer, can do to make the experience less stressful, the more accurate your impression will be of the person you're interviewing.

Some HR personnel may make candidates feel nervous, unintentionally. However, most HR staff want prospects to feel welcome and at home. It’s important to remember that your company is being interviewed too. People are becoming more and more selective about the jobs they’ll accept these days as a result. Therefore, here are a few simple things you can do that will help job candidates feel much more comfortable before, during and after the interview process. 

1. Have someone to greet the candidate personally

No matter how busy things are, you need to make a point of having someone ready to make the candidate feel welcomed by the company. You do have a position that needs to be filled and the only way that’s really going to happen for any significant amount of time is if you find someone that really wants to be there. Welcoming a candidate is a simple gesture that will help the candidate decide whether or not this is the right job for his or her needs.

2. Make introductions 

Don’t leave the candidate wondering who everyone in the room is while everyone in the room knows who he or she is. It makes for an uncomfortable situation for the job seeker and one that may ultimately be a turn-off to the candidate and his or her interest in your company.

3. Give the candidate a chance to warm up to you and the situation rather than diving right into the heart of the interview process

There are benefits to small talk that go far beyond ascertaining a little bit about how the other person thinks. It helps put people at ease and makes the interview much more productive on all sides. It also lets the candidate see that there are real, genuine people on the other side of the hiring equation. Don’t skip this important part of the process. 

4. Explain the interview process so the candidate knows what to expect

This will make your candidate feel much more at ease and help you feel more comfortable as well. But it also gives the candidate a moment or two to map out how he or she is going to approach the interview questions, and how to follow up.

5. Allow the candidate time to fully articulate his ideas and thoughts, and invite follow-up questions

If the candidate feels rushed through the interview he may feel as though the job is already lost. More importantly, he may feel that the powers that be within the company aren’t really interested in listening to what he has to say. Give the candidate your business card and invite him to contact you with any additional questions or concerns.

6. Treat it Seriously

When you arrive late to an interview, the interviewee may take it as a sign that she is not that important to you. When you make sure to arrive on time and with a welcoming demeanor, she will feel significant and respected. Instead of getting straight to business when the interview begins, attempt to break the ice with small talk about something you think may appeal to the applicant. By taking the first step toward getting to know your interviewee, you take the pressure off someone who is probably already stressed to the limit with anticipation. Once an easy rapport has been developed, she may perform better once you do get down to more serious topics.

7. Line of Questioning

When asking interview questions, use a positive and supportive tone. The idea is to draw the best response as possible from your subject and not to make her uncomfortable or defensive in any way. For example, ask simpler questions at the start of the interview so the subject has a chance to establish herself and become more confident before moving on to more complex or difficult questions. Avoid long and confusing hypothetical situations, accusatory questions or questions with a negative slant. To elicit strong and honest answers, try to keep things positive and allow sufficient time for the interviewee to develop her thoughts, even if the answers you're getting are not what you want to hear.

8. Personal Touches

Have an employee meet and greet each candidate who arrives for an interview. Introduce them to the people they will be working with and anyone they run into while at the office. A basic tour of the office and a walk around the premises is another way to show each person that they are being seriously considered as a potential hire. Walking into a strange place filled with strange people can be intimidating, especially when you will soon have to answer a barrage of questions that determine your future. A simple and warm introduction can take the edge off and make the rest of the process much easier to handle.

9. Before and After

Tell the candidate what to expect before beginning. There's no need to keep the interviewee wondering what to expect. Instead, tell her the basic idea of the interview process, what the questions will focus on and what you hope to learn. Once the interview is concluded, explain to her what she should do next and where she stands. Honesty can remove much of the mystery that often surrounds job interviews while erasing the nervousness that comes along with uncertainty. Try not to dismiss candidates from behind your desk. Instead, walk out with them so they leave with a positive feeling.

Saturday, February 15, 2014

With Keyword in Delphi

With Keyword in Delphi

The With keyword is a convenience provided by Delphi for referencing elements of a complex variable, such as a record or object. 

It simplifies the code by removing the need to prefix each referenced element with the complex variable name. 

For example: 

myObject.colour := clRed;
myObject.size   := 23.5;
myObject.name   := 'Fred'; 

can be rewritten : 

With myObject do
begin
  colour := clRed;
  size   := 23.5;
  name   := 'Fred';
end; 

However be warned that it can surprisingly make your code more difficult to read, especially when nesting With clauses. More disturbingly, it can create maintenance problems, where a code change can mean that the wrong target for the 'child' field referenced.

Example code: Using the with keyword with a record structure

type
  // Declare a customer record
  TCustomer = Record
    firstName : string[20];
    lastName  : string[20];
    address1  : string[100];
    address2  : string[100];
    address3  : string[100];
    city      : string[20];
    postCode  : string[8];
  end;

var
  John, Sarah : TCustomer;

begin
  // Set up the John's customer details
  With John do
  begin
    firstName := 'John';
    lastName  := 'Smith';
    address1  := '7 Park Drive';
    address2  := 'Branston';
    address3  := 'Grimworth';
    city      := 'Banmore';
    postCode  := 'BNM 1AB';
  end;

  // Set up John's sister similarly - simply copying the whole record
  Sarah := John;

  // And then changing the first name to suit
  Sarah.firstName := 'Sarah';

  // Now show the details of both customers
  With John do ShowCustomer([firstName, lastName,
                             address1, address2, address3, city,
                             postCode]);
  With Sarah do ShowCustomer([firstName, lastName,
                             address1, address2, address3, city,
                             postCode]);
end;

// A procedure that displays a variable number of strings
procedure TForm1.ShowCustomer(const fields: array of string);
var
  i : Integer;

begin
  // Display all fields passed - note : arrays start at 0
  for i := 0 to Length(fields)-1 do
    ShowMessage(fields[i]);
end;

Output

John
Smith
7 Park Drive
Branston
Grimworth
Banmore
BNM 1AB

Sarah
Smith
7 Park Drive
Branston
Grimworth
Banmore
BNM 1AB

Pointers in Delphi

Pointers in Delphi

Pointers are a special type of variable. Like a meta-variable. They can point to other variables, or to memory. You might use a record pointer, for example, to point to a block of memory where you have stored lots of record data. You would then use the pointer just as if it were a record variable. The Pointer type provides a general use pointer to any memory based variable. That is, one that is accessed by reference. 

Delphi provides a number of typed pointer types, such as PChar, and PExtended, along with a generic, 'point to anything' type - the Pointer type.

var
  generalPtr : Pointer;  // A pointer to anything
  formPtr    : ^TForm;   // A pointer to a form object

begin
  // The current unit's form is addressable via the self keyword
  generalPtr := Addr(self);

  // We can assign this pointer to the form pointer
  formPtr := generalPtr;

  // And set the form caption to show this
  formPtr.Caption := 'Test program';
end;

The nice thing about the typed pointers is that they work sensibly with the Inc and Dec functions. Incrementing an PInt64 pointer will add SizeOf(Int64) bytes to the pointer address so that it points to the next Int64 variable in memory.
 
The Pointer type is a dangerous one - it falls foul of Delphi's normally tight type handling. Use it with care, or you will end up addressing the wrong memory. It is normally always better to use a specific pointer reference to the data type you are using.

Different Pointer types in Delphi

PAnsiChar: A pointer to an AnsiChar value
PAnsiString: Pointer to an AnsiString value
PChar: A pointer to an Char value
PCurrency: Pointer to a Currency value
PDateTime: Pointer to a TDateTime value
PExtended: Pointer to a Extended floating point value
PInt64: Pointer to an Int64 value
PShortString: A pointer to an ShortString value
PString: Pointer to a String value
PVariant: Pointer to a Variant value
PWideChar: Pointer to a WideChar
PWideString: Pointer to a WideString value

A simple example using PChar

The PChar type can be used to scan along a string :
 
 var
   myString  : string;
   myCharPtr : PChar;
   i : Integer;

 begin
   // Create a string of Char's
   myString  := 'Hello World';

   // Point to the first character in the string
   i := 1;
   myCharPtr := Addr(myString[i]);

   // Display all characters in the string
   while i <= Length(myString) do
   begin
     ShowMessage(myCharPtr^);  // Display the string characters one by one
     Inc(i);
     Inc(myCharPtr);
   end;
 end;

There are two things to note here. First the use of Addr function to get the address of the string. You could equally use the @ operator. Pointers always work with addresses - the address of a variable here, or a block of acquired memory. Here we point the PChar value to the first character in the string.
 
Secondly, now that we have a pointer, we use the ^ character at the end of the pointer name to refer to what the pointer points to. In this case, a character.
 
A PChar^ will always give us a character. A PInt64^, for example, will give us an Int64 value. This is where the typing comes in.

Record pointers

You can define a pointer to any data type using a different technique:
 
 var
   myRecordPtr : ^TMyRecord;

Here, the ^ symbol is used to dereference the type - we are saying that we do not have a TMyRecord type, but a pointer to one. Note that this is a prefix use of ^.
 
Let us create a full record example :
 
 type
   TMyRecord = Record
     name : String[20];
     age  : Integer;
   end;

 var
   myRecord    : TMyRecord;
   myRecordPtr : ^TMyRecord;

 begin
   myRecord.name := 'Fred Bloggs';
   myRecord.age  := 23;

   myRecordPtr := @myRecord;

   ShowMessage(myRecordptr.name);  // Displays 'Fred Bloggs'
 end;

When we simply refer to the record field name, without a ^, Delphi is in fact adding one for us - it recognises what we are doing, and helps us make for more readable code.

Currency Data Type in Delphi

Currency Data Type in Delphi

Currency is a fixed-point data type that minimizes rounding errors in monetary calculations. It is stored as a scaled 64-bit integer with the 4 least significant digits implicitly representing decimal places. When mixed with other real types in assignments and expressions, Currency values are automatically divided or multiplied by 10000.

The Currency type is designed for use in financial applications. It supports 4 decimal places with at least 53 bits precision. Decimal places beyond the supported 4 are rounded up or down, as appropriate. See the sample code for an example.

var
  account1, account2, account3 : Currency;
begin
  account1 := 123.456749;   // Too many decimals - will be rounded down
  account2 := 123.456750;   // Too many decimals - will be rounded up
  account3 := account1 + account2;

  ShowMessage('Account1 = '+CurrToStr(account1));
  ShowMessage('Account2 = '+CurrToStr(account2));
  ShowMessage('Account3 = '+CurrToStr(account3));
end;

Output

Account1 = 123.4567
Account2 = 123.4568
Account3 = 246.9135

Tuesday, February 11, 2014

Conditional Compilation in Delphi

Conditional Compilation in Delphi

Conditional compilation is based on the existence and evaluation of constants, the status of compiler switches, and the definition of conditional symbols.

Conditional symbols work like Boolean variables: they are either defined (true) or undefined (false). Any valid conditional symbol is treated as false until it has been defined. The {$DEFINE} directive sets a specified symbol to true, and the {$UNDEF} directive sets it to false. You can also define a conditional symbol by using the -D switch with the command-line compiler or by adding the symbol to the Conditional Defines field on the Project > Options > Delphi Compiler page.

The conditional directives {$IFDEF}, {$IFNDEF}, {$IF}, {$ELSEIF}, {$ELSE}, {$ENDIF}, and {$IFEND} allow you to compile or suppress code based on the status of a conditional symbol. {$IF} and {$ELSEIF} allow you to base conditional compilation on declared Delphi identifiers. {$IFOPT} compiles or suppresses code depending on whether a specified compiler switch is enabled.

For example, the following Delphi code snippet processes differently depending on whether the DEBUG conditional define is set. You can set conditional defines on the Project > Options > Delphi Compiler page or by entering {$DEFINE DEBUG} in your code:

{$DEFINE DEBUG}
{$IFDEF DEBUG}
  Writeln('Debug is on.');  // This code executes.
{$ELSE}
  Writeln('Debug is off.');  // This code does not execute.
{$ENDIF}

{$UNDEF DEBUG}
{$IFNDEF DEBUG}
  Writeln('Debug is off.');  // This code executes.
{$ENDIF}

Note: Conditional symbols are not Delphi identifiers and cannot be referenced in actual program code. Similarly, Delphi identifiers cannot be referenced in any conditional directives other than {$IF} and {$ELSEIF}.

Note: Conditional definitions are evaluated only when source code is recompiled. If you change a conditional symbol's status and then rebuild a project, source code in unchanged units may not be recompiled. Use Project > Build All Projects to ensure that everything in your project reflects the current status of conditional symbols.

Monday, February 10, 2014

How to open and close datasets in Delphi? Difference between Open Method and Active Property in Delphi

How to open and close datasets in Delphi? Difference between Open Method and Active Property in Delphi

To read or write data in a dataset in Delphi, an application must first open it. You can open a dataset in two ways:

1. Open method: Call the Open method for the dataset at run time.
2. Active Property: Set the Active property of the dataset to True, either at design time in the Object Inspector, or in code at run time.

After performing operations on datasets, you must close them. You can close a dataset in two ways:

1. Close method: Call the Close method for the dataset at run time.
2. Active Property: Set the Active property of the dataset to False, either at design time in the Object Inspector, or in code at run time.

For example, if you have dsSample dataset in your code. You can open it like:

dsSample.Open;
dsSample.Active := True;

and close it like:

dsSample.Close;
dsSample.Active := False;

Difference between Open and Active

1. Open is a methods and Active is a property.

2. Open method is generally used at runtime while Active property is used to open dataset at design time. Active deals with Object Inspector. Without having Active property you wouldn't be able to open the dataset at design time because you cannot publish method to the Object Inspector.

3. Open method is much more readable than evaluating what's assigned to the Active property.

4. Active property calls Open method internally.