Questions tagged [conventions]
The conventions tag has no usage guidance.
123
questions
4
votes
6
answers
316
views
Naming a method that does the same thing faster but only approximates the result?
Presume I have a function that does some precise calculation on a large amount of data, call it calculateResult(data).
This function gets very slow with increasing size of input.
Luckily, I only need ...
0
votes
2
answers
123
views
Usage of overrides in the State design pattern
Imagine a situation where out of 5 state implementation classes the implementation of a method only differs on 2 of them (i.e. 3/5 share the same implementation for a particular method).
This ...
8
votes
4
answers
506
views
Are there advantages to using an interface, rather than a class, for a Java application?
Java is often (rightly IMHO criticized) for overusing the class keyword, as it can denote:
a factory to instantiate objects (traditional classes)
a collection of global methods (when all methods are ...
1
vote
4
answers
291
views
Looking for a sanity check, do you alphabetize your code? Is that even a thing? [closed]
I'm currently working with a group of developers (as outside contractors) on an existing codebase (in kotlin) and the lead dev (the client) is blocking merging of pull requests (GitHub) because ...
7
votes
5
answers
2k
views
Should an optional boolean function argument rather default to true or false?
In many cases I can formulate some boolean parameter equally well positively as negatively, e.g. isOn or isOff. Which one should I pick then, in case I want the argument to have a default value? Is ...
2
votes
3
answers
167
views
Should I ensure my libfoo library's include file can be included as foo/foo.h?
I'm maintaining a small C library; let's call it libfoo. It has quite a few users (actually it's complicated - it's the main fork of a highly popular library which has been abandoned); and it sports a ...
0
votes
5
answers
129
views
best practice for error handling between PAM_SUCCESS and PAM_AUTH_ERR macros
We have two exit code code PAM_SUCCESS(0), PAM_AUTH_ERR(7).
If we wanna return 0 or 7 when we compared password with our password in following code which code is better that this code ?
if (strcmp (...
1
vote
1
answer
1k
views
How can I write good Conventional Commit-style commit messages for one feature over multiple commits?
If I am working on a single feature, I would usually commit multiple commits. Should every commit start with feat? Or should only 1 commit have the type of feat and use a different type for the other ...
0
votes
3
answers
246
views
What is this numeral system notation?
I used Google search to convert numbers from one numeral system to another.
10 to binary is 0b1010;
10 to hexadecimal is 0xA.
What's the meaning of 'b' and 'x', accordingly? I think these are ...
-2
votes
1
answer
1k
views
Git semantic commit versioning for file deletions
What commit type should I use when I'm deleting files from a repo?
I have seen several types over the internet, but none talk about file deletions.
Possibly the closest options that come to mind are ...
2
votes
0
answers
554
views
Broker queue and topic naming conventions
I'm in the process of adding a message broker (ActiveMQ Artemis) to a system currently and while I have my own notions on how I can divide up the namespace, it seems like a good time to get opinions ...
0
votes
2
answers
394
views
Should default settings be considered as business rules from the viewpoint of "Clean Architecture"?
The examples of default settings:
Default port for server applications
Default resources directory for Java Applications
Default Webpack config file ("webpack.config.js")
My particular ...
-2
votes
5
answers
312
views
Why does today's companies follow old RFC's?
Let me start by saying that of course conventions are important, there should be a rule of thumb for some cases that is representing the best action to follow by, in order to prevent mistakes and make ...
3
votes
1
answer
505
views
Why is it not the case that all d-tors of virtual C++ classes be virtual?
I am basically plagiarizing When NOT to use virtual destructors?. The excellent answers remind us that C++ is pay only for what you use.
However, the Standard is a couple of thousand pages long. The d-...
2
votes
2
answers
528
views
Does it make sense to use meaningless named constants?
For example, does it make sense to refactor the following code:
a = a * 2;
as:
const int INT_TWO = 2;
// ...
a = a * INT_TWO;
My question hinges on the fact that the new constant conveys no ...
0
votes
2
answers
198
views
How to divide responsibility between poco, writer and converter
I have several POCO´s (simple classes holding data) that I have need to flush from memory from time to time whenever a collection grows too large. Most often I want to upload the data to a REST ...
1
vote
0
answers
36
views
Standard way to bulk crud image with caption in an API?
I am trying to build a API for doing CRUD on images with their caption. So far I can think of
option1: sending the images in form-data as list of images and their corresponding captions in another ...
-4
votes
1
answer
91
views
Java Class Structure
I have a problem during a project of mine using Java,
as usual my java classes have the structure:
import ...;
import ...;
...
private Type0 myVariable0;
private Type1 myVariable1;
...
...
private ...
9
votes
1
answer
1k
views
What does "TILT" mean in a comment?
I'm reading Clean Code by Robert C. Martin, and the phrase TILT inexplicably appears in some code samples. Example (it's in Java, by the way):
...
public String errorMessage() {
switch (...
1
vote
0
answers
48
views
HTTP/REST and chained processing protocol/convention
Is there a protocol or a convention that supports REST (ok, maybe we should use HTTP here instead) processing chain and some neat features to help with that? Let me explain what I mean.
Let's assume ...
-4
votes
1
answer
90
views
Public var vs protected var and get function [closed]
I've noticed this style of code a lot in frameworks like Symfony and Magento 2 (which is based on Symfony):
<?php
class Foo
{
protected $foo;
# construct function - not ...
3
votes
2
answers
3k
views
Is there a term for functions starting with the "Is" prefix?
There are a number of functions of a kind; returning a boolean, and the name always starts with the "Is" prefix.
e.g. IsAlive(), IsDead(), IsKeyPressed(), IsKeyReleased(), etc.
How do we categorize ...
1
vote
1
answer
323
views
Difference between failed and canceled task
In case we hav functions (f_1,....,f_n) which runs in this order somewhere in the future.
I would like to define a relationship between those functions such that if f_i failed due to expection then ...
3
votes
1
answer
446
views
Naming Convention [closed]
When we determine names for the variables, there are two important issues that the people mention:
The variable names must be explanatory. For the sake of this, their names can be long.`
The variable ...
36
votes
5
answers
7k
views
Is it enough for methods to be distinguished just by argument name (not type)?
Is it enough for methods to be distinguished just by argument name (not type) or is it better to name it more explicitly?
For example T Find<T>(int id) vs T FindById<T>(int id).
Is there ...
1
vote
1
answer
118
views
Does any scale exist (e.g. naming convention to be used for sizes) that allows trivial insertions at any point in the scale?
Question probably sounds confusing so let me clarify.
Let's say I have an object containing keys and values for my project's font sizes:
{
small: '8px',
medium: '11px',
large: '14px',
}
...
2
votes
3
answers
1k
views
Convention for labelling coordinate axes in 3d graphics
When I recently started doing some 3d graphics, I carefully (tried to be careful, anyway) decided to use the conventional mathematical standard for labelling axes, which was much more convenient for "...
2
votes
3
answers
910
views
Why do we follow Convention?
Preface: I am not arguing against convention but rather want to have a greater understanding why convention is something I should follow and what are the benefits/drawbacks of doing so.
I have found ...
1
vote
1
answer
586
views
Naming standards or conventions for ecommerce
Naming things
There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton
Naming things seems so trivial, before I read this quote, I would have ...
2
votes
1
answer
288
views
Is the URL 'users/new' RESTful?
I was in a job interview demo-ing a RESTful API in Flask when an argument broke about the API. The interviewer argued that the URL for adding a new user (/users/new) is not proper REST.
My API ...
2
votes
1
answer
2k
views
Proper modeling and name convention for an intermediate table between intermediates
I have 4 entities: Event, Message, Flow and Document.
Event table stores a limited (seeded) number of records. Message has many events and each event can be related to many messages. The name ...
-7
votes
1
answer
559
views
Where should I store data related to UI/presentation?
Say, I have a table Categories. On a page I have a header and for each category the colour of a header varies.
A colour is of the presentation level and I've heard that what's related to the UI/...
3
votes
2
answers
147
views
Ajax response -- is there an agreement on the structure?
Say, I make an ajax request to a server from a page, something like "show more articles". Is there a common agreement on the format or rather structure in which a result should be returned?
Something ...
1
vote
1
answer
2k
views
Where to place Docker-related configuration files
Many projects need more than a Dockerfile or a docker-compose.yml in their root to work out of the box (e.g. for local development or a demo): For example a web application might need its runtime, a ...
3
votes
1
answer
194
views
Naming a view class
I'm a little hesitant on what to name a view class.
I have a view class which I call ChooseImageView because that's what the user does in that view. After the user has chosen an image I display a ...
1
vote
1
answer
797
views
ASP.NET MVC test structure and naming conventions
I decided to take the plunge and add the first set of integration and units tests to the projects I work on (yes, we have dozens of internal applications with no automated testing whatsoever...).
I ...
1
vote
1
answer
497
views
The format of an response in ajax — any convention/recommendations?
Say I have a lot of page with ajax. Is there any convention or recommendation on the format/structure of an ajax response? Namely, if there's an error, a server returns http status 4xx or 5xx and... ...
2
votes
1
answer
780
views
Is it true that for both React or Angular, they are also both "convention over configuration"?
In the Ruby on Rails communication, it is often said that RoR is "convention over configuration".
Can you say for React / Redux / Flux and AngularJS, Angular2, they are also "convention over ...
6
votes
1
answer
32k
views
The correct use of application.properties file?
Java programmers are encouraged to store all their configurable parameters in an application.properties file from which they either load properties during runtime or they load during program start and ...
57
votes
5
answers
94k
views
Should I really use all uppercase for my constants?
I am a Python programmer primarily who uses pylint for linting source code. I am able to eliminate all of the warnings except one: Invalid name for a constant. Changing the name to all caps fixes it, ...
4
votes
2
answers
222
views
Using A Configuration Class (For All Constants/Magic's)
I come from a background where using a configuration file for every, if not every, constant is the best solution for maintainability and flexibility of the program. By this I mean, every hard coded ...
101
votes
10
answers
21k
views
Should I follow a bad coding style just to follow the established conventions at my workplace?
I've been working at my job for about a year. I primarily do work in our GUI interface which uses methods from a C backend, but I generally don't have to deal with them except for return values. Our ...
2
votes
1
answer
2k
views
Is there anything wrong with my project structure and naming convention in ASP.NET MVC and Web API?
I wonder if project structure and naming convention which I use in ASP.NET MVC and Web API projects are ok. These technologies are quite new to me, so I don't have my own standards yet.
I don't ...
-2
votes
2
answers
2k
views
Java - is it bad to name variables starting with uppercase if they are vectors or matrices? [closed]
Often in math a vector or matrix will be denoted by a single capital letter. Would it be bad to have some variables such as this?
Vector3 A = ...
int Bx = ...
int By = ...
int Bz = ..
I would ...
0
votes
0
answers
308
views
Invent custom filename extension for derived format
Say I use a predefined serialization format X for certain data. Should I indicate the application in a custom filename extension or not? It is quite common
pk3 is a zip archive
XSL, SVG and many ...
14
votes
3
answers
4k
views
Naming convention for functions which have side effects? [closed]
I heard somebody say their language has a convention where the names of functions which mutate state must end with an exclamation point. I'm trying to write more functional code and I like the idea of ...
1
vote
4
answers
1k
views
Is "Pushing a variable to the Stack" a misnomer in C++?
In C++ a variable is allocated in the 'Call Stack' ('Stack') or the 'Heap.' Frequently when referring to allocating a variable to the 'Stack', people use the phrase "Push to the Stack."
My issue with ...
2
votes
1
answer
911
views
In Objective-C,what is the naming convention around protocols and their implementation classes?
Is there a naming convention for protocols and concrete implementations of them in Objective-C? Specifically regarding a protocol that's used as an abstract 'service' or 'manager' class declaration.
...
3
votes
1
answer
238
views
What are good conventions/standards for application messaging through stdin and stdout?
I'm designing and application that spawns another processes to handle some specialized work. The application and the process it spawns will communicate through standard input and standard output (and ...
1
vote
3
answers
184
views
In an ESB type system, what field name should be used as a "correlation ID"?
We're using ASP.NET Web API and Azure Service Bus and adding logging to our disparate services and systems. We need to track a correlation ID to the headers of each set of bus messages as well as logs ...