Search This Blog

Friday, 27 February 2015

Flipkart Interview Experience of a Student of DA-IICT

Coding Round

First round was coding round which had two questions on interviewstreet and lasted for 1.5 hrs. Here are the questions:
  1. We are required to transport a package using trucks. We are given package size and trucksize (every truck has equal capacity). The package can be repeatedly broken into half i.e 6 cn be broker into 3-3 and 3 can be boker into 1-2. We were required to code a program which could tell the minimum amount of trucks required for given packagesize and trucksize.
  2. We are given 4 type of infinite coins. We are given value of each time. We were required to tell whether we can pay someone using these coins.

Machine Round

After coding round 50 students out of approximately 300 were selected. Then we had a 2 hr  machine coding round. In this round, a question on binary tree was given. We were required to code a lot of functionality, like finding least common ancestor etc. Following was the criteria of judging:
  1. Compilation of code
  2. Number of test cases that it passed
  3. Algorithm/Logic
  4. Code readability
I felt that the code for the problem was lengthy but was simple. Many panicked after reading the question and functionality that we were required to implement. So for this round I would advise you to code on sites like codechef, codeforces so that you can code your logic well. Also I think practicing from DSA lab questions would help a lot. Main part is to get your code to compile, as they graded only those codes which compiled. Second thing is that it might not be necessary that your code passes all test cases because if your code compiles, passes most of the test cases and if the logic is good, then you can get into the next round. I am stating this because as far as I know, only mine and Shashank Parekh’s code passed all test cases but other 13 people who got selected had their code compiled properly and were able to pass most of the test cases, and most importantly had good logic regarding problems.

Technical PI

In this round one SDE from flipkart conducted the PI. He asked two questions:
  1. Zig Zag traversal of tree
  2. Data Structure for job scheduling. The jobs had only start time and arrival time. I was able to provide a O(logn) and he seemed happy with it.

HR PI

6 people were selected for this round. An Engineering Manager took our interview. The questions were aimed at testing your personality. The questions were like why flipkart?, state one of thing you have done that you are proud of. Also, in the conversation I mentioned that I liked Digital Image Processing, so he asked me algo to segregate a particular shape. In the end 4 people were selected for the role of SDE.
I felt that process was quite easy as compared to amazon but still coding round and machine coding round tested your ability to code fast. Also, the difficulty level of the questions that were asked in technical PI was random, so if you are good at coding then only you can be sure of making it to flipkart!

What is GSoC? (Google Summer Of Code)

Hello everyone. Firstly, let me quickly introduce myself. My name is Shourya Singh Gupta and last year I did my GSoC with digiKam on this project. In this blog I will be giving some tips to get selected for GSoC. This will be helpful to those guys who are going to try to participate in GSoC this year and in the upcoming years.
If you are reading this blog, then probably you are already aware of what GSoC is. But if not, I will give a very short info about what GSoC is. The Google Summer of Code is an annual program in which Google awards stipends (of US$5,500, as of 2014) to all students who successfully complete a requested free and open source software coding project during the summer. The program invites students who meet their eligibility criteria to post applications that detail the software-coding project they wish to perform. These applications are then evaluated by the corresponding mentoring organization. Every participating organization must provide mentors for each of the project ideas received, if the organization is of the opinion that the project would benefit from them. The mentors then rank the applications and decide among themselves which proposals to accept.
Now having given a summary of GSoC, lets get back to the main problem and that is,“how to do it ?”. So the first step towards participating in GSoC and a very crucial one I suppose is selecting an organization to work with. For this you can open last year’s website of GSoC and look for organizations that require the same skill set that you possess. Here when comparing your skill set with that required by the org, its best if you have all the skills that is required by the org, but in case you have most of the skills and not all of them then do not just rule out that org. If you think you can quickly acquire those remaining skills before starting to contribute in the org, then do take that org into consideration. This is actually one of those phases in GSoC where you get to learn those tools and technologies that you do not know yet. Now after you have shortlisted the organizations that require the same skill set that you possess, its time to select that one org in which you are going to contribute and hopefully do your GSoC with. Here different people have different views, some say its better to keep contributing in different organizations because that increases your chance to getting selected in GSoC, but I personally believe that its better to channelize your entire energy into working with one org rather than trying your hands on too many things. So do not try be jack of many rather be a master of one. One more thing that you could keep in mind while finalizing your org is to check whether that org is a regular participant in GSoC or not. Some organizations are not regular participants in GSoC. So if you want to play it safe, try to choose an org that has been regularly participating in GSoC since past few years.
After having selected the org, its time to move to the second step. Now you need to download the code base of the software that you need to work on and build and install it. I am explicitly mentioning this because if the procedure to build and install your software is complex you might get various unresolved dependency errors which takes a little while to solve. I have seen people quit preparing for GSoC because they were stuck for a long time in this step and got frustated. So if you are stuck somewhere do not get disheartened. Keep trying. If you are really not able to solve it, you can also ask the lead developers of the software about how to solve the problem. They will surely help you out.
Having done this, its time to move to the third step, which is solving bugs in software and establishing a good rapport with the lead developers(your potential GSoC mentors) of the software. This is actually the step that will determine to a great extent whether you will be selected or not. So firstly, join IRC/mailing list of the software on which you are working. This will be the medium of communication between you and the lead developers of the software. You need to prove to those guys that you have the potential to successfully complete the GSoC project if its assigned to you and the best way to prove this is by fixing bugs in software. The more bugs you solve, the more confident they get about you. Also, if you get stuck somewhere while solving a bug then do not hesitate to ask them. They are not going to think that you are a fool or anything. They understand that it takes time for a beginner to get accustomed to a large code base. But ask intelligent doubts. Do your own research before asking any doubt.
By Feb end or 1st week of March, you should choose a project on which you would like to work on, from the list of ideas proposed by the organization. This is the fourth step.You need to discuss in great depth the technical details of the project with your mentor and then you need to write a proposal stating how you are going to work on this project and the timeline that you are going to follow. You should really know the details of the project in and out. This not only improves the standard of proposal you write but in fact helps you a lot when you are are actually coding in the summer for your project.
Now the fifth step is to simply sit back and relax till the results are announced  . Whether you get selected or not is another story. I think you should be proud of yourself if you have even come this far. I am pretty sure you might have gained a lot of experience by this time, which will be of great use to you. And if you are selected, then Congratulations !!! I can guarantee you one thing, seeing your name, after working so hard for it, in the list of selected students will be one of the best moments of your life. And if that’s not enough for you, you are going to get $5,500 in the next few months (I guess that’s good enough reason for any person to be overwhelmed with happiness plus a t-shirt and some cool goodies.
And lastly just a word of caution. Please do not make the mistake of not working on your project after getting selected for GSoC. There will 2 evaluations during the coding period and you need to pass both the evaluations to get the certificate of completion and the total $5,500.
So best of luck to all the aspirants !!
May the force be with you !! 

Monday, 23 February 2015

Top 16 jQuery Interview Questions Answers for JavaScript Programmers

Without a doubt, jQuery has given a much needed boost to JavaScript, a language so useful but equally underrated at times. Before jQuery comes into picture, we used to write lengthy JavaScript code not just for bigger but even for smaller functionality. Those code were at times both difficult to read and maintain. Having written JavaScript before using this excellent library, I realized true power of jQuery, just after using it for a month. Given it's huge popularity, jQuery interview questions are increasingly asked in any web developer interview, not just beginners but also experienced developers, including HTML and JavaScript. Since jQuery is relatively new, most interview questions are asked from core jQuery library including selectors, DOM manipulation and jQuery basics. In this article, I am sharing a list of 16 jQuery questions asked to HTML and JavaScript programmers in different interviews. Some of this questions also asked in Java Web development interview, where it's required to work on both Server side (Spring, Servlet and JSP) and Client side (HTML, CSS, JavaScript and jQuery). If you are going for an interview, where role demands multiple skills e.g. Java, jQuery, it's not expected from you to know every minor detail or comprehensive knowledge of jQuery, but if you are going for a purely client side development role, you might get more tricky and advanced jQuery questions than mentioned in this article. Nevertheless, you can use it to quickly revise some of the most frequently asked jQuery questions on interviews, but they are mostly suited for web developers with 2 to 5 years of experience, especially in Java stack.




jQuery Interview Questions and Answers

JavaScript is a standard for client side scripting and jQuery makes writing JavaScript much easier. You can achieve a lot more by just writing couple of lines of jQuery code. It is one of the most used JavaScript library and there is hardly any new project, which is using plain JavaScript without jQuery. What this means to you, a Java web developer is that you will bound to see couple of jQuery interview questions in Java web development interviews. Earlier it was mostly HTTP, HTML, CSS and JavaScript but now days apart from JavaScript fundamentals, people like to know whether you are familiar with jQuery or not. This list of 16 jQuery questions is prepared for web developers and can be very handy to revise key concept before telephonic or screening round of interview. If you are new to jQuery then it will also help you to understand fundamentals better and inspire you to explore more.


1. What is $() in jQuery library? (answer)

The $() function is an alias of jQuery() function, at first it looks weird and makes jQuery code cryptic, but once you get used to it, you will love it's brevity. $() function is used to wrap any object into jQuery object, which then allows you to call various method defined jQuery object. You can even pass a selector string to $() function, and it will return jQuery object containing an array of all matched DOM elements. I have seen this jQuery asked several times, despite it's quite basic, it is used to differentiate between developer who knows jQuery or not.



2. You have five <div> element in your page? How do you select them using jQuery? (answer)

Another fundamental jQuery question based on selector. jQuery supports different kinds of selector e.g. ID selector, class selector and tag selector. Since in this question nothing has been mentioned about ID and class, you can use tag selector to select all div elements.  jQuery code : $("div"), will return a jQuery object contain all five div tags.  For more detailed answer, see the article.



3. Difference between ID selector and class selector in jQuery? (answer)

If you have used CSS, then you might know the difference between ID and class selector, It's same with jQuery. ID selector uses ID e.g. #element1 to select element, while class selector uses CSS class to select elements. When you just need to select only one element, use ID selector, while if you want to select a group of element, having same CSS class than use class selector. There is good chance that, Interview will ask you to write code using  ID and class selector. Following jQuery code uses ID and class selectors :

$("#LoginTextBox")  -- Returns element wrapped as jQuery object with id="LoginTextBox"
$(".active") -- Returns all elements with CSS class active.

From syntax perspective, as you can see, another difference between ID and class selector is that former uses "#" and later uses "." character. More detailed analysis and discussion, see answer.



4. How do you hide an image on a button click using jQuery? (answer)

This jQuery interview question is based on event handling. jQuery provides good support for handling events like button click. You can use following code to hide an image, found using Id or class. What you need to know is hide() method and how to setup an even handler for button, to handle clicks, you can use following jQuery code to do that :

$("#ButtonToClick").click(function(){
    $("#ImageToHide").hide();
});

I like this jQuery question, because it's like a practical task and also code is not difficult to write.



5. What is $(document).ready() function? Why should you use it? (answer)

This is one of the most important and frequently asked jQuery Interview question. ready() function is used to execute code when document is ready for manipulation. jQuery allows you to execute code, when DOM is fully loaded i.e. HTML has been parsed and DOM tree has been constructed. Main benefit of $(document).ready() function is that, it works in all browser, jQuery handles cross browser difficulties for you. For curious reader see answer link for more detailed discussion.



6. Difference between JavaScript window.onload event and jQuery ready function? (answer)

This is the follow-up of previous jQuery interview question. Main difference between JavaScript onload event and jQuery ready function is that former not only waits for DOM to be created but also waits until all external resources are fully loaded including heavy images, audios and videos.  If loading images and media content takes lot of time that user can experience significant delay on execution of code defined in window.onload event. On the other hand jQuery ready() function only wait for DOM tree, and does not wait for images or external resource loading, means faster execution. Another advantage of using jQuery $(document).ready() is that you can use it multiple times in your page, and browser will execute them in the order they appear in HTML page, as opposed to onload technique, which can only be used for a single function. Given this benefits, it's always better to use jQuery ready() function than JavaScript window.onload event.  See answer article for more deep discussion.



7. How do you find all selected options of HTML select tag? (answer)

This is one of the tricky jQuery question on Interviews. It's still a basic, but don't expect every jQuery beginners to know about this. You can use following jQuery selector to retrieve all selected options of <select> tag with multiple=true :

$('[name=NameOfSelectedTag] :selected')

This code uses attribute selector in combination of :selected selector, which returns only selected options. You can tweak this and instead of name, you can even use id attribute to retrieve <select> tag.



8. What is each() function in jQuery? How do you use it? (answer)

each() function is like Iterator in Java, it allows you to iterate over a set of elements. You can pass a function to each() method, which will be executed for each element from the jQuery object, on which it has been called. This question sometime asked as follow-up of previous question e.g. how to show all selected options in alert box. We can use above selector code to find all selected option and than further can use each() method to print them in alert box, one by one, as shown below:

$('[name=NameOfSelectedTag] :selected').each(function(selected){
        alert($(selected).text());
});


text() method returns text for that option.



9. How do you add an HTML element in DOM tree? (answer)

You can use jQuery method appendTo() to add an HTML element in DOM tree. This is one of the many DOM manipulation method jQuery provides. You can add an existing element or a new HTML element, appendTo() add that method in the end of a particular DOM element.



10. Can you write jQuery code to select all links, which is inside paragraphs? (answer)

Another jQuery interview question based on selector. This also required to write jQuery one liner, like many other questions. you can use following jQuery snippet to select all links (<a> tag) nested inside paragraphs (<p> tag).



11. Difference between $(this) and this keyword in jQuery? (answer)

Could be a tricky questions for many jQuery beginners, but indeed it's simplest one. $(this) returns a jQuery object, on which you can call several jQuery methods e.g. text() to retrieve text, val() to retrieve value etc, while this represent current element, and it's one of the JavaScript keyword to denote current DOM element in a context. You can not call jQuery method on this, until it's wrapped using $() function i.e. $(this).



12. How do you retrieve attribute of an HTML tag using jQuery e.g. href of links? (answer)

attr() method is used to retrieve value of an attribute of any HTML element. You first need to select all links or specified links using jQuery selector and than you can apply attr() method to get value of there href attribute. Below code will find all links from a page and return href value :

$("a").each(function(){
   alert($(this).attr('href'));
});



13. How do you set attribute using jQuery? (answer)

One more follow-up question of previous jQuery question, attr() method is overload like many other methods in JQuery. If you call attr() method with value e.g. attr(name, value), where name is the name of attribute and value is the new value.



14. What is difference between detach() and remove() method in jQuery? (answer)

Though both detach() and remove() method is used to remove a DOM element,Main difference between them is that detach() keep track of the last element detached, so that it can be reattached, while remove() method does keep reference of last removed method. This is one of the many jQuery interview question from DOM manipulation. You can also take a look on appendTo() for adding element into DOM.



15. How do you add and remove CSS classes to an element using jQuery? (answer)

By using addClass() and removeClass() jQuery methods. This can be very handy, while dynamically changing class of elements e.g. marking them inactive or active and using class ".active" etc.



16. What is main advantage of loading jQuery library using CDN? (answer)

This is slightly advanced jQuery question, and don't expect that jQuery beginners can answer that. Well, apart from many advantages including reducing server bandwidth and faster download, one of the most important is that, if browser has already downloaded same jQuery version from same CDN, than it won't download it again. Since now days, almost many public websites use jQuery for user interaction and animation, there is very good chance that browser already have jQuery library downloaded. Curious reader, please see the answer for in depth analysis.

Good jQuery Interview Questions with Answers


That's all on this list of 16 jQuery interview questions and answers for beginners. As I said already, these questions are pretty basic, but most likely asked to web developers including Java. For an Interviewer, you can use this question to check if candidate has really used jQuery or not. Since an Interview for a client side position almost always contains loads of questions from HTML, CSS and JavaScript, you got to prepare that as well, along with jQuery questions. By the way, if you have faced any other question on jQuery interviews and wants to share with us, you can do so by commenting in this article. You can also asked any jQuery question, asked to you on interviews.

Saturday, 21 February 2015

Scala vs Java - Differences and Similarities

Scala is new generation JVM language, which is generating popularity as alternative of arguable one of the most popular language Java. It's not yet as popular as Java, but slowly getting momentum. As more and more Java developers are learning Scala and inspired by Twitter, more and more companies are using Scala, it's future looks very bright. To start with, Scala has several good feature, which differentiate it from Java, but same time it has lot of similarities as well e.g. both Scala and Java are JVM based language, You can code Scala in Java way and Scala can use any Java library, which in my opinion a great decision made by designers of Scala. Since tremendous works has already been done in form of open source framework and library in Java, it's best to reuse them, rather than creating a separate set for Scala. Out of several differences, one of the main difference between Scala and Java is it's ability to take advantage of Functional programming paradigm and multi-core architecture of current  CPU. Since current CPU development trend is towards adding more cores, rather than increasing CPU cycles, it also favors functional programming paradigm. Though this differences may not be significant, once Java 8 will introduce lambdas, but it might be too early to comment. Apart from functional programming aspect, there are many other differences as well. One of the obvious one is improved readability and succinct code. Java is always on firing line for being too verbose, I thing Scala does take care of that and code which took 5 to 6 lines in Java, can be written in just 2 to 3 lines in Scala. Well Grounded Java Developer has some nice introduction on JVM languages like Scala, Groovy and Closure, which is worth reading.  In this article, we will see such kind of similarities and differences between Scala and Java.




Similarities between Scala and Java

Following are some of the major similarities between Scala and Java programming language :

1) Both are JVM based language, Scala produce same byte code as Java and runs on Java Virtual Machine. Similar to Java compiler javac, Scala has a compiler scalac, which compiles Scala code into byte code. At this level, all JVM language like Groovy, JRuby, Scala becomes equals to Java, because they use same memory space, type system and run inside same JVM.

2) You can call Scala from Java and Java from Scala, it offers seems less integration. Moreover, you can reuse existing application code and open source Java libraries in Scala.

3) Major Java programming IDE like Eclipse, Netbeans and InetelliJ supports Scala.

4) One more similarity between Scala and Java is that both are Object Oriented, Scala goes one steps further and also supports functional programming paradigm, which is one of it's core strength.

Differences between Scala and Java

1) First and Major difference you will notice between Scala and Java is succinct and concise code. Scala drastically reduce number of lines from a Java application by making clever use of type inference, treating everything as object, function passing and several other features.

2) Scala is designed to express common programming patterns in elegant, concise and type-safe way. Language itself encourage you to write code in immutable style, which makes applying concurrency and parallelism easily.

3) One difference, which some might not notice is learning curve. Scala has steep learning curve as compared to Java, my opinion may be slightly biased because I am from Java background, but with so much happening with little code, Scala can be really tricky to predict. Syntax of Scala looks confusing and repulsive as compared to Java, but I am sure that is just the starting hurdle. One way to overcome this hurdle is following a good Scala book like  Programming in Scala or Scala in Action, both are excellent books for a Java developer, who wants to learn Scala

4) One of Scala's cool feature is built-in lazy evaluation, which allows to defer time consuming computation, until absolutely needed and you can do this by using a keyword called "lazy" as shown in below code :
 
// loading of image is really slow, so only do it if need to show image
lazy val images = getImages()  //lazy keyword is used for lazy computation
if(viewProfile){
    showImages(images)
}
else(editProfile){
    showImages(images)
    showEditor()
}
else{
    // Do something without loading images.
}

If you love to learn by following examples, then I guess Scala CookBook is a another good buy, contains tons of examples on different features of Scala.

5) Some one can argue that Java is more readable than Scala, because of really nested code in Scala. Since you can define functions inside function, inside another functions, inside of an object inside of a class. Code can be very nested. Though some time it may improve clarity, but if written poorly it can be really tricky to understand.

6) One more difference between Scala and Java is that Scala supports Operator overloading. You can overload nay operator in Java and you can also create new operators for any type, but as you already know, Java doesn't support Operator Overloading.

7) Another major difference between Java and Scala is that functions are objects in Java. Scala treats any method or function as they are variables. When means, you can pass them around like Object. You might have seen code, where one Scala function is accepting another function. In fact this gives the language enormous power.

8) Let's compared some code written in Scala and Java to see How much different it look:


Java:
List<Integer> iList = Arrays.asList(2, 7, 9, 8, 10);
List<Integer> iDoubled = new ArrayList<Integer>();
for(Integer number: iList){
    if(number % 2 == 0){
        iDoubled.add(number  2);
    }
}
Scala:
val iList = List(2, 7, 9, 8, 10);
val iDoubled = iList.filter(_ % 2 == 0).map(_  2)

You can see that Scala version is lot succinct and concise than Java version. You will see more of such samples, once you start learning functional programming concepts and patterns. I am eagerly waiting for Scala Design Patterns: Patterns for Practical Reuse and Design by John Hunt, which is not yet released and only available for pre order. This book is going to release this month.


That's all on this article about similarities and differences between Scala and Java.  Though they are two separate programming language, they have lot in common, which is not a bad thing at all and in my opinion that's the only thing, which will place Scala as Java alternative, if at all it happens in future. As I had mentioned in my post 10 reason to learn Java programming, that Java tools, libraries, and community is it's biggest strength and if Scala can somehow reuse that, it will be well ahead, forget about competing though, it will take years to build such community and code. For a Java programmer, I would say nothing harm in learning Scala, most likely you will learn few good practices, which you can even apply in Java, as corporate sector is still on Java, and Scala in it's early days, you can be well ahead, if you learn Scala now. On closing note, at high  level Scala looks very promising, all design decision made are really good and they came after several years of experience with Java.


Recommended Books on Scala for Java Programmers

Books are best way to learn a new programming language, first of all they contains complete information but also in much more readable and authentic form. I strongly recommend to follow at-least one book, before jumping on blogs and online articles. One reading any Scala Programming book is must to build fundamental, which is indeed necessary, given rather steep learning curve of Scala. Following are my list of some books from which you can choose one.

Programming in Scala: A Comprehensive Step-by-Step Guide, 2nd Edition by Martin Odersky, Lex Spoon and Bill Venners
Scala for the Impatient by Cay S. Horstmann
Scala in Depth by Joshua D. Suereth and Martin Odersky

Arraylist vs Vector in Java

1.  Synchronization and Thread-Safe

Vector is  synchronized while ArrayList is not synchronized  . Synchronization and thread safe means at a time only one thread can access the code .In Vector class all the methods are synchronized .Thats why the Vector object is already synchronized when it is created .

2.  Performance

Vector is slow as it is thread safe . In comparison ArrayList is fast as it is non synchronized . Thus     in ArrayList two or more threads  can access the code at the same time  , while Vector is limited to one thread at a time.

3. Automatic Increase in Capacity

A Vector defaults to doubling size of its array . While when you insert an element into the ArrayList ,      it increases
its Array size by 50%  .


By default ArrayList size is 10 . It checks whether it reaches the       last  element then it will create the new array ,copy the new data of last array to new array ,then old array     is garbage collected by the Java Virtual Machine (JVM) .

4. Set Increment Size

ArrayList does not define the increment size . Vector defines the increment size .

You can find the following method in Vector Class

public synchronized void setSize(int i) { //some code  }

There is no setSize() method or any other method in ArrayList which can manually set the increment size.

5. Enumerator

Other than Hashtable ,Vector is the only other class which uses both Enumeration and Iterator .While ArrayList can only use Iterator for traversing an ArrayList .

6.  Introduction in Java

java.util.Vector  class was there in java since the very first version of the java development kit (jdk).
java.util.ArrayList  was introduced in java version 1.2 , as part of Java Collections framework . In java version 1.2 , Vector class has been refactored to implement the List Inteface .

Friday, 20 February 2015

10 Articles Every Programmer Must Read

Being a Java programmer and Software developer, I have learned a lot from articles titled as What Every Programmer Should Know about ..... , they tend to give a lot of useful and in-depth information about a particular topic, which otherwise is very hard to discover. In my quest of learning I have come across some very useful articles, which I have bookmarked for reference and multiple reading. I personally think that all programmer can benefit by reading these articles, which makes me write this post and share all of these "What Every Programmer Should Know" articles with you guys. These are from my personal bookmarks. In this article, you will see classic what every programmer should know article from topics like memory, Unicode, floating point arithmetic, networking, object oriented design, time, URL Encoding, String and many more. This list is very important for beginner and newcomers, as they are the ones, who lacks practical knowledge. Since most of these post are actually driven by practical knowledge, beginner and intermediate programmers can take a lot from it. Also gaining knowledge of fundamentals early in career helps to avoid mistakes, which has done by other programmers and software developers on their course of learning. Though it’s not easy to grasp all knowledge given in these articles in just one reading. You probably won't understand some details about floating point number or get confused with subtle details of memory, but it’s important to keep these list handy and refer them time to time with a context. So Good luck and Enjoy reading these wonderful articles.  By the way, don't forget to share any What Every Programmer Should know article, if it’s not already in this list.


What Every Programmer Should Know about Memory
This is one of the classic article, which will take you through may lanes of memory, some old, some new, some known and some unknown. Despite being so conman and omnipresent, not every programmer have enough knowledge of Memory. Knowledge of memory in modern system becomes even more important if you are in space of writing high performance application. Hardware designers have come up with ever more sophisticated memory handling and acceleration techniques–such as CPU caches–but these cannot work optimally without some help from the programmer. I am still reading this article, and I can't tell you how much I have learned from this about RAM, CPU Caches e.g. L1 and L2 cache, different types of memory, direct memory access, memory controller designs and Memory in general. In short, a must read for programmers of all level of experience.


What Every Computer Scientist Should Know About Floating-Point Arithmetic
Floating point arithmetic is a tricky topic, and it’s not easy to master. Even many Java programmer doesn't know what can go wrong when comparing float/double value with == operator. Many of us often makes mistake of doing monetary calculation in float and double. This article is another gem of this series and must read for all software developers and programmers. As your experience grows, you are expected to know subtle details of common things, and floating point arithmetic is one of them. As as senior Java developer, you must know how do perform monetary calculation, when to use float, double or BigDecimal classes, how to round floating point numbers etc. Even if you know fundamentals of floating point arithmetic, You will learn something new about floating point calculation by reading this article.


What Every Developer Should know about Unicode
Character encoding is another area, where many programmer struggle, and "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)" aims to fill that gap. On side note, Yes that's the full title of that article. It was written by Joel Spolsky, one of the founder of statckoverflow.com. Joel has written this post on his blog almost 10 years back, but it is still relevant in today’s world. This article will teach you about What is Unicode, What is character encoding, how characters are represented using bytes and many more. One of the best thing about this article is language and flow, even if you don't know anything about Unicode, you can easily follow. In short, one more must read for all programmers, coders and software engineers.


What Every Programmer Should know about Time
Apart from Character encoding, time and date is another area, where many programmers struggle, including me. Even senior developers lost between GMT, UTC, day light saving and between leap seconds. Frankly speaking, It's not easy to deal with time zones without making any mistake, then add day light savings and effect of that. Problems becomes worse if you using trial and error method, because you will never able to solve your problem by doing that. There are so many things which can go wrong and there are equal number of misconceptions. Things like, whether date contains time-zone or not can confuse you like hell, converting UNIX time to other time-zone can freak you out, forget about clock synchronization and delays. I hope many of your misconception about time will go away and you will build sound fundamental about Time, by reading this classic article.


What every web developer must know about URL encoding
This article describes common misconceptions about Uniform Resource Locator (URL) encoding, then attempts to clarify URL encoding for HTTP, before presenting frequent problems and their solutions. While this article is not specific to any programming language, it illustrate the problems in Java) and finish by explaining how to fix URL encoding problems in Java, and in a web application at several levels. You will learn basics of URL grammar, general URL syntax in HTTP and other protocol. This article also explores common pitfalls of URLs e.g. character encoding, reserved character at different part of URL, and URL encoding/decoding issues. If you are a Java programmer, then you will also learn about how to handle URLs in Java application, the right way. How to construct URL and using Apache commons HTTP client library. Finally it also suggest best practices or dealing with URLs e.g. you should encode URLs when you build them, making sure your URL-rewrite filters deal with your URL correctly and many more. In short, a must read article for any web developer and programmer.



What should every programmer know about web development?
What Every Programmer and Devleper Should know Memory, Time, Date, String,UnicodeThis is an interesting article from programmers stack exchange, about what should every programmer implementing the technical details of a web application consider before making the site public. This includes things ranging from Interface design and User Experience, Security, Web standards, Performance, Search Engine Optimization(SEO), Technology involved, and about several important resources. Since today's world is hugely dependent upon internet and programmer having their personal site, blog is quite common. Experience learned on this article will not even help in your professional work but also in your personal work. You will learn about all key technology e.g. HTTP, HTML, XML, CSS, JavaScript, browsers compatibility, tips to reduce loading time of your website, XML sitemaps, W3C specifications and several other key details.


What Every Programmer Should Know About SEO
This is another article, which is very important for web developers, programmers and blogger. SEO is too big to ignore, since many programmers are also blogger, it’s important to learn few basics of Search Engine Optimization to help Google find their content and present to other fellow programmers. Since no company can survive without web presence in today's inter-connected world, SEO becomes even more important. If you own start-up, selling any product, then SEO is something to care about. All programmers, especially web developers can largely benefit from this article. Remember, Search Engine Optimization is vast and very dynamic subject, and also varies between different search engines e.g. Google, Yahoo, and others. So, In order to master this topic you will always need to update your knowledge.


What Every C Programmer Should Know About Undefined Behaviour #1/3
C programming language have the concept of "undefined behaviour". Undefined behaviour is a broad topic with a lot of nuances and that's one reason of Why I like Java, less number of undefined behaviour, less confusion, more stability and more peace. Many seemingly reasonable things in C actually have undefined behaviour, and this is a common source of bugs in programs. Beyond that, any undefined behaviour in C gives license to the implementation (the compiler and runtime) to produce code that formats your hard drive, does completely unexpected things, or worse. Read this excellent article to deep dive on sea of undefined behaviour


What Every Programmer Need to know about networking
From the article itself "You’re a programmer. Have you ever wondered how multi-player games work? From the outside it seems magical: two or more players sharing a consistent experience across the network like they actually exist together in the same virtual world. But as programmers we know the truth of what is actually going on underneath is quite different from what you see. It turns out that it’s all an illusion." This is very interesting article about networking, written for game programmers but I think every programmer and developer can benefit from this.


What Every Java Developer Should Know about String
This is my article on java.lang.String and what I personally thing every Java programmer should know about it. String is very important in day to day programming in Java and that's why good knowledge is must for any Java developer. This article touches many important areas of String including string pool, string literal, comparing String using == vs equals(), converting bytes to String, Why String is immutable, properly concatenating Strings and many more. Advanced programmer may already know all these stuffs but even then it’s good to revise them.


What should every programmer know about security?
This question was ask by one computer programming student in StackOverFlow. Just like we learn a lot about general programming concepts e.g. operating system, algorithm, data-structure, computer architecture, and other stuff, its also important to know about security. Though Security is vast topic ranging from encryption/decryption, SSL, web security, obfuscation, authentication, authorization etc, a basic minimum knowledge is must for every programmer. I personally didn't know much about Security when I started my career, its when I start writing Servlet/JSP based Java web application, I come to know about web security and several security threats like SQL Injection, Denial of Service, XML Injection, Cross site scripting and others. As Java developer, now I follow secure Java coding practices provided by fortify, PMP and other static code analysis providers.  This article is very good collection of topics and links about Security and whether you are doing coding or not, you will surely benefit from this resource.


Latency Numbers Every Programmer Should Know
This is the bonus article, but must read for every Programmer. In order to write high performance application in any programming language e.g. Java or C++, you ought to know fundamental latency numbers e.g. how much time it take to read a variable from memory, from L1 Cache, from L2 cache, from random read in SSD and from disk. How much time it take to lock unlock on mutex, to send a data packet from one city to another or doing a roundtrip on same data centre. These latency numbers are independent of any programming language and part of core knowledge, a developer must have to write high frequency low latency applications. Good thing about this link is that it also provides you comparative analysis of how these latency numbers have evolved over the years. You can see what these latency numbers were in 2006 and what they are now.


That's all in this list of article every Programmer must read. By reading articles titles as What Every Programmer or Developer Should know, you gain in-depth knowledge of a particular topic. Frankly speaking there are too many things to learn for programmers, learning a programming language like Java is just a tip of iceberg, but isn't it many of us have passion for learning. Programming is a challenging job, and only things which help you all along your career is fundamental knowledge e.g. things about Memory, Unicode, floating point numbers, time, security is very important for any programmer. Few things are programming language specific e.g. my post about Java String and What every C programmer should know about undefined behaviour, but they are still good to learn for many beginner and developers.


Introduction of How Android Works for Java Programmers

Android development is current buzz in Java programming world. It's the Android, which keeps Java in the fore front from last couple of years. Now, How important is to understand or learn Android for Java programmers? Well it depends, if you like application development and want to reach mass, Android offers that opportunity to you. Millions of Android phones are available and they are keep increasing, with pace, much higher than IPhone or iOS. What all these means is, it does make a lot of sense to learn Android programming for Java programmer, and this article is about that, but this is also a one of the  good reason to learn Java programming. This tutorial will give you basic idea of How Android works? not detailed but a good overview. One distinct advantage Java programmers has over others is that Android API is much like Java API, though Android doesn't support all classes available in J2SE SDK, it supports critical ones. Another advantage is that, you can use same tools e.g. IDE like Eclipse to develop Android applications, Google provides Eclipse plug-in for Android development. On opposite, if you want to go for  iOS development, A steep learning curve with Objective C and iOS SDK waits you. I think it make more sense for a C++ programmer to do Objective C and iOS, than a Java Programmer. So classic battle of Java vs C++ still continues with Smartphone application development. Any way, let's come to the topic of How Android works internally. . If you are looking for some good books to start with Android, you can also check out Professional Android 4 Application Development and Ian F. Darwin’s Android Cookbook.

How Android works

How Android works , app runs on device from Java programmersAs I said Android uses Java for application development. So you can code your Android apps using Java API provided by Google, and it compiles into class files. Similarity ends here, Android doesn't use Java Virtual machine (JVM) for executing class files, instead it uses Dalvik virtual machine, which is not a true JVM and doesn't operate on Java byte code. In order to run on Dalvik Virtual machines, class files are further compiled into Dalvik Executable or DEX format. After conversion to DEX format, class files along with other resources are bundled into Android Package (APK) for distribution and installation into various devices. Key thing to know is that, Dalvik VM is based on subset of the Apache Harmony Project for its core class library, which means it doesn't support all J2SE API. If you are using Eclipse IDE for coding Android Apps, then you don't need to worry much because, it will help you with code completion. Now let's see How Android Application runs on device?


How Android apps runs on Device

If you are familiar with Linux and concept of process, then it's easy to understand how android applications runs. By default, Each Android application is assigned a unique user id by the Android operating system. After starting android application, they run on there own process, inside there own virtual machine. Android operating system manages starting and shutting down the application process, whenever required. This means, each android application runs in isolation with other, but they can certainly request access to hardware and other system resources. If you are familiar with mobile application development, may be in J2ME, then you may know about permissions. So when an android application is installed or started, it request necessary permission required to connect internet, phone book and other system resource. User explicitly provides grant these permissions, or it may deny. All these permissions are defined in manifest file of Android application. Unlike Java Manifest file, Android manifest is an XML file, which lists all the components of apps, and settings for those components. Four major components of Android application development is Activities, Services, Content Providers and Broadcast Receivers. Activity is most common of them, as it represent a single screen in Android Application. For example, in an Android Game, you can have multiple screens for login, high score, instructions and game screen. Each of these screen represent different Activities inside your app. Similar to Java, good thing about Android is that it manages certain task on behalf of developer, one of them is creating activity object. Activities are managed by System, when you want to start an activity, you call startActivity() method which takes an Intent object. In response to this call, System can either create new activity object or reuse an existing one. Just like Garbage collection in Java, manages a critical task or reclaiming memory, Android manages starting, stopping, creating and destroying of apps by themselves. You may think it's restrictive, but it's not. Android provides life-cycle events, which you can override to interact with this process.

That's all on How Android works.  Android is definitely worth learning for Java programmer, as it uses Java, you can reuse your existing knowledge of Java programming techniques, design patterns and best practices to code a good android app. Of course, you need to adapt some Android specific things like, but those will come along. So, what are you waiting for, go and explore more about Android and write an Android HelloWorld application. Finally you can also take a look some of the best book to start with Android development, Professional Android 4 Application Development and Android Cookbook by Ian F. Darwin.

Blog Archive