Parth Modi Software Engineer

Optimizing your queries with ActiveRecord

Last week gave a talk about “Querying with Rails” in a meetup organized by the Solute Technolabs LLP. Starting with basics of ActiveRecord, I focused on how Querying becomes difficult and complicated down the road with ever increasing features, and how to leverage ActiveRecord associations, joins, scopes and class methods.

Have a look at presentation:

Querying with Rails from Parth Modi

As always, feel free to share your feedback!

Read More

Modeling Has Many Relationships with DynamoDB

DynamoDB is ideal when you need consistent high performance with large data effectively. Being NoSQL database, normalization isn’t much benefical and hence associations and joins are not formed exactly how they are in SQL databases. In this article I explained how to form has_many Relationships with DynamoDB.

Modeling has_many Relationships with DynamoDB

Coming from a strong SQL background and being a fan of using ORM such as Active Record, adapting to the NoSQL mindset gave me an opportunity to rethink and explore the capabilities of NoSQL. But soon I realized that normalization is not always the right choice in the case of NoSQL databases. And more important, handling relations is a bit different.

Hope you find this useful, share your feedback.

Read More

Dry your RSpec Tests with Shared Examples

When I refactored a project a few weeks ago, I spent most of my time writing specs. After writing several similar test cases for some APIs, I started to wonder whether I might be able to get rid of a lot of this duplication.

So I threw myself into reading up on the best practices for DRYing up tests (Don’t Repeat Yourself). And that’s how I came to know of shared examples and shared contexts.

In my case, I ended up using shared examples. And here’s what I’ve learned so far from applying these.

When you have multiple specs that describes similar behavior, it might be better to extract redundant examples in shared examples and use them in multiple specs.

Read More