Questions tagged [coding-style]
Coding style is a set of guidelines that helps readability and understanding of the source code.
                1,064 questions
            
            
            
                -1
            
            votes
        
        
            
                1
            
            answer
        
        
            
                134
            
            views
        
        
            
            
            
        How to organize struct-based "methods" in C similar to object-oriented style? [closed]
                    So I was coding in C for a while now, getting used to language syntax and different styles.
Implemented a couple of simple data structures, algorithms and tried my skills in making Minesweeper clone.
...
                
            
       
        
            
                2
            
            votes
        
        
            
                4
            
            answers
        
        
            
                484
            
            views
        
        
            
            
            
        How to combine multiple functions into a single template based function
                    Threre are two functions FindMaxDistanceVector and FindMaxDistanceList whose implementation is almost same except some debug information added in FindMaxDistanceList. Note that these two functions are ...
                
            
       
        
            
                0
            
            votes
        
        
            
                2
            
            answers
        
        
            
                362
            
            views
        
        
            
            
            
        Which is better: a chain of OR statements or IF in a loop? (Java)
                    Which code style is preferred in Java?
final boolean result = isCausedBy(e, ExceptionType1.class)
        || isCausedBy(e, ExceptionType2.class)
        || isCausedBy(e, ExceptionType3.class)
        |...
                
            
       
        
            
                1
            
            vote
        
        
            
                3
            
            answers
        
        
            
                308
            
            views
        
        
            
            
        Considering IDE and text editor features when choosing a coding style
                    Recently, I had a debate with one of my friends on using type inference in C# (var keyword). His argument was that we should stick to using the explicit type names because "even with the ...
                
            
       
        
            
                2
            
            votes
        
        
            
                3
            
            answers
        
        
            
                239
            
            views
        
        
            
            
        Is it still "feature envy" if the state to make decision or the action to take after asking the state involves other classes to participate?
                    According to https://softwareengineering.stackexchange.com/a/212130/432039, if a class asks another class for the state, and then call methods of that class, it is called "feature envy", eg:
...
                
            
       
        
            
                10
            
            votes
        
        
            
                4
            
            answers
        
        
            
                2k
            
            views
        
        
            
            
            
        Is the inability to find code by searching for a class name a reason to avoid using auto in c++ variable declarations?
                    According to https://softwareengineering.stackexchange.com/a/180616/432039 suggested, I know the answer advised "auto" should be used instead of the actual type when declaring variables.
...
                
            
       
        
            
                1
            
            vote
        
        
            
                5
            
            answers
        
        
            
                253
            
            views
        
        
            
            
        End method in normal flow versus exception flow [duplicate]
                    Consider the two following examples:
public Something fetchSomething(String key) {
    if(somethingsMap.containsKey(key)) {
        return somethingsMap.get(key);
    }
    throw new ...
                
            
       
        
            
                6
            
            votes
        
        
            
                4
            
            answers
        
        
            
                3k
            
            views
        
        
            
            
            
        How do you honour the principle to only do "one thing" in a method in reactive streams?
                    Uncle Bob mentions in his book "Clean Code" that "[f]unctions should do one thing [...] only" and advocates that a method should stick to one abstraction level (I'd call it flight ...
                
            
       
        
            
                14
            
            votes
        
        
            
                5
            
            answers
        
        
            
                5k
            
            views
        
        
            
            
            
        How to "Tell, don't ask" when 2 objects involves in the condition and the decision at the same time?
                    According to Explanation on how "Tell, Don't Ask" is considered good OO, I know the following is bad:
if(a.isX){
    a.doY();
}
public class A{
    public boolean isX;
    public void ...
                
            
       
        
            
                0
            
            votes
        
        
            
                4
            
            answers
        
        
            
                433
            
            views
        
        
            
            
            
        Code quality: expressiveness vs. conciseness
                    I've been wondering about code expressiveness vs. conciseness lately. What I mean by that is that a lot of modern programming languages offer features to express statements in a very short manner, ...
                
            
       
        
            
                1
            
            vote
        
        
            
                2
            
            answers
        
        
            
                349
            
            views
        
        
            
            
        What is an appropriate length for function names? [closed]
                    I'm writing a C++ class, CBookSpellDef which has the following methods:
    int     GetIndexOf(const char *psz);
    char*   GetNameAtIndex(int index) { return m_spellTypes[index].szName; }
    char*  ...
                
            
       
        
            
                24
            
            votes
        
        
            
                11
            
            answers
        
        
            
                8k
            
            views
        
        
            
            
            
        Is it logical to not use inheritance because the function is critical?
                    Our codebase has a typical base-class with a ton of sub-classes. The base-class already has many default functions for the sub-classes.
However, one particular function has the same verbatim ...
                
            
       
        
            
                0
            
            votes
        
        
            
                1
            
            answer
        
        
            
                275
            
            views
        
        
            
            
        How to deal with very complex codebase? [duplicate]
                    I recently changed my job to a big MNC and the code I am exposed to is highly complicated, difficult to read and understand. Although it is divided in microservices and runs on local I have to keep ...
                
            
       
        
            
                17
            
            votes
        
        
            
                8
            
            answers
        
        
            
                7k
            
            views
        
        
            
            
            
        How to be (more) critical during Code Reviews? [closed]
                    I'm a Software Engineer who sometimes need to review the code of my fellow team members. I often look at the source code and think; this looks fine. I'm having a hard time to think critical about it. ...
                
            
       
        
            
                -2
            
            votes
        
        
            
                3
            
            answers
        
        
            
                1k
            
            views
        
        
            
            
            
        Common practice where to place "is" word while naming predicate function: at the beginning or in the middle?
                    There's a lot of free or member predicate-like functions (that returns boolean value) in different programming languages and popular libraries/frameworks that have "is" as a prefix, e.g.:
...
                
            
       
         
         
         
        