Linked Questions

16
votes
7answers
2k views

What can one do to improve readability of math-oriented code in C#, Java, and similar? [closed]

As both a C programmer and a C# programmer, one of the things I don't like about C# is how verbose math functions are. Every time you would have to use a Sin, cosine, or power function for example, ...
8
votes
4answers
4k views

Should you ever use private on fields and methods in C#?

I am somewhat new to C# and just found out that: in C# all of the fields and methods in a class are default private. Meaning that this: class MyClass { string myString } is the same as: class ...
15
votes
7answers
4k views

Should I write compact code or code with lots of spaces? [duplicate]

I have two friends that have completely different schools of thought on how to lay out their code. The first says that code should be well-indented and use lots of spaces and to name variables ...
18
votes
7answers
950 views

How to improve the training of students regarding maintainability? [closed]

Maintainability is a major stake of professional software development. Indeed, maintenance is nearly always the longest part of a software life cycle, as it lasts from the project release until ...
15
votes
4answers
3k views

Is it overkill to wrap a collection in a simple class only for the sake of better readability?

I have the following map: Map<Double, List<SoundEvent>> soundEventCells = new HashMap<Double, List<SoundEvent>>(); This HashMap maps double values (which are points in time) ...
13
votes
3answers
1k views

Is using C/C++ macros as a shortcut for conditional compilation a good practice?

Let's say I want to have several types of output messages in my code. One of them is DEBUG, which is printed only, when the code is compiled in Debug mode. Usually I'd have to write something like #...
5
votes
9answers
2k views

Is it better to have separate functions or add more arguments to a function? [closed]

Which is the better style to follow for say, changing the voltage on a 4 channel PSU: setChannelOneVoltage(voltage) setChannelTwoVoltage(voltage) setChannelThreeVoltage(voltage) setChannelFourVoltage(...
4
votes
4answers
681 views

readability vs shorter code in returning from function [closed]

In something as simple as int sq(int x) { int y = x*x; return y; } versus int sq(int x) { return (x*x); } the former function requires an extra IL step. EDIT: IL code from the first example, ...
8
votes
4answers
1k views

Are trivial protected getters blatant overkill?

Something I really have not thought about before (AS3 syntax): private var m_obj:Object; protected function get obj():Object { return m_obj; } private var m_str:String; protected function get ...
4
votes
4answers
662 views

Is removing duplication worth it when it doesn't reduce code size?

Yesterday, I removed duplication in a file. The code was performing translations in a grid[i][j]. The duplication was between the code for the i-axis and the code for the j-axis: For instance, I ...
6
votes
7answers
696 views

As a novice, how can I best overcome the complexity of larger projects?

Currently, I'm a student and I can tackle all my assignments which only require, at most, 3-5 classes to implement. Now, I'm wanting to develop programs on a bigger scale but I am having a really ...
8
votes
4answers
7k views

How to avoid javascript becoming spaghetti code?

I've done quite a lot of javascript over the years and I'm using a more object-oriented approach, specifically with the module pattern. Which kind of approach do you do use to avoid a bigger code-base ...
4
votes
4answers
483 views

Please explain why we need SRP in “Plain English” despite its drawbacks?

Can you in "plain English" explain why we need Single Responsibility Principle? Especially that it moves the what I call "bloat" into other places. See below for more info. By bloat I mean in my ...
10
votes
3answers
4k views

Cleanest way to write logically procedural software in an OO language

I'm an electrical engineer and I don't know what the hell I'm doing. Please save the future maintainers of my code. Recently I've been working on a number of smaller programs (in C#) whose ...
7
votes
3answers
2k views

What is the best practice around De Morgan's Law [closed]

We all know De Morgan's Laws !(a && b) === (!a || !b) !(a || b) === (!a && !b) Is there a community consensus around which one of these representations is easier to reason about (and ...

15 30 50 per page