Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've started to learn a little ROR and everthing I read says that ROR espouses the DRY principle and they seem to imply that this is a big thing that makes ROR different from other languages/frameworks.

What language does encourage duplicate code?

share|improve this question
    
php is often considered guilty of this; it's not that php is bad, but it is quite easy to write bad php code. –  ford Mar 6 '12 at 23:55
add comment

2 Answers

It's not that other languages encourage duplicate code, per se, but the DRY principle of Rails people is pretty extreme in that anything that might be considered repetition is programmed away using the metaprogramming features of Ruby.

For example, in many web frameworks, the database schema and the object definitions have the same fields but have to be maintained separately. In C and C++, functions often have to be declared twice—once in a header file and once in the code itself. All of this kind of repetition is strongly deprecated in the RoR ethos.

share|improve this answer
add comment

In the case of modern languages, it's the designs, and moreover, the architectures, that encourage or discourage DRY. Keep in mind that some architectures favor one over the the other. Example: in MVVM, SRP > DRY in most cases. In MVVM you may find several classes and/or data structures that could be considered repetitious, but the main goal is to keep each class beholden to one master rather than to keep one class from repeating the code in another class.

share|improve this answer
    
What is MVVM? What is SRP? –  nohat Feb 1 '11 at 3:31
    
Model-View-ViewModel (MVVM) is a presentation pattern common in WPF (.net). True, it's not a Ruby pattern, but it is an example of how a pattern and / or architecture can encourage the violation of DRY. SRP stands for Single Responsibility Principle: en.wikipedia.org/wiki/Single_responsibility_principle . –  Daniel Auger Feb 1 '11 at 22:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.