Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best practices in code reuse between different Ruby projects?

guys!

I'm a software developer with Java background and I'm starting some projects using a Ruby web framework (Padrino/Sinatra).

In my java projects, I usually had some "common" projects whose classes where used in several projects. For instance, I had a central authentication service, and a shared database that stored the user profiles. All my projects that used this service shared some models mapped to the user profile database.

So, despite the framework, orm lib etc., what's the best way of sharing code across several Ruby projects?

like image 273
Carlos Melo Avatar asked Dec 01 '11 19:12

Carlos Melo


People also ask

Is it okay to reuse code?

Code reuse is the practice of using existing code for a new function or software. But in order to reuse code, that code needs to be high-quality. And that means it should be safe, secure, and reliable. Developing software that fulfills these requirements is a challenge.

What are the challenges of code reusing?

It combines both technical and non-technical challenges. Reusing software across business units in a large organization needs coordination. It's also not clear which cost centre will fund it. Developers also don't like management forcing them to use components and frameworks developed by another team.

How does the need to reuse code affect how you write your application?

Businesses need rapid app development since they wish to keep up with their competitors and gain the "early-bird advantage" in the market. Using code reuse allows programmers to reuse the same code for similar features in multiple apps, reducing the time it takes to develop new applications.


1 Answers

Besides this, ruby's gems is one of the best way of reusing common parts of code. Gems have names, version numbers, and descriptions and therefore you can easily maintain up-to-date versions of these libraries, install and uninstall, manage your computer’s local installations of gems using the gem command, available from the command line. Gems became standard with Ruby 1.9, but before you have to use require 'rubygems' line in the scripts. There are several tools that help create them, for example, bundler. Bundler not only tool for gem creation, but an awesome application's dependencies manager.

like image 100
WarHog Avatar answered Nov 02 '22 02:11

WarHog