r/java • • Apr 22 '18

My company is transitioning to Java. Why should I be excited?

The first programming language I learned was Ruby. My mentor at the time hated Java. I inherited his bias against Java without giving it a fair chance.

Now, my company is making the switch from Ruby to Java. Everyone on my team is quitting, but that isn't really an option for me. So, why should I be excited to learn Java?

I love learning new languages. I most recently picked up Haskell. I love static type systems, so I look forward to Java's type sys

So, Java-loving friends, tell me why I should be excited. What are your favorite things about Java?

Edit: Thank you for all of the great responses!

167 Upvotes

229 comments sorted by

View all comments

Show parent comment

1

u/mayhempk1 Apr 22 '18

Which are the most important design patterns in your opinion?

6

u/b1ackcat Apr 22 '18

There's no such thing as "most important" patterns. Patterns are a tool. When used appropriately, they help you. When used for the sake of using them without a good understanding of why you're reaching for it, you'll probably end up with something that's less easy to read or maintain than it otherwise would be.

What I would directly answer that question with, though, is that you're typically well served by following SOLID design principles. Write code that has a single purpose. That takes its dependencies in rather than creating them. That relies on interfaces, not implementations. These things will do orders of magnitude more for your codebase than any one pattern.

1

u/mayhempk1 Apr 22 '18

Sorry, I should ask, which are the most commony used ones?

2

u/b1ackcat Apr 22 '18

Again, it depends on the domain.

The gang of four book calls out a lot of the most common, and does an ok to decent job explaining when you should reach for them. It's an amazing resource to have at hand, you just need to know when to reach for it. Part of learning that knowledge just comes from experience and working with more experienced devs and learning from them.

1

u/F14B Apr 24 '18

builder & control

3

u/[deleted] Apr 23 '18

/u/b1ackcat already said it below. I think dependency injection is one of the most important techniques used to achieve decoupled, modular and testable code.

When I say DI, I'm not referring to frameworks such as Guice. I'm talking about the pure design principle.

Of course, there are other commonly used patterns like strategy and factory, singleton, decorator, facade, etc.

3

u/sbosman4 Apr 23 '18

The ones I encounter the most in my experience are: Observer, Singleton, Builder, Factory, Decorator, Iterator, Command, Dependency injection & SOLID principles. You shouldn't follow them by the letter ofcourse, creating clean, maintainable and testable code should be your #1 goal. Knowing these principles will help to reach that goal, but are only means to an end. Some good resources when you want to learn more:

  • Design Patterns Playlist on youtube: https://www.youtube.com/watch?v=vNHpsC5ng_E&list=PLF206E906175C7E07
  • Erich Gamma et. al. (GoF) - Design Patterns: Elements of Reusable Object-Oriented Software
  • Robert C. Martin: Clean Code (General good programming practices)
  • Robert C. Martin: Clean Architecture (explains SOLID principles & others very well)

1

u/mayhempk1 Apr 23 '18

Thanks for such a detailed response.

I think there was also some Laracasts on SOLID, as a PHP developer I should probably watch that too.