Linked Questions

3
votes
3answers
8k views

Is it really correct to declare all instance attributes in __init__

According to Pycharm (and thus assume according by PEP) i should state all instance attributes directly inside __init__. In my case it does not seem suitable to me. I have something like: class ...
3
votes
4answers
8k views

Is overriding a pure virtual function with default arguments good or bad?

Is overriding a pure virtual function with default arguments good or bad? class Base { public: virtual int func(int i, int j = 10) = 0; }; class Derived : public Base { public: int func(int ...
0
votes
3answers
228 views

Is relying on an IDE for code readability acceptable

During my years developing software I have most of the times tried to improve the readability of my code. As one example, I often try not to use boolean flag parameters of methods and I try to ...
3
votes
5answers
7k views

Check for empty PHP array

An empty array in PHP is considered falsey. That means the following will not print anything as the array is empty. <?php $myArray = array() if ( $myArray ) { print "My Array is NOT empty"; } ...
1
vote
1answer
132 views

Should I use an `else lif` or an `if` for the second of two consecutive assertions?

Here's an example of my question in python. Notice there's only a very subtle difference: changing an if to an elif. There's no difference in behavior; if the first if statement is executed, the ...
81
votes
9answers
17k 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 ...
12
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 ...
4
votes
2answers
516 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 ...
48
votes
18answers
32k views

What is proven as a good maximum length of a function? [closed]

Does function length affect the productivity of a programmer? If so, what is a good maximum number of lines to avoid productivity loss? Since this is a highly opinionated topic please back up the ...
12
votes
4answers
5k 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 ...
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) ...
6
votes
2answers
258 views

What time horizon and level of abstraction is the right for the maintainable and evolvable software? [closed]

From time to time I feel exhausted in my software development efforts because I am pressed to think and develop in very specific and very short term manner. One client here and now requires one ...
-1
votes
2answers
119 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?...
47
votes
5answers
29k views

At what point/range is a code file too big?

I'm finding lots of 2-3k line files, and it doesn't really feel like they should be that big. What is a good criteria to objectively call a source code file "too big"?, is there such thing as a ...
0
votes
2answers
874 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 ...

15 30 50 per page
1
2 3 4 5
9