The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
2answers
93 views

ID properties on Domain objects in DDD

In my domain I have an Account object. e.g. class Account { public string Number; public string SortCode; } Within the context of DDD, should this account object have an ID property? The ...
4
votes
4answers
208 views

How to avoid excessive method overloading?

We have quite a lot of places in the source code of our application , where one class has many methods with same names and different parameters. Those methods always have all the parameters of a ...
6
votes
3answers
178 views

Dependency Injection vs Mixing Levels of Abstraction

I've been reading Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin. One point he makes: G34 Functions should descend only one level of abstraction However, I'm ...
2
votes
2answers
96 views

How to use the Decorator pattern to add little functionality to big objects?

This question regards the usage of the Decorator pattern to add little functionality to objects of large classes. Following the classic Decorator pattern, please consider the following class ...
35
votes
14answers
5k views

How important is it to clean up someone else's code when faced with a tight deadline? [closed]

(I'm talking about HTML / CSS code (not programming languages) but I think we also face the same issue as with programmers.) I am the senior front-end designer in a team and I often have to re-work ...
4
votes
4answers
307 views

Choosing value in SQL query vs (Java) code

I need to choose one of three values of an integer using the value of a column on a nullable column of a table. There are at least two approaches: 1) use SQL to do all the work: test null values, and ...
2
votes
1answer
105 views

Should accessible members of an internal class be internal too?

I'm designing a set of APIs for some applications I'm working on. I want to keep the code style consistent in all the classes I write but I've found that there are a few inconsistencies that I'm ...
2
votes
2answers
345 views

“Clean Code”: How to organize named queries?

Few days ago I started to read Robert C. Martin "Clean Code" book and it encouraged me to look more detailed at my code. After I opened eclipse I saw this: ...
0
votes
1answer
128 views

The user interface in a clean architecture with client / server model [closed]

I have been reading (and watching presentations) about subjects like: DDD, TDD, BDD, SOLID (principles), design patterns, clean code, clean architecture, agile project methodologies. All in all I ...
1
vote
3answers
216 views

How to apply separation of concerns in a very big and messy application [closed]

I have a very big application that is written in C++ but it don't take advantage of the C++ performance and power due to different programmers with different backgrounds the code is a result of 22 ...
9
votes
5answers
561 views

Can a pure-functional solution to this problem be as clean as the imperative?

I have an exercise in Python as follows: a polynomial is given as a tuple of coefficients such that the powers are determined by the indexes, e.g.: (9,7,5) means 9 + 7*x + 5*x^2 write a function to ...
5
votes
2answers
121 views

Should more than one function be used when they do similar, but not identical things?

For example, if I wanted to generate some HTML based on some input. Which is the preferred way out of: <?php function generate_html($type, $input){ switch($type){ case 'paragraph': ...
7
votes
4answers
342 views

What are good ways of balancing informative exceptions and clean code?

With our public SDK, we tend to want to give very informative messages about why an exception occurs. For example: if (interfaceInstance == null) { string errMsg = string.Format( ...
1
vote
1answer
139 views

Further decoupling using static libraries

I've been thinking for a while about reasons that prevent a lot of programmers — myself first of all — from writing clean, modular and expressive code while developing, for example, CocoaTouch apps. ...
3
votes
3answers
579 views

Ordering if conditions for efficiency and clean code [closed]

This is purely a design question and the example is simple to illustrate what I am asking and there are too many permutations of more complex code to provide examples that would cover the topic. I am ...
0
votes
1answer
271 views

Good fix vs Quick fix [duplicate]

Let's start from this principle: quality is a feature that you can't add to a project in the middle of the development process. This is the scenario: two weeks to go live with my project and, one of ...
1
vote
1answer
137 views

Validating data to nest if or not within try and catch

I am validating data, in this case I want one of three ints. I am asking this question, as it is the fundamental principle I'm interested in. This is a basic example, but I am developing best ...
1
vote
1answer
123 views

Writing arguments in constructors

When creating constructors with multiple arguments, is ok to use the generic String[] args or is it better to list the arguments? Does it really make any significant difference as the coding becomes ...
1
vote
2answers
83 views

Whether to separate out methods or not

I am new to java and want to learn best coding practices and understand why one method is better than another, in terms of efficiency and as the coding becomes more complicated. This is just an ...
3
votes
4answers
479 views

Casual projects on Github omit error checking, logging, etc., for the sake of clarity?

I just started using GitHub to socialize some projects for simple chat and peer-to-peer apps. With respect to coding, is it customary to omit exception handling, error checking, logging, etc., to ...
5
votes
2answers
311 views

How to solve “train wreck” properties problem that violates Law Of Demeter?

I've been reading about law of Demeter and I would like to know how to solve this traversing model properties problem that I see a lot on Objective-C. I know that there is a similar question but in ...
3
votes
5answers
381 views

Best practice for code coverage of empty interface methods

Given a class that implements an interface, but does not need all of the methods implemented, what is the best practice for unit testing this class with respect to code coverage? - or is it considered ...
3
votes
3answers
443 views

Avoiding boilerplate in PHP classes

I am working on a PHP code and as it grows getting more and more tired of repeating the same standard pattern again and again and again: class BolerPlate { protected $property1; protected ...
7
votes
3answers
252 views

Where should I put methods that make an Http Request to get data from a web service in iOS development?

I have a Model Car in my iOS application where it's parameters like name, year, value etc are fetched from a web service in order to fill a list with cars data. Where should I put the method that ...
9
votes
6answers
432 views

Is it better to have one method that takes a bool as a parameter or two methods with different names? [duplicate]

I'm writing a factory class for a Selenium Web Driver and I came across a choice that I couldn't figure out which is cleaner. Having two methods with the same parameter. GetWebDriver(string browser) ...
4
votes
2answers
548 views

Are “Clean Code” practices really that clean and useful? [closed]

I am currently doing an internship in a large corporation and they are undergoing many changes in software delivery structure (moving to Agile). In the past couple of months I have noticed this ...
5
votes
5answers
428 views

Is it best to use “get” as a prefix for getters?

if I had a boolean (property) shouldAutoLogin is it better to name the getter getShouldAutoLogin or just shouldAutoLogin so that it reads more like English? ex : if(shouldAutoLogin){ ... } or ...
6
votes
4answers
454 views

How do I introduce clean code? [duplicate]

My team has about 18 members and the code is generally good, using TDD and good specifications makes for working code. But I think they abuse comments in favor of writing cleaner, more readable code. ...
77
votes
23answers
7k views

Is fewer lines of code always better? [closed]

Which of these programming styles is better? var result = methodOne(methodTwo(a, methodThree(b)), c, d); or var result3 = methodThree(b); var result2 = methodTwo(a, result3); var result = ...
1
vote
1answer
75 views

A better approach to refactor code when doing A/B Testing

I'm asked to refactor my component code to support A/B Testing. What is the better approach: 1) Pass a boolean value to the methods and check for that flag inside the method body? method(flag ...
42
votes
12answers
3k views

Coding style (do more, then simplify) [duplicate]

I'm a CS student and I have been coding for a few months shy of a year now, and I seem to have developed what I think may be a "bad" habit and I'm wondering if anyone does the same (or whether it's a ...
5
votes
2answers
245 views

Web API URI Schema Design

I'm in the middle of designing an API for a very basic flashcard application for learning purposes and I'm wondering if you all think there can be any improvements. In the app, a Folder contains ...
4
votes
1answer
600 views

How much usage of “likely” and “unlikely” macros is too much?

The often known as likely and unlikely macros help the compiler know whether an if is usually going to be entered or skipped. Using it results in some (rather minor) performance improvements. I ...
4
votes
7answers
499 views

Naming guard clauses that throw exceptions

I have a function evaluate() that parses a String for some variables and replaces them with their corresponding value: public String evaluate() { String result = templateText; for ...
5
votes
3answers
1k views

Is there a cleaner way of caching data

We've started implementing some caching code in our MVC project. We've derived from .Net's ObjectCache to store it in a SQL database. What we do right now is in each method we want to cache we have ...
3
votes
2answers
345 views

Writing Clean, Elegant Procedural Code (BASIC): Is There Such a Thing?

I learned to code in OO languages. I've always been interested in design patterns, clean code, etc., etc. - you know the type. Now at work I'm using a BASIC dialect. Given modern programming values, ...
4
votes
2answers
329 views

About clean code

Example: I have a method that formats the output based on a parameter from an object. The question is, should I pass the object that holds the parameter to the method, or just the required param? ...
7
votes
3answers
532 views

Cleaning Up Generated Code: Refactor or Map?

Context: I recently had to deal with a class file generated by XSD.exe. It was 3500 lines long with ridiculously-verbose class / variable names (think ...
9
votes
4answers
740 views

Using a “dead man's switch” to manage time-sensitive code

In our software environment, we often run a/b tests, as is probably good practice. However, our environment is set up such that, in very short order, the code starts to become very crufty with dead ...
21
votes
6answers
1k views

How do I prevent unknowningly duplicating code?

I work on a rather large code base. Hundreds of classes, tons of different files, lots of functionality, takes more than 15 minutes to pull down a fresh copy, etc. A big problem with such a large ...
18
votes
3answers
1k views

Does TDD lead to the good design? [duplicate]

I'm in transition from "writing unit tests" state to TDD. I saw as Johannes Brodwall creates quite acceptable design from avoiding any of architecture phase before. I'll ask him soon if it was real ...
8
votes
5answers
615 views

Which is more maintainable — boolean assignment via if/else or boolean expression?

Which would be considered more maintainable? if (a == b) c = true; else c = false; or c = (a == b); I've tried looking in Code Complete, but can't find an answer. I think the first is more ...
1
vote
4answers
286 views

Try/Catch or test parameters [duplicate]

Possible Duplicate: Arguments for or against using Try/Catch as logical operators Efficient try / catch block usage? I was recently on a job interview and I was given a task to write ...
5
votes
2answers
799 views

Constant values in the interface

Some time ago I have read two different books and each of them gives totally different answer for the question if it is a good pattern to define constant values in the interface (in java). So I am ...
10
votes
7answers
905 views

Is it bad style to redundantly check a condition?

I often get to positions in my code where I find myself checking a specific condition over and over again. I want to give you a small example: suppose there is a text file which contains lines ...
2
votes
1answer
257 views

Effective handling of variables in non-object oriented programming

What is the best method to use and share variables between functions in non object-oriented program languages? Let's say that I use 10 parameters from DB, ID and 9 other values linked to it. I need ...
18
votes
7answers
1k views

Does software rot refer primarily to performance, or to messy code?

Wikipedia's definition of software rot focuses on the performance of the software. This is a different usage than I am used to; I had thought of it much more in terms of the cleanliness and design of ...
3
votes
4answers
546 views

Reusable VS clean code - where's the balance?

Let's say I have a data model for a blog posts and have two use-cases of that model - getting all blogposts and getting only blogposts which were written by specific author. There are basically two ...
102
votes
12answers
31k views

Why is Clean Code suggesting avoiding protected variables?

Clean Code suggests avoiding protected variables in the "Vertical Distance" section of the "Formatting" chapter: Concepts that are closely related should be kept vertically close to each other. ...
24
votes
5answers
2k views

Pass ID or Object?

When providing a business logic method to get a domain entity, should the parameter accept an object or an ID? For example, should we do this: public Foo GetItem(int id) {} or this: public Foo ...