Linked Questions

78
votes
9answers
16k views

When to use / not use syntactic sugar

Currently I am working on a school project written in C#. Some teammates just started in C# and some are already familiar with C#. Today I had a discussion on whether to use syntactic sugar like this ...
11
votes
3answers
2k views

Is there a conflict between YAGNI and SRP?

I my job, I am tasked with the responsibility of improving the code quality. To meet this responsibility I often pair program with developers and conduct sessions on design principles and design ...
-1
votes
2answers
113 views

Common way to name methods with same name as desired variable? [closed]

I frequently find myself pulling up helper methods in order to make my code better, but end up with duplicate method names. Is there a standard way to name such methods without getting duplicate names?...
0
votes
2answers
657 views

How to prevent 'global variables' in a big project?

With 'global variables', I mean Variables on namespace level Static data members in classes Static variables in functions In a big C++ project I would like to have a mechanism (like a compiler ...
-3
votes
3answers
156 views

Is storing configurations in memory more performance and maintenance efficient? [closed]

My teammate has this class which contains a lot of Strings: public class Config { /** * List of status */ public static final String IN = "bla*"; public static final String ...
2
votes
2answers
136 views

Why should imports be made at the beginning

Why is it considered good style to do all imports in a python application at the beginning, even if what is imported is used only once? I have been programming only shorter pieces of software for a ...
1
vote
2answers
201 views

When should we use wrapper classes for data structures / what is the ideal number of packages

I recently wrote a program in which I wrapped a map data structure to increase the readability of code like so : package wrappers; import model.primary.customer.Customer; import java.util.HashMap;...
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 #...
1
vote
1answer
253 views

Metrics that measure the readability of the function

Functions are the first line of organization in any program.I believe writing them well improves the readability of code to some extent.I am working on metrics that describe how readable the function ...
2
votes
3answers
831 views

How do you denote a variable in a comment?

Let's say I have the following function in Python: def foo(one, two): return one + two And I want to document it with "adds one to two". However, this is confusing, because I could just mean ...
-1
votes
1answer
116 views

Iteration inside a using or using inside an Iteration

Is there a best practice for iterations inside of a "using"? which is better? and maybe a why? "using" inside of an iteration... foreach (var currentPerson in Persons) { using (var db = new ...
4
votes
2answers
506 views

Is using spacing effectively equivalent to the long method code smell?

There's a common code smell involving long methods with the most common answer being that methods should be really small, less than 50 lines per say (or 20). I understand why this is because it ...
-1
votes
3answers
133 views

How to build your class in a readable way [closed]

When developping a project I follow the OOP principles and break my code into classes and most of the time I go for one file = one class. Now I dont know how to organize my code into the class and ...
2
votes
1answer
407 views

Making a test fixture inherit from the SUT class

Some time ago I had to code review a unit-test fixture like this one (C# code): public class ServiceFixture : Service { [Fact] public void Test_DoSomething() { Assert(DoSomething()...
57
votes
9answers
9k views

Readability versus maintainability, special case of writing nested function calls

My coding style for nested function calls is the following: var result_h1 = H1(b1); var result_h2 = H2(b2); var result_g1 = G1(result_h1, result_h2); var result_g2 = G2(c1); var a = F(result_g1, ...

15 30 50 per page