Linked Questions

4
votes
2answers
5k 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
3answers
6k views

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

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

Java naming conventions vs. C++/C naming conventions

I am a Java developer who is starting to pick up more and more C++/C (yes I know they're different, bear with me). One thing that struck me as odd was the different naming conventions used by these ...
2
votes
2answers
14k views

Print Statements Inside Function Or Before Calling It? [closed]

I have a script which different people may use. I have print statements so people can follow along what the script is doing, and if it breaks where it went wrong, and if a certain step takes a long ...
7
votes
6answers
1k views

what is the best way to ensure accountability in code checkins?

Note: after writing this I realize that this question is perhaps philosophical, but I'm interested in how the industry handles this scenario regardless. I have recently been working with a code base ...
5
votes
5answers
1k views

When decomposing a large function, how can I avoid the complexity from the extra subfunctions?

Say I have a large function like the following: function do_lots_of_stuff(){ { //subpart 1 ... } ... { //subpart N ... } } a common pattern is to decompose it into ...
10
votes
1answer
822 views

Trouble grasping what clean code looks like in real life

I am currently reading and working through "Clean Code: A Handbook of Agile Software Craftsmanship" by Robert C. Martin. The author talks about how a function should do one thing only, and thus be ...
3
votes
2answers
13k views

python code style for long lists [closed]

when coding a very long list in python, is it better to fit several items on each line or should I limit it to 1 per line? 99% of the time I would go with style2 below but I have 5 lists each about ...
6
votes
3answers
677 views

Overloading methods that do logically different things, does this break any major principles?

This is something that's been bugging me for a bit now. In some cases you see code that is a series of overloads, but when you look at the actual implementation you realize they do logically different ...
3
votes
4answers
2k views

How does a developer code in anticipation of change? [closed]

I ask this question based on the fact that currently my environment is under constant change due to the type of work we do. We do not always work on a project bases we often have smaller changes that ...
4
votes
2answers
503 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 ...
9
votes
2answers
3k views

Is implementing an interface defined in a subpackage an anti-pattern?

Let's say I have the following: package me.my.pkg; public interface Something { /* ... couple of methods go here ... */ } and: package me.my; import me.my.pkg.Something; public class SomeClass ...
3
votes
4answers
989 views

When, Where, and How to Unit Test [duplicate]

I'm very familiar with xUnit frameworks and I try to implement unit tests on every project I start. Somewhere along the way, I realize that I'm writing the same tests over and over again, and then I ...
0
votes
2answers
581 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
2k views

Private string constants for map keys

Is it good practice to define private constant strings that have the same name as their values? Take the following code for example. public class Example { private static final String FIRST_KEY =...

15 30 50 per page