The language-agnostic tag has no wiki summary.
3
votes
2answers
45 views
Default value or conditional?
Which of the following two is preferred:
var somevar = valueA;
if(condition) {
somevar = valueB;
}
or:
var somevar;
if(condition) {
somevar = valueB;
} else {
somevar = valueA;
}
?
...
1
vote
2answers
155 views
How to Format Clean Accumulation Code?
I often find myself writing methods in languages such as Java or C++ that are only meant to loop over an array or something similar, accumulate the values, and then return the total. The problem is, ...
3
votes
1answer
37 views
Choice of variable names for paths/filenames [closed]
I give this names such as logFilePath:
C:\Users\Felix\Programming\Logfiles
I call this logFileName:
myprogram01.log
But when I have this:
...
1
vote
1answer
181 views
Best way to implement a web MVC application (language agnostic)
Well, the questions is a little bit broader, so I'll assume that the basics is already defined:
Controller
FrontController
Controllers (plugin hooks, request/response object, view handler)
View
...
1
vote
1answer
112 views
Recursive notation and how to make recursive call to a function that isn't inherently recursive?
Two Questions
I want to build a function X that makes n recursive calls to a function Y that isn't inherently recursive.
Y(a,b) is not "inherently recursive" in the sense of not having self calls ...
5
votes
3answers
169 views
Can anyone make my O(n^3) function more efficient, or offer suggestions to make handling it more efficient?
I'm trying to devise a way to calculate the mean differences (the absolute average differences between any two values in a set), of sub-arrays (starting from arbitrary indices) in an int array. I'll ...
21
votes
8answers
1k views
Is it bad to use a ternary inside of an if condition?
Let's suppose I have some sort of form that automatically performs a copy procedure when the user either focuses on a textbox, or highlights some text.
Let's suppose that the user has a preference of ...
4
votes
4answers
119 views
Again on nested IF
Sometimes I use something like:
private void Test()
{
success = false;
while (true)
{
if ( ! Action1() ) break;
if ( ! Action2() ) break;
if ( ! Action3() ) break;
...
3
votes
5answers
1k views
Empty method in abstract class
I have an abstract class which holds a hook method for a template method. Not all classes which extend this class will need to implement this method (in fact most will not, but a few will). As such ...
3
votes
2answers
156 views
nested if-s vs. multiple if-s
Which one if better, and why?
Eg.
if (conditionA && conditionB) {
//do something
} else if (conditionA) {
//do something else
} else if (condition C) {
...
}
or
if (conditionA) {
...
3
votes
6answers
748 views
Constructors - lots of paramters or none and use of set methods
In your opinion what is the best way to construct an object given the two examples below:
Option 1: Lots of parameters
private string firstname;
private string surname;
private Address homeAddress;
...
4
votes
2answers
386 views
I'm not crazy, right? Endless IF statements… This is a bad pattern, yes?
For the example I'm using psudocode.
I'm only asking, because almost the entire code base I've inherited here, in C# and php looks like this:
if (varOne == flag) {
run_some_sql();
...
8
votes
7answers
405 views
Is it better to put more logic in a for loop condition, or to use a while loop?
I had this as an interview question, and the interviewer pointed this out. Here's what I wrote:
//C# Syntax here
public string Reverse(string s)
{
char[] arr = s.ToCharArray();
int idx = 0;
...
4
votes
2answers
203 views
Code review workflow feedback [closed]
here is what is happening where a 'friend' of mine works:
one person is working on an interface for future functionality. (Person A)
two (or more) are waiting on said interface for their work, ...
3
votes
2answers
316 views
Using continuous integration servers output for code review [closed]
For many languages there are many QA Tools often used together with and CI Server like Hudson or Bamboo.
While this question might be a bit off topic from my experience code review and CI go and in ...