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
140 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. ...
0 votes
2 answers
364 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) |...
2 votes
3 answers
241 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: ...
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 ...
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 ...
1 vote
2 answers
355 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* ...
0 votes
1 answer
278 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 ...
-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.: ...