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
-3
votes
1answer
43 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
94 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
156 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 ...
41
votes
10answers
9k 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 ...
0
votes
6answers
153 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 ...
12
votes
1answer
683 views

Why was “self” chosen over “this” for the name of the first parameter of python methods?

What was the rationale for choosing the name self instead of this when defining class methods in Python? Yes, of course, you can name it whatever you want - but the widely agreed-upon name for the ...
-4
votes
2answers
61 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 ...
-4
votes
0answers
57 views

How to call small side programs that does not belong into main program?

When I am writing a computer program I usually have many types of code. I have a main code, which goes into src folder. Usually I have some test code that goes into test folder. Maybe I have some ...
14
votes
4answers
18k views

Naming boolean field that is a verb

In Java, by convention getter and setter for boolean fields will be isField() and setField(). This works perfectly fine with field names that are adjectives like active, visible, closed, etc. But how ...
-1
votes
2answers
95 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 ...
40
votes
8answers
7k 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 ...
4
votes
2answers
240 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 ...
1
vote
2answers
41 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
101 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 ...
36
votes
9answers
28k views

Default vs Impl when implementing interfaces in Java

After reading Should package names be singular or plural? it occurred to me that I've never seen a proper debate covering one of my pet peeves: naming implementations of interfaces. Let's assume ...
10
votes
8answers
8k views

Do variable names affect the performance of websites?

Do variable names affect website performance? I know this will going to be very low number, but still can any one provide the reasons for not choosing a long variable name in aspect of performance?
-2
votes
1answer
65 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 ...
5
votes
3answers
241 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 ...
0
votes
2answers
270 views

Should I break down test class into multiple files?

I have a test class with about 25 tests that are testing the different aspect of it. I wonder Should I break it down into smaller classes? If so, then what is the best naming/packaging convention? ...
3
votes
1answer
96 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 ...
15
votes
3answers
10k views

Are my method or variable names too long? [closed]

So I was currently in the middle of coding, unfortunately for me, I was in "The Zone" then I thought to myself, are my method/variable names to long? POP out of the Zone I go! So I came here to ...
7
votes
2answers
218 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
120 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
1answer
47 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
5answers
111 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
2answers
99 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 ...
8
votes
1answer
343 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 ...
25
votes
7answers
33k views

What to do if I hate C++ header files?

I was always confused about header files. They are so strange: you include .h file which doesn't include .cpp but .cpp are somehow compiled too. Recently I joined a team project, and of course, ...
-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 ...
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 ...
1
vote
1answer
65 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 ...
6
votes
6answers
2k views

Use of “my” prefix in object naming

I am refactoring a large code base, and noticing the author often uses "my" to prefix object names. For instance, using myThingy to identify an object of type Thingy. Is this generally considered a ...
2
votes
3answers
172 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
114 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()): ...
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,...
1
vote
3answers
210 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', ...
4
votes
3answers
294 views

How should I go about 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 ...
0
votes
3answers
256 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
76 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, ...
8
votes
4answers
43k views

Best way to naming classes and packages in Java

Apart of the code conventions to use camelCase, PascalCase etc., are there any conventions for naming packages and classes in Java? For example, I have an mvc project and the main package is com....
0
votes
1answer
36 views

Appropriates names for Api implementation and Api Client Library

Suppose I have a big project, called Northwind. It's a website in front of a database. Now management want me to create a public API for this. I create a new ASP.NET Core project called Northwind.Api ...
1
vote
2answers
131 views

What is the rationale for naming the code module differently to the class name

For class Foo, what is the rationale for calling the physical code module something different e.g. FooBar.cs Is this just a style thing, or does it serve some other purpose/intent? It is accepted ...
1
vote
3answers
144 views

Term for “IP address or DNS name” [closed]

We have a column in a database table that can hold either an IP address or a DNS name, and we're struggling to name it without leaning one way or another. Is there a "standard" term that means "IP ...
1
vote
1answer
603 views

Java package naming conventions (in maven modular project)

Until now I have been using simple strategy for packages naming in my maven-modular projects. Each package name contains name of the module in which it is placed. For example, simple project would ...
3
votes
5answers
433 views

Naming classes representing multiple values - Singular or Plural?

So we've got the following class: public class BudgetAmounts { public readonly int BudgetFk;//Foreign key to Budget public readonly int ItemSalesGroupFk;//Foreign key to the type of product ...
3
votes
2answers
849 views

Method naming: to vs as vs get

Do the words to, as and get have any special meaning when used in method names? Examples to new Integer(4).toString() get Integer.getInteger("system.unknown.property",4) as Arrays.asList(...
36
votes
5answers
6k 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 ...
2
votes
1answer
95 views

Naming a software which allows communication between two independend systems via internet [closed]

Probably a trivial question but I just don't know how that piece of software would be called correctly: I have a closed system (A) and an application on another system and location (B). The ...
1
vote
2answers
510 views

Using “On” at the start of a method name

From what I've observed, methods that start with the word "On" fall into two categories: A base class that defines an event will expose a protected method whose name starts with "On" followed by the ...
-1
votes
1answer
120 views

Domain Driven Naming is too long and verbose [closed]

we are tackling the domain of https://en.wikipedia.org/wiki/Factoring_(finance)[factoring][1]: Factoring is a financial transaction and a type of debtor finance in which a business sells its ...

1
2 3 4 5
12