Best products from r/java

We found 219 comments on r/java discussing the most recommended products. We ran sentiment analysis on each of these comments to determine how redditors feel about different products. We found 183 products and ranked them based on the amount of positive reactions they received. Here are the top 20.

Top comments mentioning products on r/java:

u/ryc8889 · 1 pointr/java

I would also advocate Joshua Bloch effective Java

He does a very good job of breaking down different Java tips into different chapters and each chapter has a set of items. He also goes one step further and instead of just instructing you to do one thing blindly he goes over the other options possible and why they are not optimal

Also as an added bonus, Amazon says there's a third edition being released in october

Effective Java (3rd Edition) https://www.amazon.com/dp/0134685997/ref=cm_sw_r_cp_api_ccmEzb08YXW4C

Rob Martin's clean code is another book I would recommend but it isn't specifically for any one type of project but it gives nice examples of how to cleanly structure your code(also has a nice set of "smells and heuristics" which you can use as a pocket reference) but given your past experience this book can probably be more of a skim.

Other than that I would agree with what other people are saying with learning a framework. I like spring boot and there's plenty of example projects on GitHub that uses it and spring's own documentation is also pretty good.

For concurrency I would recommend Brian goetz Java concurrency in practice.

If you want a refresher for data structures and algorithms and just some examples of it in java I recommend Robert Lafore's data structures and algorithms in Java but if you're more familiar with math/algorithms and want to do a deeper dive then the CLRS introduction to algorithms is the holy Bible.


Edit: one other thing that I have found extremely useful is online developer websites

My top three are:
Dzone - has fantastic refcardz which are like cheat sheets for different frameworks, technologies and even general principles as well as articles for general programming as well as specific topics (cloud, Db, iot, etc)

Tip - subscrbe to the dzone newsletter. They send you emails that are collections of 10 or so articles and I usually just look through them to see if there's anything interesting or relevant to me

Infoq - similar to dzone also has a great collection of articles and presentation videos

Oreilly - not really a website I know but if you look at their free ebooks there's a good collection of them that will help you get started depending on what topics you're looking at

Bonus - YouTube. There's just so many tutorials and videos starting from beginner levels all the way to advanced topics like scaling cloud architectures for google-like loads, microservices, deployment.

I don't think anything beats doing a personal project though. If anything you can fork a starter spring boot project(which generally revolve around a basic concept like an online book store) and re-write it to be about a concept you're interested in.

Also reactive extensions seem to be catching a lot of buzz these days. I don't have any personal experience working with them but could also be another interesting topic to look into since I think java is actually adding support for reactive streams in java 9

u/phao · 2 pointsr/java

I can't talk about Schildt's competence on Java. I know about his C books, which are pretty much recommended to be avoided. Bruce Eckel's on the other hand, I've heard only good about his materials (although I didn't really like his design patterns book very much). I've never read the two books you've mentioned though.

Have you tried the official tutorials for learning Java? They're very good IMO. They're freely available too.

My first book on java was The Java Programming Language (it teaches Java 5 [current version of java is 8]). Except that you'd be learning Java 5, which is still fully applicable, this book is very good. One of the authors is the creator of java, another is Guy Steele. He's a programming languages expert whose books I believe are worth reading just because he wrote it. He's pretty above the average, and also one of the creators of Scheme. Look him up on wikipedia =D.

I've read Core Java too (it has pretty up to date editions). I found it good, which is a win on its own since most learning sources are terrible IMO, but I didn't find anything particularly interesting about it. It does cover a lot of ground, though. I surely recommend it.

A lot of writing good java code is about understanding the usual patterns of which people make use.

The author of Core Java has a book on this (http://www.amazon.com/Object-Oriented-Design-Patterns-Cay-Horstmann/dp/0471744875/). I've never read it, but I'd guess it's good. I don't know how advanced it is though.

You can, of course, always look up the Design Patterns book (http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612/). I'd not recommend reading this before learning java. I think you should only do it after learning some java. Although I don't think it's a particularly challenging book, I think it'll make a lot more sense given you can see its code examples (mostly in C++, and some in smalltalk; but mostly in C++) and understand what they do. You don't need to really know C++ for that, honestly. The code doesn't make use of any (IMO) advanced features of C++. Knowing java and using common sense I think is enough to understand what is in there.

There are many books on better using java. If you google for good java books, you'll find plenty of reviews, recommendations, and so forth. You can search amazon too.

By the way, a lot of the programming techniques for writing good code in one language can be learned by studying materials in other languages. For example, I owe much of my programming basis knowledge to K&R2 (The ANSI C Programming Language - 2e), SICP (Structure and Interpretation of Computer Programs), The Little Schemer, and The Seasoned Schemer. These books teach in C and Scheme (two languages that I probably will never use professionally), but a lot of what they teach I've been able to apply while coding in C++, Java, JavaScript, PHP, SML, Python, and also other languages I've used in the past.

Good luck.

u/lbkulinski · 3 pointsr/java

From Data Classes and Sealed Types for Java:

>Digression -- enums
>
>If the problem is that we're modeling something simple with something overly general, simplification is going to come from constraint; by letting go of some degrees of freedom, we hope to be freed of the obligation to specify everything explicitly.
>
>The enum facility, added in Java 5, is an excellent example of such a tradeoff. The type-safe enum pattern was well understood, and easy to express (albeit verbosely), prior to Java 5 (see Effective Java, 1st Edition, item 21.) The initial motivation to add enums to the language might have been irritation at the boilerplate required for this idiom, but the real benefit is semantic.
>
>The key simplification of enums was to constrain the lifecycle of their instances -- enum constants are singletons, and instantiation is managed by the runtime. By baking singleton-awareness into the language model, the compiler can safely and correctly generate the boilerplate needed for the type-safe enum pattern. And because enums started with a semantic goal, rather than a syntactic one, it was possible for enums to interact positively with other features, such as the ability to switch on enums, or to get comparison and safe serialization for free.
>
>Perhaps surprisingly, enums delivered their syntactic and semantic benefits without requiring us to give up most other degrees of freedom that classes enjoy; Java's enums are not mere enumerations of integers, as they are in many other languages, but instead are full-fledged classes (with some restrictions.)
>
>If we are looking to replicate the success of this approach with data classes, our first question should be: what constraints will give us the semantic and syntactic benefits we want, and, are we willing to accept these constraints?

u/MoreCowbellMofo · 2 pointsr/java

>How valuable is an Oracle cert?

No more than any other online course from a respected institution such as google, say: https://cloud.google.com/training/free-labs/ or one of the online courses available at MIT/Stanford.

>What else should I look into to boost my repertoire?

See if your university has any business partnerships you could do a 2-3 month project for. I worked with one of the university's here in the UK as part of a business/university partnership and that gives the students real world experience and us some free work. Win-win if the project is completed.

Sorry - mostly UK (amazon) links :)

TDD - https://www.amazon.co.uk/Growing-Object-Oriented-Software-Guided-Signature/dp/0321503627/ref=sr_1_1, Video by Trisha Gee whos fairly well known for speaking on this stuff: https://www.youtube.com/watch?v=QDFI19lj4OM (some very handy shortcut keys in the video and a good outline of some of the tools available to you).

Clean Code - https://www.amazon.co.uk/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882 (by "Uncle Bob")

Design patterns - https://www.amazon.co.uk/Head-First-Design-Patterns-Freeman/dp/0596007124/ref=sr_1_1

Learn to use shortcuts in Intelli J to speed up your ability to generate/refactor code: https://www.amazon.co.uk/Getting-started-IntelliJ-Hudson-Assumpção/dp/1849699615/ref=sr_1_1

Also Jetbrains does good newsletters (curated by the same lady that made the video above under TDD) sign up to stay up to date with interesting/relevant blogs/articles/industry news https://www.jetbrains.com/resources/newsletters/

Github - https://www.amazon.co.uk/Version-Control-Git-collaborative-development/dp/1449316387/ref=sr_1_4

Bash Commands - https://nikgrozev.com/2016/05/22/shell-cheatsheet-part-1-common-bash-scripting-tmux/

XP/Scrum/Kanban development process - https://www.agilealliance.org/glossary/xp/ the way we work

Trusted developer blog on various engineering topics https://martinfowler.com/

Interview Prep https://www.hiredintech.com/courses

Hint: the above books are likely to be available at any academic library. If not, request them. you likely only need to read 33-50% of them and you'll be golden. I imagine you can likely get hold of electronic versions of these books as well.

The best thing you can do to prepare yourself is to start practising developing projects... get them up on github. it could be a website, a desktop application/game/tool, a demo of sorting algorithms, a web service... literally anything. Fork others' projects, code a feature request and create a pull request back to the original repository/codebase on github. Just build something rather than nothing. Anyone can do the latter. There's so much more opportunity now that we have github available. Think of any thing you might be interested in working on and someone, somewhere has likely already got a project underway in that area, and you're free to submit a pull request to their repository at the click of a button. This wasn't really possible 10-15 yrs ago.

The simple answer is there's so much to know, you just have to find what your interests/passions are and follow those as much as possible.

No matter how good you are at what you do today, the tools will be different tomorrow and may even depend on the industry you enter: AI, web services, blockchain, computer vision, robotics? The list is long and each one requires you to be highly trained (over many years) before you're considered any good at it.

Just try to learn what you can. Find something that genuinely interests you and study it until you become a trusted authority on the subject, or you find something you're more interested in instead.

If you have any ideas for the type of area you might be interested in put them up here and perhaps someone can point you to a relevant project?

https://en.wikiquote.org/wiki/Howard_H._Aiken "Don't worry about people stealing your ideas. If your ideas are any good, you'll have to ram them down people's throats."

u/watafu_mx · 2 pointsr/java

>I want to make more applications...but I don't have any ideas..is there any reading you would recommend me to do?


Have you read Head First Java?

Head First Design Patterns?

The pragmatic programmer?



>I want to be employable...after 3 years doing a computer science course, I feel like I still only know the basics. What Java books do you value most and feel helped you become a much better programmer?


In my particular case, I didn't read books. My interest has been developing web applications, so I have gotten more information from frameworks' documentation an tutorials than from books.


>What are some examples of programs you made when you were 1 or 2 years into your Java programming career?


Hmm... I created some plugins to check on the availability of some servers and services. When it detected those were unavailable, it sent email and SMS alerts to our system administrators. Things got interesting when the email server was down tho.

>What resources would you recommend me reading to understand how to make my android applications able to access the internet..so that users can compare high scores and achievements?


>I have the drive. I love programming and I want to be a successful one. What advice can you give me?


Code as much as you can. Check what kind of applications you want to develop and find which frameworks can help you build them. You don't need to re invent the wheel (unless necessary). Follow the developer's guide and check if there are any tutorials that you can use to improve your knowledge and make better applications in the better way possible.


>Thank you for your help. I really appreciate it. I've felt stuck for days and i honestly did browse a lot before I came here. I've seen a lot of Java developer jobs paying £20-40k but i feel i don't have the relevant experience to even apply to them yet. I feel like i know very little..I.e I have no idea what J2EE is and what it's used for.


From wiki:
"Java Platform, Enterprise Edition or Java EE is Oracle's enterprise Java computing platform. The platform provides an API and runtime environment for developing and running enterprise software, including network and web services, and other large-scale, multi-tiered, scalable, reliable, and secure network applications. Java EE extends the Java Platform, Standard Edition (Java SE)[1], providing an API for object-relational mapping, distributed and multi-tier architectures, and web services. The platform incorporates a design based largely on modular components running on an application server. Software for Java EE is primarily developed in the Java programming language and uses XML for configuration."


If you want to build enterprise web-enabled applications, this is what you should start reading:
J2EE 6 Tutorial
And I always recommend these as well, they helped me a lot when I was learning Java Server Faces:


http://balusc.blogspot.mx/

http://www.mkyong.com/ (He has an Android tutorial that might help with with your interest to develop applications for that OS)

http://www.coreservlets.com/

u/jbacon · 2 pointsr/java

A few things to consider:

  1. PHP and JavaScript serve different purposes - the former executes on the server side, and the latter executes on the client side. PHP is just one of many possible server side languages - you could use Ruby, Python, Java, .NET, whatever. Doesn't matter, as long as your server knows how to render the page and send it to the client. JavaScript is really the only client-side language available.

  2. You cannot trust the client AT ALL. If all the order and pricing calculation is done on the client side (in JavaScript on the page itself), then you open yourself up to a million kinds of fraudulent ordering attacks. Anything done in JavaScript or sent from a form over the wire can be modified by the person sending it. After the order is all configured, your backend order management system (whatever that is), must validate the order and see if the price makes sense, then forward that price on to payment.

  3. From this, we can determine one very important architectural decision - all pricing and item information must be stored on and provided by the server, and not embedded into client-side code like HTML/JavaScript. So, we need a database to store all that information - how you do that is up to you. I would recommend MySQL or PostgreSQL as an easy, free option. PHP can integrate with both of those just fine.
    When you render the page, have your PHP code fill the options available on each form from your database, and your web server will deliver that final rendering (consisting only of HTML/CSS/JS) to the client. Remember, PHP code happens before your page ever leaves your server. The PHP page that processes form submissions should validate that what it received makes sense - go through each item submitted and check to see if it matches the database.
    That's your basic flow for a simple PHP-based webapp - Server executes PHP code, PHP code gets data from database, server sends rendered page to client, client submits form back to server, server validates form.

  4. Payment processing is a whole other can of worms. If you accept credit cards on your website, you must conform to PCI security standards, and you will be liable for any breach of information. My advice is to not do any of this yourself - there are many off the shelf website payment processing solutions. To start, just integrating PayPal is probably acceptable. You can graduate to card acceptance as you grow.

  5. Once you are comfortable with that, and understand how all the pieces fit together, you can start to explore new techniques and technology stacks. Ruby on Rails, Java with Spring/Spring MVC/Hibernate, Python with Django, Groovy on Grails - the list goes on and on. There are a million ways to make a simple web application.

    Basic programming principles, however, will always apply. I would recommend picking up a copy of The Pragmatic Programmer and reading every single page, then hang the tip sheet up by your desk. This book is an amazing resource for general programming practices, which will apply to anything you do.

    If you have any specific questions, I'd be happy to answer those as well.
u/AnnoraxD · 2 pointsr/java

Good job! Copying existing game ideas is a perfect way to learn

Some recommended reads I had saved as bookmarks if you want to dig even deeper into game programming:

Game programming patterns

Goes deep into all the different patterns of writing a good game engine. Written by one of the devs at EA. There is a free web-version if you scroll down on first page.

Game mechanic explorer

Lots of small snippets and explanations on common mechanics, like bullet trajectories etc. Only for 2d games but much easier to digest then the patterns-site.

A* introduction

A* is a fun algorithm to implement

Clean code book

This one is a must, a book you might get the most out of when working with other people but if you wanna get thinking in the terms of maintainable code and what will be expected of you at a real workplace, take the advices it gives to heart :)

And a tip for a potential next project:

One of the first games I did was a clone of Bomberman. The graphics can be pretty simple but you get to dig into cool stuff like (simple) AI with pathfinding and you can make a very simple multiplayer game out of it that isn't that lag sensitive

u/albert3179 · 1 pointr/java

Since you want to learn java and esp. OOP, I would say start with a good book. I like Core Java Vol. 1 and Core Java Vol. 2 but you can start with any book you like.

Download Java from Oracle since they have version 7 for Lion.

For editor, I would stay away from any full featured IDE like Netbeans or Eclipse in starting phase. Start with TextEdit or Sublime Text. Write few code by yourself and compile it using Terminal. This way you will learn the compilation process. All IDEs compile files automatically so you can't learn what is going on behind the screen. If you use command line, you will also learn CLASSPATH, packages, class creation etc.

You should use command line for first 2-3 months only or may be less depending upon your learning curve. After that you can choose IDE. By that time, you will also good knowledge to judge which IDE is good for you. Netbeans and Eclipse both are good and free. I like Netbeans.

Good luck with your learning process.

u/LyndonArmitage · 1 pointr/java
  1. I use IntelliJ at work and home, not just for Java but for a lot of other things, it has the fastest and best intelligent auto complete I have seen in an IDE and supports a whole tonne of frameworks and programming languages, it's also got some kickass keyboard shortcuts and a nice dark skin.
    However all the main IDEs are good, those are Eclipse, Netbeans and IntelliJ (as far as I am aware). At university you will probably be learning with Eclipse, BlueJ (which I have never used, but is supposed to be educational) or maybe even notepad. If they give you a choice I'd use Eclipse to learn with since it is used by a lot of companies and open source projects.

  2. One thing to watch out for is String comparison using the == operator. The == operator in Java compares memory address and not content of the strings, a quick google search turns up this blog post with some details on Strings in Java. Basically you should use string1.equals(string2) when comparing strings in Java.

  3. Nab a book from your university library or buy one on Amazon/The Book Depository.
    I taught myself it following various tutorials online but the books teach you better practices than those most of the time and are more in depth. Java a Beginners Guide seems highly rated on Amazon and has been kept up to date. When I was at university I saw a few copies of Thinking in Java around but it's a tad out of date now, Head First Java might also be worth a look.
    The videos I used to learn Java were a combination of thenewboston videos (these don't encourage good practices but show a basic way of getting started) and some Java games programming related videos by thecodinguniverse.
    Once you have the basics of Java down, might I also suggest completing the challenges on /r/dailyprogrammer to help get you more comfortable with it.
u/drummondaw · 1 pointr/java

I'm in the same boat as you. I'm currently working through a book called Java: A Beginner's Guide Sixth Edition. I chose this book because it uses the latest version of Java, which I think is important in some respects. Older books may have the same information initially (loops, datatypes, etc. rarely change), but as you delve deeper there are certain aspects of the language that improves over time and makes your life easier as a developer.

Choosing the right author is essential because they're basically your professor throughout the learning process. Someone suggested www.thenewboston.com and the vast majority of developers on this site laugh at even the mention of this resource. In other words, do your homework and ensure you're learning from a respected individual.

After having a basic understanding of a programming language your next step should be to choose a personal project slightly beyond the skill level you currently have. Doing research, solving problems/bugs and finishing something enhances your learning like you wouldn't believe. I've been reading programming books for many years and the times when I'd simply read a book in its entirety and then try to build something always showed me that my retention wasn't very strong. When I took the time to pause and use what I had learned throughout segments of the book I learned a lot more and my retention was extremely high.

Using what I've said above, you can pick pretty much any programming language and apply this learning style. I have tried both online classes and books and have found books to be the best method for myself. With online classes I've found myself spending time watching way too many videos than actually writing code.

u/thief_garet · 4 pointsr/java

I just resently started a carreer as a Java Developer myself (m/22), so I can remember the things I had a hard time with like it was yesterday.

What I had the most trouble with, carreer wise, is the configuration of a lot of frameworks. Java in itself is relatively easy (especially since you already are an experienced developer), it's the frameworks that require the most time to learn. A lot of them require a certain amount of configuration, mostly in XML. Learning how to set them up was mostly trial and error in my case. Like someone else said in the comments, pet projects are the best way to learn this. So, to answer your question about what I hate about Java: this configuring is it. Stuff like that is easier in, say, C#. However, if you join an already existing project, the configuration is already done most of the time (although not always very good).

Now for the resources. I really did a bad job with Java in my first year of college, but this guy really helped me with his tutorials (I got 100% percent when I took the exam again): [The New Boston] (https://www.youtube.com/playlist?list=PLFE2CE09D83EE3E28). I linked you the beginner tutorials, but he also has intermediate. [Effective Java] (http://www.amazon.com/Effective-Java-Edition-Joshua-Bloch/dp/0321356683) is also a good resource, like mentioned in the comments. Another one I like is [The Well-Grounded Java Developer] (http://www.manning.com/evans/). It is a really balanced book, talking about important things like Threading, the JVM, Dependency Injection, Continuous integration etc.

I would suggest you first do some little projects to get a feeling with Java as a language, and then stepping over to frameworks like Spring and hibernate. Check the differences between Spring and Java EE, read about dependency injection (Martin Fowler has a great article about this), etc.

This turned out longer than I expected, so I'll leave it at this. If you still have questions, feel free to PM me or leave a comment.

u/KevZero · 2 pointsr/java

I have no formal training in CompSci, but this book seems like a pretty standard 1st or 2nd year text. It's one of the best technical book purchases I ever made, imho: Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process by Craig Larman. I would recommend it to anyone who wants to learn programming. Goes great with the classic "GoF" book, Design Patterns. For any particular language's syntax and libraries, I just read the docs and check stackoverflow or IRC for any tricky idioms and for best practices.

u/K60d55 · 23 pointsr/java

I don't really like the term "design your system using interfaces" because it doesn't tell you why. It's a generic idea without any context.

It is better to start with a principle, like Dependency Inversion. Dependency Inversion says you should separate your code from its external dependencies. This is good, because it keeps your code isolated and not dependent on the particular details of things like storage.

Does your application use MySql? Does it use MongoDB? It doesn't matter. In your interface, you can specify query methods for objects from a data store, and a method to save objects to your data store. Then implement the interface specifically for the data store. Your interface could be called FooRepository and the implementation MySqlFooRepository or MongoFooRepository. I dislike interfaces called FooRepositoryImpl. This strongly suggests an interface isn't necessary.

Interfaces are contracts that help you preserve your design and to explain what you need out of external dependencies.

Interfaces are good, but so are classes. Don't overuse interfaces, because indirection isn't always necessary or good. It can make your code impossible to follow and understand.

Start by learning principles like SOLID, which will help you understand where usage of interfaces makes sense. Agile Patterns, Principles and Practices is the best book I've read about this. Another book which does a great job of explaining how to properly use interfaces is Growing Object Oriented Software Guided By Tests.

u/GrayDonkey · 3 pointsr/java

You need to understand there are a couple of ways to do Java web development.

  • Servlets & JSPs. - Check out Core Servlets and JavaServer Pages or the Java EE Tutorial. Note that I link to an older EE tutorial because the newer versions try to switch to JSF and not much changed in Servlets and JSPs between Java EE 5 and 6. I recommend learning Servlets and JSPs before anything else.
  • JSF - A frameworks that is layered on top of Servlets and JSPs. Works well for some tasks like making highly form centric business web apps. Most of the JSF 2 books are okay. JSF is covered in the Java EE 6 Tutorial
  • Spring - Spring is actually a bunch of things. You'd want to learn Spring MVC. If you learn any server-side Java web tech besides Servlets and JSPs you'd probably want to learn Spring MVC. I wouldn't bother with GWT or any other server-side Java web tech.
  • JAX-RS - After you get Servlets and JSPs down, this is the most essential thing for you to learn. More and more you don't use server-side Java (Servlets & JSPs) to generate your clients HTML and instead you use client-side JavaScript to make AJAX calls to a Java backend via HTTP/JSON. You'll probably spend more time with JavaScript:The Good Parts and JavaScript: The Definitive Guide than anything else. Also the JAX-RS api isn't that hard but designing a good RESTful api can be so be on the lookout for language agnostic REST books.

    Definitely learn Hibernate. You can start with the JPA material in the Java EE tutorial.

    As for design patterns, Design Patterns: Elements of Reusable Object-Oriented Software is a classic. I also like Patterns of Enterprise Application Architecture for more of an enterprise system pattern view of things. Probably avoid most J2EE pattern books. Most of the Java EE patterns come about because of deficiencies of the J2EE/JavaEE platform. As each new version of Java EE comes out you see that the patterns that have arisen become part for the platform. For example you don't create a lot of database DAOs because JPA/Hibernate handles your database integration layer. You also don't write a lot of service locators now because of CDI. So books like CoreJ2EE Patterns can interesting but if you are learning a modern Java web stack you'll be amazed at how archaic things used to be if you look at old J2EE pattern books.

    p.s. Don't buy anything that says J2EE, it'll be seven years out of date.
u/radekhecl · 1 pointr/java

First make sure you know well plain java. Do some sipmle programs, read web tutorials or beginners book. After that, read Effective Java from Joshua Bloch.
https://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683
You don't need to read every line of this book, but at least you should know roughly what is going on there.

Regarding the framewors. There are zillions of them so you have to be selective. It really depends on what you want to do.
Spring + sql is good for web applications. These are for example used as a administrative portals. It's kind of job safety since there are many of them and won't disappear soon. Go for that.

Now just a little advice for the job. The salary of the programmers goes down since it's becoming still easier to create generic things. To me it turned out to be really good deal to combine it with mathematics. Don't look to yourself only as a programmer, bring something more to the table.

Let me know if you need any help.

P.S.
I am thinking about flushing out some posts and examples related to computer vision in the next couple of months. Is this something you would be interested in to see?


u/[deleted] · 1 pointr/java

Frameworks like Spring and JPA/Hibernate are used in professional software development, and it is important to know them, but they won't teach you proper ways to architect your software. They are only tools, not substitutes for understanding and judgment.

I would suggest stepping back and learn patterns like Clean Architectures. This will help you understand the principles of software architecture, which is more important than Spring or JPA/Hibernate.

There are plenty of books on this subject. My favorites are Growing Object Oriented Software Guides by Tests, Agile Patterns, Practices and Principles in C# (the book has very little to do with Agile), Clean Code, Clean Architecture, Patterns of Enterprise Application Architecture.

Martin Fowler's website has a lot of good stuff about all architectural topics, from the stuff you're asking about, to microservices and big data.

Uncle Bob has a lot of videos on YouTube that are well worth a watch, like this one. Skip past the first five minutes or so unless you want a physics lesson, too.

u/lethargilistic · 1 pointr/java

Still, if it's their first time learning programming, Effective Java probably isn't the best fit. Most of its tips are the kind where you hear something for the first time, recognize it as common sense, then wonder why you didn't do it that way in the first place. However, its tips won't really be of use to someone who hasn't grasped object oriented programming yet.

Chapters 3, 4, 7, and 8 (of 10) are probably the ones that a beginner would get the most use out of. (Amazon's Look Inside has a TOC, which actually lists out all the tips in the book, so you can verify this yourself.) The other chapters are fairly specific to Java, which may be "in the weeds" and a bit too specific to Java to be immediately useful to a first-time learner. That criticism also somewhat applies to Chapter 3, but your friend is probably already working with methods inherited from the Object class (such as toString()), so that one would be useful to them.

Also, Effective Java is available freely online from an .edu extension, so (more than likely, but can't really verify) legitimately. I do own a copy, myself, but that's something to consider.

For a book that is entirely general programming advice (and thereby more useful to a beginner), I'd instead recommend Code Complete, second edition by Steve McConnell. You can open up that book to practically any page and find tips and best practices that can be applied to writing code in any lanaguage. It's also usually at least a bit cheaper than Effective Java.

u/halcyon44 · 3 pointsr/java

My own Amazon tech book wishlist shares a lot of those on Petri's list, but I'd have to include Code Complete as one of the best books on software development that I've read.

Petri has written some of the most helpful articles on Spring tech that I've read online.

You have some really awesome in-depth Hibernate articles, Vlad. Thanks for your hard work!

u/mmmguitar · 6 pointsr/java

Like most time in my job, I dont have alot of time to look at code, so something I find important is how clean / understandable the code is and at a glance its where I'm struggling with your code.

In particular, process request seems to be 200 odd lines long, doing many things and branch / nests alot and to understand you have to delve in to the guts of it and also read comments (which on shared code will go out of date). I think the complexity would really show if you try to unit test the code.

Clean Code is an awesome book on the subject. At times may go over the top a little but the message is great.

So to break that method down and make it cleaner / more understandable you can do 2 things. Firstly, small private methods that self document:

For example in the middle of the method you do this with a comment:


//----- DATA SEPARATOR -----//
String delimiter = "\t";
if ((REQUEST.get("FILE_DELIMITER") != null) && (REQUEST.get("FILE_DELIMITER").length() > 0)) {
String sep = REQUEST.get("FILE_DELIMITER").trim();
if ("COMMA".equalsIgnoreCase(sep)){
delimiter = ",";
} else if ("PIPE".equalsIgnoreCase(sep)){
delimiter = "|";
} else /if ("TAB".equalsIgnoreCase(sep))/ {
delimiter = "\t";
}
}

could be extracted to this:


String delimeter = getDeliminator(request)

....
}

private String getDeliminator(Request request) {
if ((request.get("FILE_DELIMITER") != null)) {
String sep = REQUEST.get("FILE_DELIMITER").trim();
if ("COMMA".equalsIgnoreCase(sep))
return ",";
else if ("PIPE".equalsIgnoreCase(sep))
return "|";
}
return "/t"
}

The advantage with that extraction is now processRequest has got smaller and there is now 1 line saying get delimeter that I can understand straight away because the name of the method is saying what its doing. Because of that you don't need that commend and the code becomes self documenting.

Its also simpler because there is no longer variable being defined with a default value that may or may not get overriden.

The delimeter calculation logic is now wrapped up in a nice little method that does 1 thing. Ultimately processRequest doesnt care how the delimiter is calculated, just that it gets one.

Everything has got a little cleaner and simpler.

So yeah there's many places that that sort of extraction / self documentation will help. Generally speaking a method should do 1 thing, if its over 4 lines long then it may doing too much (ok that quite extreme, but long methods are a sign of methods may be doing too much)

The second thing that may help is breaking that class up a bit. Its doing a lot, processing request, generating a file, doing all sorts of things with processing, writing the file out.

If you break things up a little you can reduce the complexity of whats going on, i.e. process request process the request and leave it up to something else to do file generation etc.

Its handy because it greatly simplifies testing, you can then starting testing the individual components. More along the single responsibility type idea.

A couple of other quick things I noticed, only use CAPS variable names for static instances. You have dual variables request and REQUEST doing differrent things,, i dunnore, request and requestTable?

Theres also a couple playes where you are catching an exception and doing nothing, it supresses the exception, generally thats bad, at least do a stack trace or log the exception happened. Its hard tracking down bugs / odd behaviour when exceptions are suppressed.

u/MassiveFlatulence · 6 pointsr/java

Since you're experienced, the best way to learn Java is to start coding in it. Create a simple blog in Java using basic servlet + JSP hosted in Tomcat + JDBC connection to some free database (Postgresql / H2). You will find issues along the way which you can Google around. The best thing about Java is that most questions already answered in StackOverflow. After you've done with it, go and read Effective Java then refactor your project to follow the best practice mentioned in the book. After that you can try to learn more libraries / framework eg. create a new reporting system and communicate the blog with the reporting system through JMS. Adding dependency injection using Spring and many more.

u/bubblemaster30 · 3 pointsr/java

I used this book,
http://www.amazon.com/Introduction-Programming-Comprehensive-Version-Edition/dp/0132936526/ref=zg_bs_3608_53

There are probably other good books, but I really liked this one. It has a broad range of topics and examples.

Also, I didn't start programming until college. Starting at 14 is awesome! You're going to be amazing by the time you graduate!

u/kraftvgs · 1 pointr/java

I had minor programming experience from a NASA internship but no practical object oriented programming experience aside from very basic classes. Effective Java is a wonderful book and if you have read it and comprehend it then you are more than ready for an entry-level programming job. Seriously, just start applying.

If you want to do more reading I would recommend staying away from Java books and dive into more generalized coding practice books. IMO, Clean Code is a must read, especially for a new programmer. Also Working With Legacy Code is a great read if you plan on going into a business setting where you will be working with a well-established code base. Again, these are just opinions. Go with all of the advice you've seen in your thread. I haven't seen a shred of bad guidance.

u/trimatt · 7 pointsr/java

If you want to gain a bit of confidence in writing good Java code i'd start by reading Josh Bloch's Effective Java. It's a fantastic reference manual to have on your desk...

Check it out here

u/Vorzard · 1 pointr/java

You mentioned Robert Sedgewick. His book, Algorithms and his online courses are highly recommended. And he uses Java in them.

http://www.amazon.com/Algorithms-4th-Edition-Robert-Sedgewick/dp/032157351X
http://algs4.cs.princeton.edu/home/

For object-oriented design the Head First books are great. It also worth to have the classic book Design Patterns: Elements of Reusable Object-Oriented Software.

http://www.amazon.com/dp/0201633612

I also recommend the books Code Complete, and Clean Code, they are great.



u/nutrecht · 3 pointsr/java

> As such, the commission a team of 2 people to remake the tool in C++ and QT. Well that was started last January. 8 months later and they aren't even close to being done. I'd wager at this rate they have another 2 or 4 more months. The silly thing, is my program in java was 3 files with maybe 400 lines of code.

You are at a company with very junior people. Unfortunately it's juniors who fell into the expert beginner trap and feel they already know everything. It's common for people like this to shit on other programming languages. Actual experienced devs know they are just tools and pick the right tool for the job.

Regarding your questions; I for now would recommend to not focus too much on the framework (both Java EE and Spring are fine, and learning one means you're also learning pretty much 80% of the other anyway) and focus on your core Java skills first and foremost. You already have experience so you will probably blow trough something like this mooc really fast. Other than that books like effective Java and clean code are great books to have read for a professional Java dev.

When it comes to starting with either Java EE or Spring; pick the one you prefer. I'm personally quite fond of Spring Boot because it is quicker to get started with and still has all batteries included, but if you prefer Java EE it's fine too.

P.s. like others said; it's not been called J2EE for a long time. Some vacancies do write it this way but that's generally a sign the company hasn't gone with the times.

u/fotuenti · 1 pointr/java

i too knew c++ when i decided to learn java, i found the core language book most useful immediately followed by Joshua Bloch's Effective Java (see wsppan's comment for a link).

Core Java Volume 1 - Fundamentals

in all honesty i was using the 6th edition book. good luck.

u/david72486 · 3 pointsr/java

I can definitely recommend 3) and 4) for sure. 2) has a particular style - many people enjoy it, some might not, so read a few pages first.

I'm not personally familiar with 1) and 5).

I will also add Clean Code for design patterns and general organization. If you're a beginner, it's probably okay to take that book at face value. However, once you get more advanced, you'll discover the parts where you can bend/break the strict rules he sets up there.

u/sh0rug0ru · 1 pointr/java

You can also check out the Java tutorials and the Java EE tutorials, but these might be a little on the light side compared to books devoted to the topic.

The Core Java Volume I and Core Java Volume II by Cay Horstmann are the best books I've read for learning Java. Some people like the Head First series.

Effective Java is a must read.

u/yusuke_urameshii · 0 pointsr/java

I second this book as well as a good starting point, the heads first java book as well might be a good starting point, and then jump into this mentioned above.

I would also suggest [Effective Java Edition 2 ] (http://www.amazon.com/Effective-Java-Edition-Joshua-Bloch/dp/0321356683). This book takes and builds upon the first two books, and teaches you a lot better OOP coding practices, and just how to be better at coding overall.

u/dalarist · 3 pointsr/java

Hey there! I personally love patterns. I think there are one of the single best things you can learn as a programmer. So here are some resources I have used and was successful with.

u/quantifiableNonsense · 6 pointsr/java

The stuff you are learning in CS class is definitely important, but it's orthogonal to the things you will need to learn in the industry.

Read "Code Complete" to get a head start on this stuff. - https://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670

As far as some fun interviews with famous programmers, another great book is https://www.amazon.com/Practice-Programming-Addison-Wesley-Professional-Computing/dp/020161586X

u/topshelf89 · 2 pointsr/java

I recommend the head first java book http://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208. It would help a lot to read through some of it before starting your class, or while taking your class. The whole Head First series is great and an easy read. It will make some of the trickier programming concepts easier to understand.

u/Centinul · 8 pointsr/java

I agree that Code Complete is an excellent book. Another I'd add to the list is The Pragmatic Programmer.

Effective Java is good but it's really about the nuances of the Java language. It looks like you are looking for better programming practices in general. If so I'd go with the books already mentioned.

u/beltedgalaxy · 3 pointsr/java

They did talk about some good, solid practices for Java, that really don't go out of relevance.
If you have a solid base of Java, much of what they talked about can also be found in a more cohesive format in Josh Bloch's amazing book "Effective Java" . even though this book was last published in 2008, the content is as relevant as ever, as it discusses foundational best practices.

u/_____dban_____-_ · 2 pointsr/java

You might find Michael Feathers Working Effectively with Legacy Code useful. It demonstrates how to safely migrate towards TDD in legacy projects by building up automated functional tests which allow safe refactoring to more testable code.

u/EllipsisUser · 5 pointsr/java

The Pragmatic Programmer: From Journeyman to Master

It's not really focused on Java or any language specifically, but it helps you become a better team member. The concepts help you write code you won't curse at later...

u/Chew55 · 3 pointsr/java

I haven't used it but at university my lecturer used to recommend Head First Java as a gentle introduction to Java and for any students who found themselves struggling to keep up with the pace of the class. It contains lots of practical examples and is pretty unintimidating.

I've used the Head First series for other topics and always found them useful.

u/spoon16 · 9 pointsr/java

Clean Code http://amzn.com/0132350882

Code Complete 2 http://amzn.com/0735619670


Both are great books. I just finished reading Clean Code and I highly recommend it.

u/doclight · 2 pointsr/java

If static were an evil modifier, I'm pretty confident it wouldn't have been added to the language.

> no.

Static constant values allow the compiler to compute anything solely dependent on them at compile time, instead of at run time. Like say for example:

public static final double E_TOTEN = Math.pow(Math.E, 10);

> So singleton instead of static is somehow magically ok now? It's the same damn thing @
@

Would you prefer if I used the word enum?

> I have no idea what your example is demonstrating.

It wasn't an example, it was a question. Which one provides better encapsulation? A method that has access to every member variable in the class, when the necessary values are provided through public accessor methods, or a static method that uses the public accessor methods.

If you're really serious about coding in Java, I recommend you check out Josh Bloch's Effective Java.

u/sh0rug0ru____ · 2 pointsr/java

This is Dependency Inversion.

The best demonstration I have seen for effective use of interfaces is in Growing Object-Oriented Software Guided By Tests. Interfaces express the requirements a unit has that its dependencies must fulfill. The dependency is inverted (synonymous with terminated?) - instead of the unit depending on the specifics of its dependencies, the dependencies must be adapted to suit the requirements of the unit.

u/vladmihalceacom · 2 pointsr/java

> Yes, the Native Query and access to Connection is always THE Hibernate's answer to all the lacking support of basic SQL features like Window Functions or being able to count aggregated results.

That's a very common misconception. Hibernate is not a replacement for SQL. It's an alternative to JDBC API that implements the Enterprise Patterns stated by Martin Flower in his book.

Thre are many alternatives to JPA or Hibernate. In fact, I'm also using jOOQ, and I like it a lot. I wrote about it. I'm using it in my training and workshops as well.

There are things you can do in jOOQ that you can't do with Hibernate, and there are also things you can do with Hibernate that you can't do with jOOQ.

u/ITGZachATTACK · 2 pointsr/java

I'm only about 6 chapters into volume 1, but I'm really enjoying Core Java by Cay Horstman and Gary Cornell. It assumes previous programming knowledge. My only issue with it so far is that there are no exercises to work through.

I also hear Thinking in Java is the defacto standard on how to learn it though, but I don't know if it assumes previous programming knowledge or not.

I started with C++ so the C++ comparisons throughout are helpful to me.

If you're interested in Core Java:

Volume I - http://www.amazon.com/Core-Volume-I-Fundamentals-Edition-Series/dp/0137081898/ref=dp_ob_title_bk

Volume II - http://www.amazon.com/Volume-II-Advanced-Features-Edition-Series/dp/013708160X/ref=pd_sim_b_1

u/evil_beeton_idiot · 2 pointsr/java

I guess Core Java™, Volume I--Fundamentals is a very good starting point. I recommend it always to guys asking me how to start with Java. Then the Vol II for advanced topics. And then Effective Java for best practises. Effective Java is excellent, but you need to have spent at least 1000 hours of programming in Java to fully understand what the book tries to teach you.

For a related discussion you might have a look at this post at stackexchange.

u/chapmbk · 6 pointsr/java

The most important thing when looking for a Java developer job is to actually understand Java. I don't mean knowing how to write code in Java. I mean knowing how the language works. What is the purpose of equals/hashCode, how to make object Immutable, what is the String pool, etc...
You would be surprised how many developers think they understand the language and have no clue how it works.


  1. Read and understand effective java and clean code.
  2. Be familiar with and excited about automated testing. You should aim for 80% - 90% unit test code coverage in your projects.
  3. Be familiar with static code analysis tools. PMD, FindBugs, etc...
  4. Understand the benefits of code reviews. Be familiar with popular code review tools. Crucible, etc...
  5. Have a degree.
  6. Be familiar with current technologies. Show that you research new technologies on your own

    You do not need all these things to get a job. There are plenty of large IT organizations that will just hire lots of people to fill seats and then drop them if they don't work out. However, if you want to get a job at a company that is serious about producing quality code, you need to show that you are serious about being the best developer you can be. Getting a job at an organization like this will not only pay better but you will also have the opportunity to learn from all the highly skilled developers that work there.
u/Ownaginatious · 5 pointsr/java

These two are good reference guides despite their age. Lots of good best practice stuff.

u/pragmatick · 2 pointsr/java

The other answered enough abuout 1&2. Apart fom recommending Head First Java I'd advise you to go to Coding Bat and try to solve at least the beginner puzzles there. We got a student here at work who learned (or should've learned) Java in university but the professor was so stuck on high minded patterns and theoretical stuff that none of the students actually learned a bit of coding. Those puzzles are perfect for getting to know strings, loops and all the beginner stuff that you should know inside out. And depending on what you do at uni help you with your exams a lot.

u/DeliveryNinja · 3 pointsr/java

Just keep refactoring. Read through the code and each time leave a little bit cleaner. It should be a joy to read good code. Robert Martin would say that you should have methods that are a max of 5-6 lines long. If you want to learn more then you should check out his book, clean code I highly recommend it.

u/Deinumite · 1 pointr/java

That's probably a good starting book. Once you are more advanced, and if you want to continue learning java, I'd check out this book. It's literally the best java book ive ever read.

http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=sr_1_1?s=books&ie=UTF8&qid=1319858709&sr=1-1

u/vplatt · 1 pointr/java

I have this as well, but don't really have any remarks for you. That said, maybe you should look through some of the reviews for it on Amazon or the like. The reviews there seem pretty authentic.

https://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420/

u/axlor · 2 pointsr/java

I always liked Effective Java the most, might be a little too advanced. I'm really not sure where you are in terms of comfort with syntax and basic concepts. Can you explain further what you've done in terms of programming in Java, and how you understand these concepts?

Also, I would suggest checking out TheNewBoston video series on Java programming, lots of great syntax and implementation of concepts you mentioned. http://www.youtube.com/watch?v=Hl-zzrqQoSE&playnext=1&list=PLAFF55E55870752DA

I think I may have found a book more for your level. www.amazon.com/Thinking-Java-4th-Bruce-Eckel/dp/0131872486. Thinking in Java. From a review, here are some topics covered:

Object-design basics

Inheritance and polymorphism

Object lifetimes

Exception handling

Multithreading and persistence

Java on the Internet

Analysis and design basics

Java basics: keywords and flow control

Initializing objects

Java packages

and many more.



Some of these I'm sure you've seen, and this will be another look at them, others will be new but important to know and understand.

u/FireIre · 6 pointsr/java

My college uses Introduction to Java, Comprehensive Edition. We'll be using it for 4 full semesters, and I think there will still be a chapter or two we don't cover. It has 34 Chapters in the book then 16 online chapters that covers a lot of topics covering Java EE, JSP, etc. It starts at the beginner level and goes from there.

However, despite its size it still doesn't go too in depth in many topics. For example, I'll be taking Java concurrency class next semester. We'll be starting with the concurrency chapter in the Intro to Java book and then we'll be moving to Concurrency in Practice by Brian Goetz.

This os only the second of two Java books I have exposure to, so I can't really rate it against any others, but it seems pretty good overall, though slightly vague on a few topics.

u/Omnicrola · 8 pointsr/java

I'm surprised nobody has recommended Clean Code by Robert Martin, which has good advice for keeping code clean in any language. Examples are given in Java. It echoes a lot of the advice given here, as well as explaining the reasoning behind the practices.

u/sh0rug0ru_ · 1 pointr/java

I would suggest reading these books to get a deep understanding of OOP:

  • Agile Patterns, Princples and Practices in C#
  • Growing Object Oriented Software Guided by Tests
  • Clean Code

    Here's a chapter from the Agile PPP book, Heuristics and Coffee, which gives a great overview on how to think in OOP terms. Keep this in mind: OOP is a way of thinking as much as it is a way of programming. OOP lives in the spaces between objects, in the methods, not necessarily the objects!

    Also, note that OOP is a code organization, which really starts to make sense in larger programs. I would suggest writing some larger programs, such as a contact manager, an email client, a chat application, etc. Larger programs will give you a chance to play with technologies such as databases and client/server networking. More stuff to add to the ol' resume.
u/krabby_patty · 4 pointsr/java

Working Effectively with Legacy code is great. It's not specifically a Java book, but I've found it very useful.

https://www.amazon.co.uk/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052

u/insanitum · 2 pointsr/java

Upvotes for Head First Design Patterns, it's a great reference and fun read!

u/ChamesJucks · 2 pointsr/java

Start with Spring Roo + Clean Code:

u/Cpist · 4 pointsr/java

The best way I would suggest is buying a starters Java book online. I'm taking my AP Computer Science class as well and my teacher is also pretty difficult. He goes quick so I definitely recommend trying this. Also, try Khan Academy, PracticeIT, and CodingBat.

Ninja Edit: Grammar.

u/haakon · 2 pointsr/java

In your example, the first argument is not needed:

public static int sum(int... numbers) {
int sum = 0;
for (int i : numbers) {
sum += i;
}
return sum;
}

"Tricks" like these are just part of the language, so to learn them, read a relevant book I guess. To learn more idiomatics and best practices, I'd recommend Effective Java

u/whatiswronghere · 12 pointsr/java

I would definately recommend going for a book. Head First Java is the book I'm learning from right now, and I find it to be engaging, funny, and on point.

u/keyofdminor · 18 pointsr/java

A classic text for this situation is Working Effectively with Legacy Code by Michael Feathers. Legacy code is a different ball-game than relatively clean code-bases, and has its own set of strategies. As it happens, there is a timely episode of the SE Radio podcast as well.

u/TyphonRT · 0 pointsr/java

You can't go wrong with these two books:
http://www.amazon.com/Java-Puzzlers-Traps-Pitfalls-Corner/dp/032133678X/

http://www.amazon.com/Effective-Java-Edition-Joshua-Bloch/dp/0321356683

Joshua Bloch is a good author and was involved in implementing the Java API (collections API, etc.) early on...

You can also find several talks he's done online for Java puzzlers.

Some good presentations online (including some puzzler ones):
https://www.youtube.com/results?search_query=joshua+bloch

u/zeldaccordion · 1 pointr/java

Have you read Effective Java? I'm reading it right now and enjoying it / learning quite a bit from it. I recommend it!

u/mrcleaver · 7 pointsr/java

Learn by experience and by reading is probably the way to go. The gang of four's design patterns is still the de-facto standard:
http://www.amazon.ca/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612

I really love this book for Java design patterns though, fun to read and really informative:
http://www.amazon.ca/Head-First-Design-Patterns-Freeman/dp/0596007124/ref=sr_1_1?s=books&ie=UTF8&qid=1333263240&sr=1-1

Then it's a matter of knowing when and where to apply them, which is a harder problem and just an experience thing I'd say.

u/GeorgeMaheiress · 3 pointsr/java

A good resource is Java Concurrency In Practice. Sounds like you'd be interested in Item 5.3: Blocking Queues and the Producer-consumer Pattern. Unfortunately I can't share it with you as it's copyrighted, but here's the short code snippet from it:

Producer & Consumer:


public class FileCrawler implements Runnable {
private final BlockingQueue<File> fileQueue;
private final FileFilter fileFilter;
private final File root;
...
public void run() {
try {
crawl(root);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}

private void crawl(File root) throws InterruptedException {
File[] entries = root.listFiles(fileFilter);
if (entries != null) {
for (File entry : entries)
if (entry.isDirectory())
crawl(entry);
else if (!alreadyIndexed(entry))
fileQueue.put(entry);
}
}
}

public class Indexer implements Runnable {
private final BlockingQueue<File> queue;

public Indexer(BlockingQueue<File> queue) {
this.queue = queue;
}

public void run() {
try {
while (true)
indexFile(queue.take());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}

And startup method:


public static void startIndexing(File[] roots) {
BlockingQueue<File> queue = new LinkedBlockingQueue<File>(BOUND);
FileFilter filter = new FileFilter() {
public boolean accept(File file) { return true; }
};

for (File root : roots)
new Thread(new FileCrawler(queue, filter, root)).start();

for (int i = 0; i < N_CONSUMERS; i++)
new Thread(new Indexer(queue)).start();
}

u/shvr · 2 pointsr/java

Core Java is another great book. It's really in depth and beginner friendly, and comes with lots of example code / programs. I've been working my way through it and love it. No fluff, just the information that's needed. I come from a Python background, but I'd also recommend it to a beginner with no previous programming experience.

u/smysnk · 6 pointsr/java

While you said books haven't helped, give this one a try: http://www.amazon.com/Head-First-Design-Patterns-Freeman/dp/0596007124

This website is pretty good also: http://sourcemaking.com/design_patterns



u/TheAntiRudin · 2 pointsr/java

For true novices I'd recommend Java for Everyone by Cay Horstmann. For people new to Java but already familiar with programming I'd recommend Core Java by Cay Horstmann and Gary Cornell.

u/Balduracuir · 3 pointsr/java

That line of code you showed violates more Interface segregation principle than Single responsability to me.
It's not because everyone is using something that it is a good practice... You can try to spread the good word around you and encourage people to read or re-read Clean code for example.

u/thakk0 · 3 pointsr/java

It depends, honestly. There is some discussion about this in Effective Java if you haven't read it.

I'll summarize some of what Josh Bloch says on the topic here:

> If a class is accessible outside its package, provide accessor methods...If a class is package-private or is a private nested class, there is nothing inherently wrong with exposing its data fields

For example --

public enum Planets
{
MERCURY(1), VENUS(2), EARTH(3), MARS(4), JUPITER(5), SATURN(6), NEPTUNE(7), URANUS(8)
private double _rateOfSpin;
public Planets( double rateOfSpin ) { _rateOfSpin = rateOfSpin; }
public rateOfSpin() { return _rateOfSpin; }
}

If you use rateOfSpin(), you have the option of making this a derived value without introducing a breaking change. For the cost of an additional "() -- you get some flexibility. If your enum is private or package-private, you can eschew the accessor with minimal risk.

Hope this was helpful.

u/-jp- · 2 pointsr/java

If you're studying Java specifically I recommend getting Josh Bloch's Effective Java. It explains the rationale behind literally everything I think I've seen in that ecosystem, and is one of the better programming books I've read in general.

u/_dban_ · 10 pointsr/java

Just a public service announcement - this is not what mocks are for. I would recommend anyone interested in the subject of effective mocking to read Growing Object Oriented Software Guided by Tests by Pryce and Freeman, the authors of the jMock framework.

From the OP, the way to test "monolithic" applications using mocks is exactly the same way you should test HTTP endpoints as well. As far as the application is concerned, it should not matter that the endpoint is a microservice, a remote HTTP API or otherwise.

This lets you set a service contract for your expectations of the remote service specified using a service interface. The implementation contains the details of the HTTP interaction, which you can test for real, separately and in isolation from the rest of the application to verify that it meets the needs of the application as specified in the service contract.

Otherwise, this mock isn't really testing anything other than you are using an HTTP connection API correctly, which doesn't tell you if the REST service actually behaves the way you expect.

u/banuday17 · 1 pointr/java

Agile Principles, Patterns and Practices in C#. The online version is from the older Java book.

This book is hands down the best book I've read on how to do Object Oriented Programming.

u/bjarneh · 5 pointsr/java

this book is often mentioned among the best programming books ever written; together with Larry Wall's (Camel) Perl book, and Dennis Richie's C book.

Effective Java

http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=sr_1_1?ie=UTF8&qid=1314549239&sr=8-1

u/thank-you-raymond · 2 pointsr/java

I suggest that you do the OCA exam, and use this book. You will learn the language fundamentals in great detail.

u/Celos · 2 pointsr/java

If it's a requirement for finishing school, just get ahold of one of the study guides for it and follow the instructions. Something like this.
The topics covered and the practice exams match up with the actual exam very well.

If it actually is a requirement, then your school library should have a copy of it (or something similar).

u/thesystemx · 3 pointsr/java

DON'T COMMENT!

Comments should be placed only where it explains something that's not clear by the code itself. Commenting getters and setters buys you nothing, unless they have some side-effect the user should be aware of (but then again, they should not have such side-effect in the first place).

Clean Code (http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882) has an entire chapter devoted to this.

Btw, please also format your code normally. What you 're doing now with those weird bracing style is atrocious!

u/thamesr · 3 pointsr/java

If you ever work with an older codebase, check out "Working Effectively with Legacy Code".

https://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052

Getting older code under test is some of the most challenging (and rewarding) work you can do.

u/TheGoddamBatman · 2 pointsr/java

Head First Java. It's a book, so it's not free. But it's good, if a little basic. If you want to actually learn Java you will need to spend some actual time.

I'm sure your company will let you expense it.

u/umeshawasthi · 2 pointsr/java

If you just starting, my suggestion is to start Head First Java book. This is one of the best book for beginners (It's still in my collection).

Once you have basics, you can start looking in to web resources to more advance tips and tricks.

u/CSResumeReviewPlease · 2 pointsr/java

This, as well as any tutoring services the college makes available. If you're just looking for an easily understood Java book I've been reading through this book and it's a very approachable book.

u/bogoris76 · 18 pointsr/java

It is a best-practice; by default java compares objects by reference, not 'by content'. That said, two objects representing the same logical entity (e.g. Order) are different objects instances (different reference in memory), but represent the same entity e.g. in DB (they have the same ID). Assume the following: equals and hashCode is *not* overriden. You read the same value by id from a DB using jdbc and put them into a HashSet. As these have different references there will by 2 items in a set. Do the same but override equals and hashCode to reflect the content of the object. The set will have only one item. Why and when this is important: if your system (application) relies on subsystem that manages identity of entities (e.g. SQL DB where you use IDs) and do *NOT* rely on actual object identities -- and this is pretty much common for most applications that use external storage (e.g. SQL).

Why to do it for *all* objects: assume we have 2 classes A and B, where A contains a collection of Bs . A has overriden equals and hashCode and compares with another A ; it also has to compare collection of Bs. How ever, collections of Bs will *only* be equal if all Bs are identical -- the same references but not values.

If you happen to use hibernate overriding equals and hashCode is a must IMHO as hibernate will rely on equality by content, not reference.

​

Good read (required :-) ) on the topic:https://www.amazon.co.uk/Effective-Java-Joshua-Bloch/dp/0134685997/ref=dp_ob_title_bk

u/GreyscaleSunset · 7 pointsr/java

Effective Java is the bible of this language and has recently released it's third edition

See also the O'Reilly series filtered by language/product and release date

u/VGPowerlord · 5 pointsr/java

To commentt on Effective Java, 3rd Edition comes out sometime soon (October, I think). It even has a preorder on Amazon.

u/techtechtock · 1 pointr/java

I just started learning Java and found Head First Java very helpful.

u/strcrssd · 6 pointsr/java

Read and adhere to the guidelines presented in "Clean Code" by Robert Martin (Uncle Bob). The book could have been written as a response to this question.

Edit: krogger pointed out I misattributed the work. This has been corrected. Thanks Krogger.

u/surfinThruLyfe · 2 pointsr/java

Head First Java is a good book for beginners.

Head First Java, 2nd Edition https://www.amazon.com/dp/0596009208

u/phonyphonecall · 1 pointr/java

Highly recommend learning it right the first time by reading Java Concurrency in Practice.

u/calp · 9 pointsr/java

I think the book people normally recommend for this is Effective Java by Joshua Bloch

u/GreyDeck · 1 pointr/java

I liked Core Java vols. I and II, but it's a little expensive and only 12th in Amazon's list of java books. Head First is number one.

u/thehollyhopdrive · 3 pointsr/java

Two Java specific books you should read cover to cover (and keep around as an effective reference) are Effective Java and Java Concurrency in Practice, and you should also seriously consider reading Design Patterns. The examples in it aren't written in Java but they hold for all OO languages.

u/swiftversion4 · 2 pointsr/java

This is the text I used to learn elementary Java programming:

https://www.amazon.com/Introduction-Java-Programming-Comprehensive-Version/dp/0132936526

at the end of each chapter is a set of exercises... we're talking about 20-30 or more exercises.

I'm actually re-studying basic java because I have an advanced java course this fall. I'm just going back to each chapter, read through it, and doing every.single.exercise.

It gets repetitive very quickly, but that's what I want: to know the basics so thoroughly that I don't have to think in order to type or use them in basic scenarios.

The main point for me is to do the basic exercises so much that when I start this advanced Java course this fall, i'm not re-learning any of the basics. if you're willing to spend $15 to get an old copy, it might be worth it.

Or find a pdf online if you don't care about paying for it. That works, too, I guess.

u/cowwoc · 6 pointsr/java

There is nothing to tone down. I'm not questioning your technical competence. I'm just saying this is a design anti-pattern. If you read Effective Java you'll end up with a better design that will avoid the need to ever think of Strings.isNullOrEmpty().

u/dvuevo · 19 pointsr/java

Apparently the 3rd edition is listed on Amazon and coming out in October.

Anyone know if this was actually announced or is it more of a placeholder?
https://www.amazon.com/dp/0134685997/

u/fact_hunt · 6 pointsr/java

For concurrency you can't go wrong with Java Concurrency in Practice

u/pjmlp · 8 pointsr/java

You missed:

Filthy Rich Clients

http://www.amazon.com/Filthy-Rich-Clients-Developing-Applications/dp/0132413930

Not so relevant now that JavaFx is here, but still a good way to understand how to properly write Swing code that doesn't put Java to shame.

Java Concurrency in Practice

http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601

A must read for anyone writing multicore code on the JVM.

u/corrspt · 8 pointsr/java

Might want to wait for the 3rd edition, (October 2017, according to the publisher - (https://www.amazon.com/Effective-Java-3rd-Joshua-Bloch/dp/0134685997)

u/zargx · 3 pointsr/java

> The idea is that both DAOs join the transaction, and that either the
> data from both DAOs ends up in the DB, or none at all. The DB has some
> contraints set for the data that we are persisting.

and

> What we however really wanted to test was whether the data
> actually ended up in our DB and whether both DAOs joined the
> transaction to see if the effects of DAO1 are correctly undone
> (rollbacked) when DAO2 throws.

This is not what mocks are for. This is why you do integration testing and functional testing.

Mocks state the expections a class under test has for its collaborators, and verify behavior given those expectations. You use this to grow the interface for collaboration based on class under test's needs. Furthermore, the owner of the interface is the class under test, not the collaborator. If you change the interaction with the interface, you must verify the collaborator still meets the expecations of the class under test. This is in line with the principle of Depedency Inversion.

Thus, returning to your example, the proper question is what does the ServerFacade need from the DAOs? You grow the DAO to meet the needs of the ServerFacade. Then, integration tests should be written to verify that the DAO meets the expectations set by ServerFacade. And any time you change ServerFacade's expectations, you'd better make sure the DAO still meets those expectations by updating the integration test.

Seriously, read the book Growing Object Oriented Software Guided By Tests, written by the authors of the EasyMock framework. Before reading your own interpretation of what you think mocks are for, read how the authors of EasyMock intended it to be used.

u/maredsous10 · 2 pointsr/java

Java: A Beginner's Guide by Herbert Schildt (Author)
www.amazon.com/Java-Beginners-Guide-Herbert-Schildt/dp/0071809252/

u/devnull5475 · 5 pointsr/java

Immediate, unequivocal answer: Thinking in Java by Bruce Eckels.

u/rosuoammdo · 2 pointsr/java

I learned it from this book. I took a class that primarily used Java, and I had never used anything but C (and thus had zero knowledge of OO programming). This book brought me up to speed fast and it was very thorough.

u/c0demonk3y · 6 pointsr/java

The Pragmatic Programmer http://www.amazon.co.uk/Pragmatic-Programmer-Andrew-Hunt/dp/020161622X

Has a lot of similar stuff to Code Complete 2 but not quite as dense so makes a good primer.

u/CodeShaman · 0 pointsr/java

Once you've mastered basic design patterns, this book will take you to a heightened state of consciousness.

u/chemosabe · 2 pointsr/java

> Oh boy, I know nothing about either of those things.

Get this book pronto. It's essential.

u/xpto123 · 2 pointsr/java

I think Java Performance and Java Concurrency In Practice are two of the main ones. Especially JCIP is the reference for concurrent programming.

u/AnAirMagic · 19 pointsr/java

By Essential Java, I take it you mean Effective Java, right?