Friday, 24 October 2014

10 Online Coding Contests For Programmers!

Be Unique:--

If you think you have the best coding skills in the town or if you are a starter and you are willing to practice your coding and compete against the very best of coding, then you are reading the right article! Here we bring to you 10 online programming contests, where coders from all around the world compete.
programming, Programming languanges, coding, programming competion, programming contests, coding contests, coding competitions, developers, coders, Job for developers,

These sites have their sets of practice problems, practice sessions and competition rounds. Major of the competitions are sponsored by some big shot companies and they also keep a keen eye on the contests, so who knows you might just one lucky person to be selected for a big internship or for a big job. Some of these competitions are held on weekly, monthly or yearly basis where as others have specific dates for competitions. 

GoogleCode Jam:-
That's a wrap. The eleventh annual Code Jam Finals wrapped up in Los Angeles, CA ..

Topcoder

TopCoder is indeed the world’s largest competitive software development community where developers from all over the world take part in. The community offers timed programming competitions in various categories like algorithms, testing, design, assembly, SRM, marathon and many others. The competition is sponsored by big names like Microsoft and the NSA and they offer cash prizes for the winners. Solutions can be submitted in Java, C++, C#, or VB.

CodeChef

CodeChef is a non-commercial organization operated by DirectI, an Indian software company based in Mumbai, India. It is a global programming community which hosts online contests, trainings and events for programmers from around the world.

Sphere online judge (SPOJ)

Sphere online judge is one of the earliest competitions, with support for more than 40 programming languages and compilers. The SPOJ platform has been created around an online judge system, which serves for the automatic assessment of user-submitted programs.

CodingBat

CodingBat is a live coding site, which offers problems to build coding skills in Java and Python. The problems here provide instant feedback which also works as a brilliant platform for the coders to practice and grasp the basics of programming.

Google Code Jam

Google Code Jam is an annual programming competition sponsored and supported by Google itself. Here, professional and student programmers provided complex algorithmic challenges to solve using the programming language of their choice in a limited amount of time.

Dream in Code

Dream In Code (DIC) is a online community for programmers and web developers. Members have free access to thousands of programming tutorials, code snippets, forum topics and more.

Codeforces

Codeforces is an online programming platform where you can practice variety of problems and submit competitive ones and compete on problems submitted by other users.

UVa Online Judge

This online coding site is maintained by University of Valladolid, Spain. Here you can find problems from past programming contests such as the ACM International Programming Contest and also one can submit their own source codes in a variety of languages.

Python Challenge

Focused on the Python programming language, Python Challenge is a series of programming challenges. Although any language could be used to solve the puzzles, many of the clues are easier to decipher if you’re working in Python.

Facebook Puzzles

As the name suggests this small set of programming problems is conducted by Facebook to evaluate potential hires. One can submit their solutions in a variety of languages like C++, C, Haskell, Java, Perl, PHP, Python, or Ruby.

ACM-ICPC

ACM – ICPC is one of the world’s largest programming contest conducted annually. The contest is basically sponsored by IBM for teams of students. The contests majorly involves algorithmic programming problems. Regional contests lead to World level Finals. Supports only two languages i.e. C/C++ and Java.

Wednesday, 22 October 2014

Best Java Developer's Blogs


This list collects 100 high quality blogs from Java developers from all over the world. Some of these blogs may not be written by Java developers, but at least Java developers should find it useful or interesting. Reading those blogs should be fun and often bring some fresh ideas.
Google ranks large websites higher. That is not so fair for small high-quality blogs. There are a lot of sites that have very large traffic, but they may not have high quality. My definition of high quality is as follows
Name(Site/People)CountryKey Words
1Adam BienGermanyJava EE
2Antonio GoncalvesFranceAuthor of Java EE 7
3Henrik WarneSwedenThoughts on programming
4Billy YaroshAmericaCoding Cures
5Lars VogelGermanyAndroid and Eclipse
6Peter VerhasHungaryPure Java
7Martin FowlerAmericaAuthor, Speaker
8Bozhidar BozhanovBulgariaJEE
9Richard WarburtonUKJava 8 Lambdas
10Bear GilesAmericaJEE
11Marginally InterestingGermanyMachine Learning
12Pascal AlmaAmericaJEE
13Dror HelperAmericaConsultant
14Juri StrumpflohnerItalyJavaScript
15Reza RahmanAmericaJava EE/Glassfish
16Phil WhelanCanadaWeb
17Brett PorterAustraliaCo-author of Apache Maven 2
18Ben McCannAmericaCo-founder at Connectifier
19Java PosseAmericaSome useful links
20Mark NeedhamUKData
21Iris ShoorIsraelDebug
22Yifan PengAmericaGraduate Student
23Nikita Salnikov TarnovskiEstoniaMemory Leaks
24Dustin MarxAmericaActual Events
25Bart BakkerNetherlandAgile
26Gunnar PeipmanAmericanon-java
27Dave FecakAmericaJob Tips for Programmers
28JOOQSwitzerlandSQL
29Petri KainulainenFinlandWeb
30Informatech CRCosta Rica
31Arun GuptaAmericaJava EE
32Mechanical SympathyUKPerformance
33Extreme EnthusiasmItalyAgile
34Steve BlankAmericaAuthor of The Startup Owner's Manual
35Oliver GierkeGermanySpringSource
36Nicolas FränkelSwitzerlandJava EE
37Blaise DoughanAmericaXML and JSON
38Vlad MihalceaRomaniaSoftware Integration
39Kevin LeeAustraliaWeb
40Mikhail VorontsovAustraliaPerformance
41Jakob JenkovDenmarkSoftware Architecture
42Jim WeaverRich Client Java
43Jonathan GilesNew ZealandJava FX
44Stephen ChinAmericaJava FX
45Matt RaibleAmericaOpen Source Frameworks
46Peter LawreyUKCore Java
47Gregor RieglerAustriaOO Design, XP
48Jos DirksenNetherlandsSOA, HTML 5
49Alexander J. TurnerUKInformation, News And Views
50Java Advent
51John PurcellHungaryTutorials
52Transylvania JUGUK
53Java RootsSpring
54Java TrainingGreecetraining
55Allan KellyUKSoftware
56Samuel SantosPortugalJava EE
57Steve SmithUKAgile
58Niklas SchlimmGermanyMultithreading
59Shrutarshi BasuAmericaPhD, Computer Science
60Anton ArhipovEstoniaJava EE
61Charles NutterAmericaJVM
62RedStackAmericaSOA, JVM
63James BloomAmericaJVM
64Pierre-Hugues CharbonneauCanadaJava EE
65Eugen ParaschivRomaniaJava Web
66Wayne BeatonAmericaEclipse
67Jeff AtwoodAmericaStack Overflow
Program CreekAmericaDeep Understanding of Java Core-------------



Tuesday, 21 October 2014

18 Top Tools for Java developers

shutterstock_124013509_javagears

t’s as true for Java developers as it is for woodworkers: You can’t do the job right without the right tools. Fortunately, there are plenty of Java tools designed to make it significantly simpler to write good Java code — and help you make your Java code even better.
You’ll probably know many of the tools on this list of 18 choices, but others may be new to you. And odds are you haven’t tried them all yet!
  1. GradleBuild tool. Automates the building, testing, publishing, deployment, and more of software as well as generating static websites or documentation.
  2. EclipseOpen-source integrated development environment (IDE). If you could have just one tool for Java development, Eclipse would be a good choice.
  3. IntelliJIDE made by JetBrains, available in an Apache 2-licensed community edition and a commercial edition. IntelliJ provides similar features to Eclipse, with a smooth, developer-friendly experience.
  4. YourKitJava profiler. Combines powerful analysis capabilities, on-demand profiling during both development and production, free embedding into production, and seamless IDE and application server integration.
  5. Clover: Code coverage tool from Atlassian. Runs in your IDE or continuous integration system, and includes test optimization to make tests run faster and fail sooner.
  6. MockitoMock library. Open-source testing framework that enables the creation, verification, and stubbing of mocks.
  7. Jetty: Lightweight, embeddable app server.
  8. Hibernate: Object-relational mapper. Implements the Java persistence API.
  9. VisualVMJVM monitor. An all-in-one Java troubleshooting tool that comes with the JDK.
  10. JUnit: Unit test framework. Core tool of test-driven development that enables repeatable, white-box testing.
  11. Jenkins: Continuous integration tool. Customizable with more than 600 plugins.
  12. Spring Boot: Spring application development system. Works in your build system. Supports Gradle and Maven.
  13. Guice: Lightweight dependency injection/inversion of Control (IoC) framework, from Google.
  14. Guava: Utility library. Contains core libraries that Google relies on in Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth.
  15. FindBugs: Static code analyzer. Classifies potential errors in code as scariest, scary, troubling, or “of concern.” Available as a standalone GUI or as a plugin for Eclipse, NetBeans, IntelliJ, Gradle, Hudson, and Jenkins.
  16. Jackson: JSON parser. Aims to be fast, correct, lightweight, and ergonomic for developers.
  17. Snappy:Compression/decompression library from Google Code. A great resource when speed is a requirement.
  18. JD-GUI: Decompiler. Standalone graphic utility that displays source codes of “.class” files. Free for non-commercial use (i.e., can’t be included or embedded in commercial products).

Guidelines must be followed by a Java Developer.


Every java developer has to follow some standards to develop a good quality-software. In the Coding standards Oracle(Sun) has given some set of rules in java  and the developers must follow.Standards lead to consistency and help software engineers avoid common problems. A development environment that uses Java standards has the following advantages:
  1. Developers can view any Java software and quickly figure out what is going on.
  2. Developers new to Java are spared the need to develop a personal style.
  3. Developers make fewer mistakes in consistent environments.
  4. Discussions about the appropriateness of a language feature are reduced at code reviews.
The List of Guidelines given below.

Rule 1  Always place the public class or interface in a file as the first class.
Rule 2  Always use explicit import statement.
Rule 3  Do not use numbers as words in names.
Rule 4  Do not capitalize any letter other than the first for all words in a name.
Rule 5  Use full English descriptors that accurately describe the variable/field/class/interface. For example, use names like firstName, grandTotal, or CorporateCustomer.
Rule 6  Do not remove letters from words, except to create standard short forms.
Rule 7  Do not use the long form of a word when a standard short form exists.
Rule 8  Always include units in a name when the name refers to an entity with units.
Rule 9  Do not use acronyms in names unless the acronym is industry-standard or is defined in user documentation.
Rule 10  Always treat acronyms as words when applying other naming rules.
Rule 11  Always capitalize the first letter of class name.
Rule 12  Do not include any prefix or suffix to indicate that a name is for any specific type.
Rule 13  Do not include anything in a name to indicate that the name is for a class.
Rule 14  Do not include underscores in names, except after a member’s prefix.
Rule 15  Do not pluralize type names except collections.
Rule 16  Use abbreviations sparingly, but if you do so then use then intelligently and document it
For example, to use a short form for the word “number”, choose one of nbr, no or num.
Rule 17  Always start a method name with a lowercase letter.
Rule 18  Always start method names with a verb.
Rule 19  Always use the following verb opposite pairs when methods perform opposite actions.
Rule 20  Always use the method caller as the frame of reference.
Rule 21  Always include a prefix on field names.
Rule 22  Always ensure that the first letter after a field’s prefix is in lowercase.
Rule 23  Always include white space between a keyword and an open bracket when the keyword occurs first.
Rule 24  Always include white space before and after binary arithmetic, equality, relational, logical, assignment, and bitwise operators.
Rule 25  Do not include white space between a unary operator and its operand.
Rule 26  Do not include white space before the open bracket in a method declaration, method call, open array subscript, or indexer.
Rule 27  Always include white space after a comma.
Rule 28  Always include white space after a semicolon in loop control statements.
Rule 29  Always indent new scope three additional spaces.
Rule 30  Do not use tabs.
Rule 31  Do not ignore checked Exceptions
Rule 32  Always indent the second line and subsequent lines of a multi-line statement an additional six spaces from the first line.
Rule 33  Always break each line of a multi-line statement immediately following a comparison operator.
Rule 34  Always put braces around statement blocks of control statements even if the block is empty or a single line.
Rule 35  Always align an opening brace immediately under the first character of the corresponding keyword.
Rule 36  Always align braces vertically.
Rule 37  Do not nest if/else statements more than 3 levels deep
Rule 38  Do not include more than one statement per line.
Rule 39  Do not include more than one variable declaration per line.
Rule 40  Do not use brackets when a return statement returns a simple value.
Rule 41  Always put every element in an enum definition on a separate line.
Rule 42  Always include a comma after the last value in an enumerated type declaration.
Rule 43  Always indent the case keyword three additional spaces from the corresponding switch statement.
Rule 44  Always comment intentional fall throughs.
Rule 45  Always indent comments at the same level of indentation as the software being documented.
Rule 46  Do not use end-of-line comments.
Rule 47  Always indent end of line comments 3 characters beyond the last character in a statement.
Rule 48  Do not vertically align end-of-line comments.
Rule 49  Do not create methods with more than seven parameters.
Rule 50  Always document restrictions on method parameters
Rule 51  Always check parameters for validity.
Rule 52  Always use exceptions when an invalid parameter is found in a non-private method.
Rule 53  Always use assertions with information expressions to check for invalid parameters private methods.
Rule 54  Do not place a return statement anywhere except as the last line of a method.
Rule 55  Do not use a return statement in a method that returns void.
Rule 56  Do not use a method's return value to indicate that an unexpected error occurred in the method.
Rule 57  Do not make any member variables public.
Rule 58  Always declare fields before methods or constructors in a class
Rule 59  Always order field declarations based on their access specifier
Rule 60  Always declare constructors before any other method, starting with the default constructor if applicable.
Rule 61  Always use an initializer when a member variable is always initialized to the same value.
Rule 62  Always override Object.toString() in a user-defined class.
Rule 63  Do not overload operators unless it is completely obvious what the operator does to the class.
Rule 64  Always override hashCode when you override equals
Rule 65  Do not compare boolean values to true or false to create Boolean expressions.
Rule 66  Do not hardcode strings that are presented to end users.
Rule 67  Always use the form: Type[] name to define an array
Rule 68  Do not use interfaces to define a “constant interface”.
Rule 69  Always comment when a cast is used to convert between value types.
Rule 70  Always use the method equals to compare objects for equality.
Rule 71  Always use enhanced for loop for simple loop implementations
Rule 72  Always postpone variable definitions as long as possible.
Rule 73  Do not use the same variable for multiple purposes.
Rule 74  Do not modify a loop index variable inside a for loop.
Rule 75  Do not create more than one main method in a single package
Rule 76  Every switch statement should include a default case. The break in the default case is redundant, but it prevents a fall-through error if later another case is added.
Rule 77  Always make members,  local variables and parameters final when possible.
Rule 78  Do not use literals.
Rule 79  Do not modify a variable on the same line it is used as a condition or array subscript.
Rule 80  Avoid local declarations that hide declarations at higher levels. For example, do not declare the same variable name in an inner block.
Rule 81  Comments should add to the clarity of code. Avoid decoration, i.e., do not use banner-like comments and use single line comment and multiline comments.Document why something is being done, not just what.
Rule 82  Always write Javadoc comments for packages, interfaces, classes, methods, return values, exceptions that are thrown.
Rule 83  Always document the circumstances under which each exception can be thrown using the Javadoc @throws clause.
Rule 84  Always add the "Exception" suffix to the name of types derived from java.lang.Exception.
Rule 85  Always declare each checked exception that can be thrown individually
Rule 86  Always throw unchecked Exceptions if the error is not recoverable by the caller.
Rule 87  Always include failure information in an Exception detail message that contains the values for all parameters and fields that contributed to the exception.
Rule 88  Do not use assertions in non-private methods.

If you found any mistake or wrong statement from the above, please comment below to correct it.

Wednesday, 8 October 2014

Why StringBuffer and StringBuilder has not overridden equals() and hashCode()

Comparing Two Strings:
If we want to compare two strings,we can simply use equals() as below
?
1
2
3
4
5
6
    String str1=new String("ashish");
    String str2=new String("ashish");
     
    System.out.println(str1.equals(str2));//prints true
    System.out.println(str1==str2);//prints false
    System.out.println(str1.hashCode()+":"+str2.hashCode());//returns same value
hashCode() is overrided in String class,and the hashCode is computed using the below formula
 s[0]*31^(n-1) + s[1]*31^(n-2) + … + s[n-1]  
So two different String object will give you same hashCode value,if they hold the same value because hashCode for Strings are computed based on the value.
Comparing Two StringBuffer or StringBuilder:
You cannot use equals() to compare two StringBuffer Object.For example
1
2
3
4
5
6
7
8
StringBuffer sb1=new StringBuffer("ashish");
StringBuffer sb2=new StringBuffer("ashish");
     
System.out.println(sb1.equals(sb2));//returns false
System.out.println(sb1.toString().equals(sb2.toString());//use this approach to compare
System.out.println(sb1==sb2);//returns false
         
System.out.println(sb1.hashCode()+":"+sb2.hashCode());//return different value
As we know == always checks for references,and in the above code sb1,sb2 are 2 different instances hence false.
equals() and hashCode() are not overriden in StringBuffer or StringBuilder class,so Object class related equals() and hashCode() will be executed.
Object class equals() checks the reference as below
1
2
3
public boolean equals(Object obj) {
        return (this == obj);
    }
Object class hashCode() is a native method and its implementation depends on JVM provider.However it will return some sort of integer value.
Why equals() and hashCode() was not overridden on StringBuffer and StringBuilder class?
Hashtable was introduced on jdk 1.0 along with StringBuffers,StringBuilder class. (http://web.mit.edu/java_v1.0.2/www/javadoc/packages.html).
Consider two different String object, and we want to put them on Hashtable collection
1
2
3
4
5
6
7
8
9
10
11
String str1=new String("ashish");
String str2=new String("ashish");
     
Hashtable table=new Hashtable();
Object obj1=table.put(sb1, "Spring");//add key,value returns null as its a new entry
Object obj2=table.put(sb2,"Hibernate");replaces old value with new Value and 
returns old value
     
System.out.println(table);
System.out.println(obj1+" "+obj2); //null Spring(old value that was removed)
     
System.out.println(table); //returns {nataraz=Hibernate}
As we know,Hashtable will not allow duplicate key,but allows duplicate value.But as far as our code is concerned,str1 and str2 are 2 brand new different Objects.That means those are not same,and it should be allowed.Right?
Hashtable internally calls  hashCode()  and then equals() to check if both objects are same or not.When you try to store str2 in the hashtable,it checks str2.hashCode()==str1.hashCode() and then str2.equals(str1)
As I have already told you before,String hashCode are calculated based on the content using some formula,both the checks will return true,and Hashtable understands that it is a duplicate object and it will overwrite the Old value with the new value and returns the old value to the program.See the code code of map.put(-,-)
Note: put(key,value) returns null,if key is not duplicate. If key is duplicate,it overwrites the existing value with the new value,and returns the old value to the Programmer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    public synchronized V put(K key, V value) {
        // Make sure the value is not null
        if (value == null) {
            throw new NullPointerException();
        }
        // Makes sure the key is not already in the hashtable.
        Entry tab[] = table;
        int hash = key.hashCode();
        int index = (hash & 0x7FFFFFFF) % tab.length;
        for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
            if ((e.hash == hash) && e.key.equals(key)) {
                V old = e.value;
                e.value = value;
                return old;
            }
        }
....
....
}
Sun Microsystem wanted the programmer to allow adding 2 different String kind of Values in Hashtable or any other Hash Collections likes (HashSet,HashMap…),that’s the reason hashCode() and equals() were not overridden intentionally in StringBuffer,StringBuilder class.See the below code for clarity
1
2
3
4
5
6
7
8
StringBuffer sb1=new StringBuffer("ashish");
StringBuffer sb2=new StringBuffer("ashish");
     
Hashtable table=new Hashtable();
Object obj1=table.put(sb1, "Spring");
Object obj2=table.put(sb2,"Hibernate");//2 different object with different hashCode()
System.out.println(obj1+" "+obj2); //null null as both the values will be stored on hashMap
System.out.println(table); //  {ashish=Hibernate, ashish=Spring}
If they would have overridden those two methods,then you would not have been allowed to different StringBuffer,StringBuilder objects with same value as key in Hash collections.
Thank you for reading this Article.If you found it useful,share it on Facebook to reach the needy….