Pages : 2649780070077928 Price : Rs.
250.
00
Professional
July 2009
CRACKING THE C, C++CRACKING THE C, C++
AND JAVA INTERVIEWAND JAVA INTERVIEW
9780070077928
Pages : 264
Price : Rs.
250.
00
S G Ganesh is currently
working at Siemens,
Bangalore.
He has also
authored the book 60 Tips
on Object Oriented
Programming.
PRIVACY NOTICE:...
More
Pages : 2649780070077928 Price : Rs. 250. 00 Professional July 2009 CRACKING THE C, C++CRACKING THE C, C++ AND JAVA INTERVIEWAND JAVA INTERVIEW 9780070077928 Pages : 264 Price : Rs. 250. 00 S G Ganesh is currently working at Siemens, Bangalore. He has also authored the book 60 Tips on Object Oriented Programming. PRIVACY NOTICE: Tata McGraw-Hill Education Pvt. Ltd. values your Privacy. From time to time The through this with other companies whose products or services we feel may be of interest to you. If you would like your name removed from these lists, please mail a written request to Tata McGraw-Hill Education Pvt. Ltd. B-4, Sector-63, Dist. Gautam Budh Nagar, Noida, UP-201 301 or email us at suman_datta@mcgraw-hill. com. For questions about our privacy ractices or to confirm the accuracy of your information, please contact Roystan La Porte, Privacy Official at Tata McGraw-Hill Education Pvt. Ltd. B-4, Sector-63, Dist. Gautam Budh Nagar, Noida, UP-201 301 or call at+9
Less
From sgganesh
Adobe PDF document
Pub. on Sept. 2nd 2009
Pages: 1
Views: 107
Downloads: 0
Professional
9780070656703
244 Pages
Rs.
250/Noida:B-4,Sector-63,Dist.
GautamBudhNagar,Noida-201301Ph:+91-120-4383435
Fax:+91-120-4383401-403E-mail:rekha_dhyani@mcgraw-hill.
com
Bangalore:3310,IstFloor,8thCross(Off12thMain),H.
A.
L.
IIStage,IndiraNagar, Bangalore-560038
Ph....
More
Professional 9780070656703 244 Pages Rs. 250/Noida:B-4,Sector-63,Dist. GautamBudhNagar,Noida-201301Ph:+91-120-4383435 Fax:+91-120-4383401-403E-mail:rekha_dhyani@mcgraw-hill. com Bangalore:3310,IstFloor,8thCross(Off12thMain),H. A. L. IIStage,IndiraNagar, Bangalore-560038 Ph. :080-25263097Fax:080-25272797E-Mail:murali_krishna@mcgraw-hill. com Bhopal:BuildingNo. 49,1stFloor,Zone-1,MajorShoppingCentre, MPNagar,Bhopal, MadhyaPradesh-462011 Ph. :0755-4075638/4075637Email:pritam_bisht@mcgraw-hill. com, E-mail:rahul_arora@mcgraw-hill. com Bhubaneswar:52,ForestPark,2ndFloor,Bhubaneswar–751009 Ph. :0674-6531259,2595228E-mail:sudipto_banerjee@mcgraw-hill. com Chennai: 444/1,SriEkambara,Naicker,IndustrialEstate,Alapakkam, Porur,Chennai-600116Ph. :044-24769557-62(6Lines) E-Mail:sushil_mathews@mcgraw-hill. com Hyderabad:IstFloor,"KalaNilayam",E-6,VikrampuriColony,Karkhana, Secunderabad-500009 Ph. :040-27842412,Telefax:27842436E-Mail:sampath_erukulla@mcgraw-hill. com Kolkata: AE-641,SaltLakeCity,Sec
Less
From sgganesh
Adobe PDF document
Pub. on June 7th 2009
Pages: 1
Views: 13
Downloads: 0
12 | February 2009 | LINuX For you | www.
openITis.
com
S.
G.
Ganesh
The Joy of Programming | Guest Column
H
ow does one calculate the average of two integers,
say i and j? Trivial you would say: it is (i + j) / 2.
Mathematically, that’s correct, but it can overflow
when i and j are either very large or very...
More
12 | February 2009 | LINuX For you | www. openITis. com S. G. Ganesh The Joy of Programming | Guest Column H ow does one calculate the average of two integers, say i and j? Trivial you would say: it is (i + j) / 2. Mathematically, that’s correct, but it can overflow when i and j are either very large or very small when using fixed-width integers in C-based languages (like Java). Many other languages like Lisp and Python do not have this problem. Avoiding overflow when using fixed-width integers is important, and many subtle bugs occur because of this problem. In his popular blog post [1], Joshua Bloch (Java expert and author of books on Java intricacies) writes about how a bug [2] in binarySearch and mergeSort algorithms was found in his code in java. util. Arrays class in JDK. It read as follows: 1: public static int binarySearch(int[] a, int key) { 2: int low = 0; 3: int high = a. length - 1; 4: 5: while (low <= high) { 6: int mid = (low + high) / 2; 7: int midVal = a[mid];
Less
From sgganesh
Adobe PDF document
Pub. on June 7th 2009
Pages: 1
Views: 4
Downloads: 0
www.
linuxforu.
com | LINUX FOR YOU | MAY 2007
C M Y K
73
IIIII
t is assumed that the underlying machine follows 2’s
complement representation for integers and IEEE 754
floating point standard for floating point numbers.
Let us look at a well-known trick of swapping two integers
without using any temporary variables, which uses...
More
www. linuxforu. com | LINUX FOR YOU | MAY 2007 C M Y K 73 IIIII t is assumed that the underlying machine follows 2’s complement representation for integers and IEEE 754 floating point standard for floating point numbers. Let us look at a well-known trick of swapping two integers without using any temporary variables, which uses arithmetic operators + and -: void swap(int *i, int *j){ *i = *i + *j; *j = *i - *j; *i = *i - *j; } Yes, we know it works. But does it really work in all cases? How about this code: int arr[5] = {10,20,30,40,50}; int *ip = &arr[3]; swap(ip,&arr[3]); for(int i = 0; i<5; i++) printf(“%d “, arr[i]); // output: 10 20 30 0 50 So, when the elements to be swapped happen to refer to the same location, swapping fails. In the statement ‘*i= *i + *j;’, the implicit assumption is that *i and *j point to two different locations; this trick will not work if the results of + and – operations are over-written. Here is a small test case just to demonstrate that: int x = 10;
Less
From sgganesh
Adobe PDF document
Pub. on June 7th 2009
Pages: 1
Views: 5
Downloads: 0
78 MAY 2007 | LINUX FOR YOU | www.
linuxforu.
com
C M Y K
Overview
tandard Template Library (STL) is
a powerful template library for
C++, which is used extensively in
the industry.
It provides generic,
fundamental data structures and
algorithms useful for most of the programs.
So,
it avoids reinventing the wheel and provides
code...
More
78 MAY 2007 | LINUX FOR YOU | www. linuxforu. com C M Y K Overview tandard Template Library (STL) is a powerful template library for C++, which is used extensively in the industry. It provides generic, fundamental data structures and algorithms useful for most of the programs. So, it avoids reinventing the wheel and provides code that is well tested, versatile, efficient and generic. For example, if you want to write a symbol table for your toy compiler, you can go ahead and write your own symbol table. However, this approach suffers from several disadvantages: The effort required to write a full-fledged, effective and efficient symbol table is substantial. The hand-written code needs to undergo rigorous testing (since the symbol table is a very important piece of a compiler). Finding and fixing problems can take significant amounts of time and energy. The data structure needs to be efficient and effective: achieving this is not easy. If some other programmers are assigned to m
Less
From sgganesh
Adobe PDF document
Pub. on June 7th 2009
Pages: 4
Views: 6
Downloads: 0
102 june 2008 | LInuX For You | www.
openITis.
com
T
he following trick using three consecutive ex-or
operations for swapping two variables without
using a temporary is well known and particularly
popular among students:
i ^= j; j ^= i; i ^= j;
Here, i and j are integer variables and it works well
(we covered a few pitfalls earlier...
More
102 june 2008 | LInuX For You | www. openITis. com T he following trick using three consecutive ex-or operations for swapping two variables without using a temporary is well known and particularly popular among students: i ^= j; j ^= i; i ^= j; Here, i and j are integer variables and it works well (we covered a few pitfalls earlier with this). For further optimisation, one often sees this solution combining the three statements into a single statement: i ^= (j ^= (i ^= j)); Try this with your favourite C compiler; it usually works. This trick works based on the following assumption: the values of i and j are modified in the RHS (right-hand side) of the expression and the modified values are expected to be used in the LHS (left-hand side) of the expression. However, this solution need not work and the updated values of i and j need not get reflected when read again. This is because the compiler is free to optimise the sequence of reads and writes, using temporaries internally.
Less
From sgganesh
Adobe PDF document
Pub. on June 7th 2009
Pages: 1
Views: 6
Downloads: 0
Object Oriented Programming Essential Techniques
S G Ganesh
sgganesh@gmail.
com
From sgganesh
Adobe PDF document
Pub. on June 7th 2009
Pages: 37
Views: 7
Downloads: 0
Intermediate Languages
Intermediate languages are with us for quite a long time.
Most of the
compilers employ them in one-way or another.
The way of using
intermediate languages have also sometimes contributed to the
success of the languages like Pascal, Java and recently C# (with .
NET
initiative in general).
Even some tools like...
More
Intermediate Languages Intermediate languages are with us for quite a long time. Most of the compilers employ them in one-way or another. The way of using intermediate languages have also sometimes contributed to the success of the languages like Pascal, Java and recently C# (with . NET initiative in general). Even some tools like MS-Word makes use of an intermediate language (p-code). Intermediate languages have made a big difference in achieving portability of code. This article explores the concept of intermediate languages and their use in achieving complete portability and language interoperability. In 1950s itself, this idea of having an intermediate language was experimented with the introduction of UNCOL [1]. Later Pascal became widely available because of p-code. Not until recently did Java employed the same technology with its promise of portability to become a big success. Now Microsoft s . NET initiative is also based on this approach, but the keyword is language i
Less
From sgganesh
Adobe PDF document
Pub. on June 7th 2009
Pages: 14
Views: 5
Downloads: 0
122 DECEMBER 2007 | LINUX FOR YOU | www.
linuxforu.
com
C M Y K
recently read an interesting article [C++ Report,
Vol.
6, no.
3, ‘How to write buggy programs’ by
Andrew Koenig], which is about writing incorrect
programs.
I’ve taken the following (slightly
modified) piece of code from that article to
illustrate how compiler...
More
122 DECEMBER 2007 | LINUX FOR YOU | www. linuxforu. com C M Y K recently read an interesting article [C++ Report, Vol. 6, no. 3, ‘How to write buggy programs’ by Andrew Koenig], which is about writing incorrect programs. I’ve taken the following (slightly modified) piece of code from that article to illustrate how compiler optimisers work: extern void foo(); int main() { if(0) foo(); } The foo function is just declared and is not defined in the program. The if condition always evaluates to ‘false’. Should this program link fine or result in a linker error complaining that the definition of foo is not found? That will depend on the compiler. Some smart compilers see that the statement for if(0) will never get executed, and will therefore not generate a call to foo at all—so the linker won’t complain. However, not all compilers do such smart work in default compilation mode and hence we might get a linker error. (Such compilers might detect the ‘unreachable function call’ at high
Less
From sgganesh
Adobe PDF document
Pub. on June 7th 2009
Pages: 1
Views: 5
Downloads: 0
TABLE OF CONTENTS
Class Design
1.
Provide consistent and intuitive class interface.
5
2.
Provide common properties of classes in a base class.
9
3.
Do not expose implementation details in the public interface of the class.
12
4.
Consider providing helper classes while designing large classes.
14
5.
Keep the data members...
More
TABLE OF CONTENTS Class Design 1. Provide consistent and intuitive class interface. 5 2. Provide common properties of classes in a base class. 9 3. Do not expose implementation details in the public interface of the class. 12 4. Consider providing helper classes while designing large classes. 14 5. Keep the data members private. 18 6. Provide lowest possible access to methods. 23 7. Strive for loose coupling between classes. 26 8. Beware of order of initialization problems. 29 9. Write unit tests for classes. 31 10. Avoid low-level code. 34 Object Creation and Handling 11. Avoid calling virtual functions in constructors. 37 12. Consider providing factory methods. 43 13. Make constructor private if there are only static members in the class. 45 14. Avoid creating unnecessary temporary objects. 47 15. Prefer creating immutable objects. 52 16. Consider creating and using null objects. 54 17. Provide special objects with read only access in the class itself
Less
From sgganesh
Adobe PDF document
Pub. on June 7th 2009
Pages: 3
Views: 12
Downloads: 0