Questions tagged [naming]

Give meaning and explanation with the fewest number of characters in a form that is most accepted by your team or community at large.

Filter by
Sorted by
Tagged with
6
votes
5answers
204 views

How to map “mv” operation to HTTP verbs?

In designing a RESTful api the problem arises as to how best to allow resources to be moved between collections. Renaming a resource could be done by using PATCH but this is not the same thing as ...
-2
votes
0answers
53 views

Does “reset” always mean “clear”? [closed]

I often see function names or comments suggesting that some boolean variable or bit is being "reset". When I see the term "reset" being used instead of some more definitive term ...
0
votes
2answers
48 views

Does Get in Repo Imply GetById?

REST APIs in virtually all languages use methods named Get to get GetById(int id). Is it ok to use this convention for repositories? Let's say I have a Professions repository for the sake of example. ...
4
votes
3answers
173 views

Naming function with “proceed”

I am wondering if it is good practice to name function which does the main logic "proceed" + "functionName". I would use that name if there are some checks(if-s, try-catches, etc.) ...
0
votes
2answers
152 views

Name for a “called function”

I am writing a documentation for a programm where a function is defined and it is called three times. I call the definition of the function "function definition". But what is the correct ...
-3
votes
0answers
27 views

What's a good name for a base Error (Exception) class that originates from a API user error?

I'm writing a small library for internal company use. We're using Typescript, but the only important detail about the language is error handling: it is customary for us to throw errors, and not to ...
-2
votes
0answers
34 views

Naming of object which encapsulates an async “operation” / “process”

I have an application which sends and receives commands to and from an external device. I have modeled the interactions with the device as "usecases / interactors" which only do one thing, ...
0
votes
1answer
55 views

Guidelines for how to name annotations

Annotations/Decorators/Attributes are a language feature found in multiple languages, such as JavaScript/TypeScript, Java and C# to name a few. I've been trying to find some information about how ...
-3
votes
1answer
60 views

What could be a better naming convention for the variable 'completeConfig'?

I have a feature in which the user can directly provide the entire nginx config inside the completeConfig variable in the config yaml. Like this: nginxConfig: completeConfig: > .... .... ...
0
votes
2answers
120 views

Which approaches are exists for using of possessive case in variables/classes/methods naming?

In variables/classes/methods naming, sometimes "of" preposition is omitted and word order changing, for example: "Absolute path of source file of entry point" -> "...
4
votes
2answers
206 views

Should the name of a method be less descriptive if its class/module alread is enough?

I have a module or class Random and in it there's a method called generate(). A client will always call it as res = Random.generate(). And from the inside, obviously, it can be called simply as ...
1
vote
2answers
135 views

What is a good naming convention for Interface Adapters, Use Cases / Interactors, Entities?

I'm using MVVM + Clean Architecture in my app. And I sometimes don't have any idea if my namings are good enough for each Interface Adapters, Use Cases / Interactors, Entities. For View Models, it's ...
-3
votes
1answer
347 views

What naming convention should I use for a JSON RPC client API designed for multiple languages?

This is the documentation with the original RPC client API specification. The naming convention in the specification is camel case. Naming conventions might differ in subtle ways for different ...
-3
votes
4answers
95 views

Negative Naming in Forms

The Main Question Is it ever acceptable to use a negative name for a boolean variable? For example, I have a few user forms that have a checkbox for "N/A" or "Not Assessed". These ...
2
votes
2answers
223 views

Is there a name for a closure which just returns a value?

I have a PHP closure defined as function () use ($contents) { return $contents; }. It's like a value object except it's a closure. Is there a name for this?
2
votes
3answers
497 views

What do you call a function that returns a function?

Let's say, for example, that I have a function makeFoo that makes another function foo: function makeFoo(string) { return () => string } const foo = makeFoo('bar'); I know that makeFoo is a ...
1
vote
2answers
144 views

What do I call “unit tests” that are specifically developed during tinkering?

When developing a new section of code functionality with modules I'm not familiar, I'll often create a set of unit tests that are for "tinkering" and interactively analyzing the results in ...
-3
votes
2answers
97 views

Naming conventions for set/unset method parameter

I have some class MyClass which has two methods: Lock(){} Unlock(){} For some reasons, the two methods are to be unified into one, with an additional parameter for indicating the action. What should ...
-2
votes
1answer
53 views

System Hungarian Notation for Android UI components?

Is using System Hungarian Notation for Android UI components (Views) valid? I mean using it ONLY for Views - no strSomething, boolStuff or similar names. For example, tvDescription (TextView), ...
-2
votes
1answer
81 views

Conditional command pattern

I have an abstraction that defines something like a command pattern, interface Participant { void proceed(); } Participants are grouped in a collection and are called all together. But each ...
-3
votes
1answer
47 views

Long variable naming with chained filters on API best practices?

I am writing an application where a single variable may be affected by different filters applied to the data that's read from the DB. Each different variation has to be stored (as each one serves ...
0
votes
1answer
106 views

How to avoid messy code when working with different libraries

I'm planning to work with different libraries that use different conventions. One uses snake_case, another one uses camelCase. This leads to code that looks like I can't make up my mind: Some_Result ...
-2
votes
3answers
174 views

Is it acceptable to use “or” in the name of a boolean variable? [closed]

Say we have a boolean variable indicating whether an input array is 2D or 3D (just an example). Is it acceptable to name it is_2d_or_3d instead of is_2d, to make it clearer that if false, it indicates ...
0
votes
6answers
171 views

Naming boolean fields in classes

I have had hard times naming boolean fields. On the one hand, i've read that it is good to name them as affirmative statements, like hasAge, or canDance. It's not a problem when naming local ...
-4
votes
3answers
87 views

Should I prefix keys of JS object with the object's name?

Let's get to an example. Suppose, I have a Course object with the following properties: (course' code, course's title, credit of course etc.). When expressing this as a JS object, I can do it in the ...
41
votes
10answers
10k views

Clean Code: long names instead of comments

Don't be afraid to make a name long. A long descriptive name is better than a short enigmatic name. A long descriptive name is better than a long descriptive comment. Robert C. Martin Did I ...
-1
votes
2answers
102 views

Do I name classes based on the object type they represent or the responsibility they have?

The more I read about the Single Responsibility Principle the less I see a class as an object type, but rather as a servant that does something. For example, let us suppose we have a new requirement ...
1
vote
2answers
42 views

Identify segment in grid

Imagine a grid like the one in the image. I have to model an API which identifies a single segment inside a grid (like the one painted in red). I thought the segment should be represented with ...
2
votes
1answer
105 views

What is the name of the throw-an-exception on invalid inputs pattern?

In some .NET libraries, there's a pattern of two alternative ways to call a function. int i = x.GetValue(k); /* Might throw. */ if (x.TryGetValue(k, out int i) { /*...*/ } else { /* ... */ } I ...
5
votes
3answers
250 views

What should a member function be called that applies an argument function to the object?

Apply is a fitting name for a member function of a function-type class that applies the function to the given arguments: class Addition { int apply(int a, int b) { return a + b; } } But ...
-2
votes
1answer
67 views

What do i call a 'Mutable configuration'

I have an external process in my program. To interact with it i have a configuration file i can edit. The external process then reads this file periodically and updates its state accordingly. Now ...
3
votes
1answer
98 views

A size-type vs index-type conundrum

Suppose I'm writing C or C++ code which deals with... ok, let's make it citizens in a state. In this state, citizens have numeric id's (not strings - numbers); and for reasons of performance, or ...
7
votes
2answers
226 views

Is there a correct way to use abbreviations in code? [closed]

Oh, abbreviations in code, the bane of every developer. Consensus seems to be against them, because readability might be affected. But the examples given are often extreme: like "repr" for "represent"...
2
votes
1answer
122 views

What should I call an internal casting function that may fail

(Almost) all numbers in my program are parsed and treated as complex numbers. There is one corner cases, that specifically needs an integer. Unfortunately my programming languages does not allow to ...
1
vote
5answers
126 views

Succinct and explicative way to name “cooldown” variables

I am struggling with naming 3 variables defining the following concept: An action, after being performed, is not available for an amount of time and then is available again. The concept comprises 3 ...
1
vote
1answer
50 views

Tips for module naming and criteria for grouping files in a directory

It appeared, that I have in my pet project two abstractions: asset loaders and drawing tasks. For each abstraction I have some classes representing them (currently a single class for drawing task ...
1
vote
2answers
109 views

How to name two versions of the same object, where one has a smaller amount of data and one is the “complete” object

What is the best way to name two classes that describe the same object, but where one of those classes does not hold the complete information? And should I make one of the classes inherit from the ...
9
votes
1answer
480 views

Why is Assembly Language called “Assembly”?

Why is assembly language called "assembly"? I was just watching the 1st video in the "Crockford on JavaScript" series. In it, Douglas says, ". . . the first program to make programming easier was ...
-1
votes
1answer
46 views

Naming my classes and class folders in PHP project

I am working on an (PHP) application where users have so called workspaces. A workspace is a folder with a specific structure and bunch of specific files - user information and some workspace metadata ...
4
votes
2answers
247 views

When to use third-person verb? (PlayOnAwake or PlaysOnAwake)

First a couple of examples: var val = obj.GetValue(); var can = obj.CanPlay; var has = obj.HasValue; var val = obj.RequiresConstantRepaint(); // From Unity var val = obj.PlayOnAwake; // From Unity ...
23
votes
3answers
6k views

Why are module-specific prefixes widely used for function names in C modules?

In some C projects, function names start with a common prefix indicative of the module name, for example: mymodule_do_this_stuff(); mymodule_do_that_stuff(); Is there a justification for doing so ...
42
votes
8answers
8k views

Should I use AND in a function name?

I am in a predicament. I am working in a repository that makes a lot of database changes within its functions. The function I am dealing with returns responseids (but from a transformation, not from ...
2
votes
3answers
224 views

Use prepositions in naming verb-phrase functions?

When writing a library, designing a class or extending some existing API, we often need to express actions or relations involving noun entities: "Place the ball in the bin" "Obtain the coat for the ...
-2
votes
2answers
137 views

Python function name convention for “convert foo to bar”, e.g., foo_to_bar, foo2bar

I have a function that converts args given by argparse to a filename: def args2filename(args, prefix): filename = prefix kwargs = vars(args) for key, value in sorted(kwargs.items()): ...
1
vote
1answer
67 views

Using define in a conditional expression in Scheme

In Scheme, the general form of a procedure definition is: (define (<name> <parameters>) <body>) where <body> accepts a sequence of expressions, allowing this kind of procedure ...
1
vote
3answers
239 views

Should I give an object that holds multiple objects of the same type a plural name?

I have an object: const riders = { Dave: { gender: 'male', age: 13, }, Nina: { gender: 'female', age: 16, }, Mike: { gender: 'male', ...
6
votes
5answers
475 views

What is a good approach to naming when modeling a sport that can be between either individuals or teams?

Tennis is played as singles or doubles. I considered making my tennis scoring model logic refer to "teams" throughout its naming since "player" wouldn't take into account doubles. However, seeing ...
24
votes
4answers
5k views

Why is the norm of a complex number in the C++ complex library actually the square of the norm?

In the C++ complex library, the method norm() of a complex number actually returns the square of what I have learned is usually called the "Norm". Reference: std::norm For example, std::norm() of (3,...
0
votes
3answers
342 views

How to name functions with multiple return values

In many languages, it is common for a function to have multiple return values (as a tuple), such as: def foo(): return "Hello, World!", 0 I often do this when a computationally expensive (or an ...
1
vote
1answer
78 views

Operand ordering for matrix multiplication with assignment

If you have a matrix class with overloaded operator*=, which order should the operands be placed for the interface to be useful and intuitive. One can choose A *= B to be equivalent to either A = A*B, ...

1
2 3 4 5
12