Trying to learn java
I'm trying to learn java so that I can be more effective as a performance tester, and am finding the challenge to be extremely difficult. Without exaggeration, this is probably my 10th attempt at trying to learn it, having tried the tutorials on the Sun site, a bunch of books, some other web resources...and it just isn't clicking. I kind of "get" the whole Object Oriented way of thinking, so I'm not sure where the block is, nor how to overcome it.
Some background. Started basic around 1980, then pascal around 1984, then fortran in 1985, then modula-2 in 1986, then a bunch up to 1990 (unix shell scripting, lisp, ada, C, vax assembler). Then from about 1992 onward: more C, then perl, visual basic, then VBA, some C#, some php, finally a little java. So I have a lot of procedural baggage.
The biggest hurdle I face is looking at some java code and understanding WHY the programmer decided to do certain things. For example, why or how did they arrive at "override public static void final?" Why is it necessary to be so redundant as in "ThisObject thisObject = new ThisObject;"? How on earth does one's brain work to come up with something like btn.setOnAction(new EventHandler<ActionEvent>() ?
I'm trying not to sound like whiner, but wonky syntax aside, I have no idea how to bridge the gap between where I am and where I want to be. Any advice is appreciated.
Sounds like you're just struggling with it's strongly typed nature and object oriented concepts.
Have you seen this book? Java book explicitly for testers. https://leanpub.com/javaForTesters
Most of those decisions were made pretty early on to aid compilation optimization.
Originally Posted by jpolvino
For example you're typed variables and type checking.
In C# you can use var thisObject = new ThisObject();. Because that is compiled code with all the Assemblies imported straight into the project so everything is known at compile time and compiled in. Since Java is more modular, you're loading in a bunch of class files through Maven, even some of the classes could be substituted during run time. So you have to put your declarations of either the class or interface it expects, so the compiler knows what objects it's dealing with. For example, ThisObject vs IThisObject, will let the compiler optimize on the exact type.
It might seem strange since you IDE has full knowledge because it probably indexed all the files in your project. While Java compiler has no knowledge and will look things up in the files of the import statements at compile time. C# has concept of solutions and projects, while Java has no notion of projects, that's something provided by the IDE.
Thanks for the replies posted so far. I'll give object oriented training another go, using the recommended book as well as other options (I have access to a library of self paced courses at work). I'm looking forward to getting to the point where I can rattle off something like List<Node> allCircles = new ArrayList<Node>(); and understand why I did it.
The worst form of failure is the failure to try.
I don't do well at teaching myself code any more. I think that I became lazy or my patience after 30 years of working has reduced.
I prefer to work with an online training school where where the instructor gives me assistance and gets me unstuck. I still get homework and time to think and work on my own. I just don't have as many times where I get completely stuck.