The dry tag has no wiki summary.
0
votes
0answers
34 views
Does this code follow loose coupling pattern or should be refactored/re-designed?
I've to adming i don't like this design.
The main class (SMSHelper) is responsible of query a REST web service which in turn returns an XML string. This helper is going to return a new SMSCreditInfo ...
1
vote
2answers
62 views
Bubble sort algorithm in Ruby with tests
As a matter of practice, I tried implementing a bubble sort algorithm in Ruby. I'm especially interested in creating clean DRY and KISS code and keeping things readable, but efficient. Any hints to ...
1
vote
1answer
37 views
Downsampling boundaries of a 2D array
I have a linearized 2D array u (block_height * block_width) containing the values of a physical quantity over a regular 2D mesh. I need to downsample boundaries (top, bottom, left, right) of this ...
4
votes
1answer
78 views
Is this violating the DRY principle?
I feel that I am repeating myself a lot with this HTML/PHP code. Am I right, and is there a maintainable way of reducing the amount of repetition in the code?
mydomain/index.php:
<!DOCTYPE ...
3
votes
2answers
127 views
How to avoid repetition
The program is supposed perform discrete mathematics operations on a number of conjunctive statements (see lines 34 - 50). Currently I just have it so they print out the tables in 0's and 1's, but ...
1
vote
2answers
59 views
Get device orientation
Here is my code:
// get orientation of device
getOrientation();
// animate
var num = 400;
if( $('body').hasClass("landscape") ) {
$('.example').animate({'bottom', 0});
} else {
...
3
votes
4answers
185 views
Duplicate code in nested if statement
I have some code that looks like this:
if (condition1) {
doSomeObjectSetup();
try {
saveObjectToDatabase()
return theObject;
} catch (ValidationException) {
...
2
votes
3answers
250 views
Simple jQuery validation script works but it uses a ton of if/else statements
I've a jQuery validation script to check all form fields for a valid value and prevent form submission and display an error message if any fields fail. It was requested that the validation script not ...
3
votes
1answer
115 views
When to use a new variable vs string interpolation?
I wrote a script that I decided to refactor so I could add functionality to it as my coworkers think of it. I only saved four lines in the effort, but the main change is I removed both methods and ...
5
votes
3answers
222 views
Does using a lambda make this code more DRY?
I started out with a function having code duplication like this:
private static void GetAndSaveResources(string url)
{
...
if (url.Contains("[" + "access_id" + "]"))
...
1
vote
1answer
41 views
Select records and fill hash
I use ruby 1.8.7. I have method wich select records and fill hash. In my opinion the code is not dry. Could somebody help me to refactor it and make it shorter and more elegant?
def fill_attributes()
...
1
vote
2answers
135 views
should DRY apply to unit tests as much as production code
I have a unit test method that looks like this:
...
113 CPPUNIT_ASSERT( !m_pInputFilter[0]->SendPacket() );
114
115 CppUnitUtil::CUnitTestTimeline::GetInstance().Advance( 1, CppUnitUtil::Seconds ...
2
votes
4answers
194 views
Make this C# code more DRY
public sealed class LinkXPathRepository : ILinkXPathRepository
{
private static readonly ILog _log = LogManager.GetLogger(typeof(LinkXPathRepository));
internal ILink Parse(Uri endpoint)
...
4
votes
1answer
185 views
Prepared statements syntax review
Migrating to using prepared statements and would like some feedback on CRUD modules, concerned with syntax (usage and DRY) and speed:
START:
<?php
// This page is for deleting a user record.
// ...
1
vote
2answers
109 views
Refactoring custom validator using lots of if's
I have a custom validator that checks the min and max score of different sporting leagues -- e.g., MLB, NBA, NFL, NCAAB, etc.
Here's short version of what it looks like:
class ScoreValidator < ...