The reason rubocop is complaining is that ruby class variables (@@class_variables) are particularly surprising in their semantics.
There are alternative formulations if you really need to store data at the class level rather than the instance level, and have it inheritable-but-overrideable.
However, the first step is understanding the difference between class-level state and instance-level state, to be sure that storing state at the class-level is really what you need. In general, avoiding it is preferable, and I'm not sure it's really what you want to do, I think it's possible you just haven't fully wrapped your head around how object-oriented programming works.
I'm not sure the best resources to develop that understanding. Stuff by Sandi Metz is always good maybe https://www.amazon.com/Practical-Object-Oriented-Design-Ruby-Addison-Wesley/dp/0321721330/ ?
> PHP is particular bad for object-oriented programming
Yeah, I think that's kind of what my manager is thinking as well - he recommended a Ruby book for explaining OOP principles (Practical Object-Oriented Design in Ruby: An Agile Primer). I didn't really want to hop into another language at this point since I'm already waist deep into a few PHP based projects but I'll bump that book up to the top of my to-read bookmarks, I really want to be able to better comprehend OOP.
If you don't mind - Were I to ask my question again, except not specify a language, what'd your opinion be? Would it be better to continue writing and learning a language's fundamentals in a functional programming manner or get your hands dirty with OOP?
Consider 'finding' a copy of this book: https://www.amazon.com/Practical-Object-Oriented-Design-Ruby-Addison-Wesley/dp/0321721330/ref=sr_1_8?ie=UTF8&qid=1528505902&sr=8-8&keywords=ruby+programming It's what really gave me that AHA moment about OOP design. It's short, and don't be turned off that it's Ruby. They don't use any in depth Ruby stuff, it's all pretty simple and Ruby is easily readable. It goes from the first naive implementation, and walks you through improvements and better ways to do things.
I highly recommend Practical Object Oriented Design (POODR) by Sandi Metz. You don't need to worry too much about knowing or investing in Ruby, the principles apply to any Object Oriented language, and Ruby's syntax is really easy to understand.
Sandi Metz's "Practical Object Oriented Development in Ruby" (POODR) was the same way for me.
>Why would that be better?
Because right now your bullet is tightly coupled to other objects that it shouldn't know about. You should, in theory, be able to pass this object around and use it in different contexts without worrying about anything else.
In general, tight coupling is a bad thing that leads to systems that are less flexible and harder to work with over time.
The idea scenario would be that you could create a bullet object without telling it anything about it's wider context, and the bullet would perhaps know about its own properties - perhaps it's a certain type of bullet with a certain type of damage for example. That would be about all it would know.
Then perhaps you have some kind of weapon or gun object that would be able to fire the bullet at a certain velocity, something like that...
The fewer dependencies you have between objects, the easier it is to change your system later.
There's an excellent book on good ideas in object oriented design here: http://www.amazon.co.uk/Practical-Object-Oriented-Design-Ruby/dp/0321721330
It's a Ruby book. I'm not a Ruby developer, but the lessons it teaches are fantastic. I highly recommend reading that book - you will end up with cleaner systems that are easier to work with over time.
The key to good design is a system that delivers all the requirements now while making it as easy as possible to make the next design decision, without necessarily knowing what problems you will need to solve in the future.
Sandy Metz's book Practical Object Oriented Design in Ruby is worth reading on the topic. A big part of what classes are about is encapsulating information, and the methods associated with each class are how you send and receive information about a given object.
+1 to Eloquent Ruby. Very concise and fun read, but I'm not sure it's a great way to learn from scratch. Practical Object-Oriented Design in Ruby is also very good
This is just about the best resource on OO design I've ever read. The reviews tend to back this view up!
http://www.amazon.com/Practical-Object-Oriented-Design-Ruby-Addison-Wesley/dp/0321721330
Don't worry about it being in Ruby specifically, it absolutely applies to any OO language. There is nothing in the book specifically Ruby centric.
I might not be the best person to answer this for you, since I learned Ruby after I already knew programming in general (JS, Python, C, Java) so learning Ruby for me was more about figuring out the Ruby way of doing things than learning how to program. But these are some resources I see recommended a lot that appeal to me:
I've been meaning to read Sandi Metz's book since I've watch some talks she's given and they've been very informative. And searching/browsing/reading the Ruby documentation is something I end up doing almost every day, whenever I'm programming. It's a good reference if you can't quite remember the name of a method, and it's also great to click the "click to toggle source" link so you can see how Ruby's own methods are defined. Some of the most basic and important methods are going to be in C, but a lot of the methods (especially in the std-lib) are themselves written in Ruby, and the C is often simple enough to understand what it's doing if you understand Ruby but don't have any experience with C.
http://www.amazon.com/Practical-Object-Oriented-Design-Ruby-Addison-Wesley/dp/0321721330
and
But, if you truly are an advanced/seasoned dev, you will have no problem picking up the basics of Ruby in 3 weeks. The fine-grained details and subtle nuances, probably not, but that's not a big deal. Really, learning what self is and how it gets set in any given context is all you need to learn, as well as message passing
If you're already experienced in Java/Python, then I don't think you'll really need a book to pick up Ruby. This online guide is probably good enough to get you started.
The main conceptual shift with Ruby coming from Java and Python is that Ruby's style is to be truly object-oriented. POODR by Sandi Metz, along with her conference talks (e.g. https://www.youtube.com/watch?v=OMPfEXIlTVE) are my favorite learning sources.
Happy to help.
BTW this book could also be useful to you , very good book:
http://www.amazon.com/Practical-Object-Oriented-Design-Ruby-Addison-Wesley/dp/0321721330
RubyTapas
Personally I tried learning from books and I found it quite tedious. There's a lot to cover and if you already have experience with other MVC frameworks you feel like you can skip most parts. Probably the best Rails-specific book is Agile Web Development with Rails.
Personally I learnt using CodeSchool and their Rails courses. That way I started hacking stuff myself, some of the Rails Tutorial also doesn't hurt, although I got bored halfway though but still, good stuff, you learn about manually handling users accounts. I dislike cucumber though, but you can ignore that part and/or use other testing library (which you learn in CodeSchool too).
Once you know the basics and the idea of Rails you can get away with google and the official ruby guides for reference, and you really need to pay attention to good OO practices in Ruby, books like Practical Object Oriented Design in Ruby and Confident Ruby are great for overall ruby coding standards :)
I'd recommend Sandi Metz's book POODR
You may also be interested in some of the resources I have on my blog for ruby/rails
Contribute to open source. Create something of your own, and contribute to other projects. Since you are basically self taught and you are going for your first gig, conveying to prospective employers that you care about design, testing, and that you are not a cowboy will help. Read and understand books like Practical Object-Oriented Design in Ruby. Also, don't be a one trick pony. Tackling JavaScript could be a next logical step. Needless to say, all your open source and projects you demonstrate should have good test suites.
Learn about the non-technical stuff as well. I think Land the Tech Job You Love is great, and you probably want to look into Cracking the Coding Interview as a starting point for learning more about algorithms and data structures. Upcase is another great resource for beginning/intermediate Ruby programmers who want to up their game. Start solving challenges on e.g. codewars.com.
If you can find this book https://www.amazon.com/Practical-Object-Oriented-Design-Ruby-Addison-Wesley/dp/0321721330/ref=sr_1_2?ie=UTF8&qid=1524292880&sr=8-2&keywords=object+oriented+ruby That's what finally made it click for me. It's short, good, and Ruby is simple enough you can understand what's going on without knowing the language. And since you're just wanting to reinforce the concepts, you don't really need to code a long in Ruby, you can do it in Java or whatever you want.
check out http://www.amazon.com/Practical-Object-Oriented-Design-Ruby-Addison-Wesley/dp/0321721330/ref=pd_bxgy_b_img_z I just bought, highly recommended, got the recommendation from actual rails devs on IRC #rubyonrails