Rails on Rails Development Guidelines - Part-3 – Fundamentals of OOPs, SQL, Web and Rails
Adding third part in the series of “Rails on Rails Development Guidelines” now, you can refer to previous article here.
In the previous article, we talked about the prerequisites before we can go further. Here we are going to talk about how can we improve our knowledge for OOPs/SQL/ActiveRecords to code better.
This includes ruby programming basic syntax as well as the effectiveness/utilisation of the overall language constructs/libraries. We have to practice more and more to make the subconsciousness to think and work automatically. We can refer to the following,
- “The ruby programming language” – A book by Matsumoto. This is the first thing which must be read.
- “Ruby best practices” – A book by Gregory Brown. This covers advanced topics like tests, API designing, Functional programming techniques. This is a must read for seasoned programmers, if you don’t understand basic programmes or logic, then don’t start on this!
- “Practical Object Oriented design in ruby” – A book by Sandi Metz. This books talks about OOPs fundamentals with Ruby, S.O.L.I.D principles, Tests etc. Following is the list we must master,
- Class, Module, Object, Instance/class variables, constants, access modifiers (protected/private)
- Inheritance : Parent child relationship, where child inherit some behaviour and properties from Parent. One class extends another, and overriding the behaviour using methods, method lookup at runtime.
- Encapsulation : bind the data inside an Object, to make certain meaningful representation. - private attributes and getter/setter (accessor) methods to access them.
- Polymorphism : One task can be done in diff. ways, like Draw a Triangle/Circle etc.
- Abstraction : Hiding the implementation, and define only the functionality. - same example as 3rd point, but here method would be hiding the internal implementation details.
- S.O.L.I.D : https://scotch.io/bar-talk/s-o-l-i-d-the-first-five-principles-of-object-oriented-design#dependency-inversion-principle
- S - Single-responsibility principle - A class or method should have only one job.
- O - Open-closed principle - Objects or entities should be open for extension, but closed for modification.
- L - Liskov substitution principle - Every subclass/derived class should be substitutable for their base/parent class.
- I - Interface segregation principle - A client (caller of the class/method) should never be forced to implement an interface that it doesn’t use or clients shouldn’t be forced to depend on methods they do not use.
- D - Dependency Inversion Principle The high level module must not depend on the low level module, but they should depend on abstractions.
Before we can move onto learn how to build web application, we need to understand the basics of web world. This includes learning about Cookies, Session, Request, Response, Server, Client, AJAX, XML, HTML/CSS etc. These are standard items to be used for any kind of web application.
SQL (Structured Query Language)
Any kind of web application would require us to store/fetch data to/from databases (MySql/Postgres/SQLServer etc.). SQL is the common language used to access and operate on database servers. This includes the SQL as a language, database design (generalisation/normalisation), fundamentals of database - Connection, views, indexes, primary/foreign keys, joins (inner/outer/left/right/self). Basically, we must have a basic knowledge of database operations and usage!
Once we are through above everything, we can go ahead and start on Rails! Pretty much huh? But without it we would not be able to think and act “what to do”. Now, Rails includes the following,
- Basics of Rails - config, initializers, assets, concerns (Models, helpers and controllers), view helpers, haml/slim/liquid(used by shopify), partials
- ActiveRecords - Models, joins, associations.
- Refer to “Rails 4 way” by David Hansson. This will help learning the basics of Rails.
- Once you have mastered Rails, refer to “Rails anti-patterns” by Chad Pytel and Tammer Saleh. This talks about standard practices for Rails and the patterns we should/must-not use while designing the application components.
- This is something which you learn by experience, by reviewing code of others (in the team OR open source), by writing more code on your own and fixing design issues, by identifying better approaches to do something. It’s more of a practice thing.
- You must refer to “Refactoring Ruby Edition” by Martin Fowler. This book is for advanced programmers and talks about refactoring ideas by showing examples in Ruby.
That’s it for this part, Keep reading 🙂
At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.
Consulting is free – let us help you grow!
Choose Your Language
- Digital Marketing
- IT Consulting
- Project Management