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
119 views

Is it bad practice to give a directory and a file the same name?

I have a program that produces a command line tool called GetFood. The source code lives in a directory named GetFood/, and I have a main file that interacts with a class that gets the food. It seems ...
-2
votes
3answers
98 views

Adding qualitative information to function names

I started adding informations about the behavior of functions to their name recently. Two big examples: pure - this function has no side effects (besides the returned value), which I would use in ...
1
vote
2answers
163 views

Naming functions that do one or more things

I recently picked up 'Clean Code' by Robert Martin and have taken to refactoring my recent project. I'm realizing how important it is to name variables and functions in a way that clearly expresses ...
2
votes
5answers
583 views

Is wrapping built-in functions with user functions ok?

As I was working with a friend on a project I noticed that he created custom functions such as: function is_empty($val){ return empty($val); } function is_not_empty($val){ return !empty($val); } ...
5
votes
2answers
2k views

Java-style package naming and second-level country domains

I own a .co.uk domain, and I whenever I've dealt with Java-style package naming, I've gone with uk.co.domainname. Once I encountered package that did the following: co.uk.domainname. Is one of these ...
1
vote
3answers
599 views

Is Diff a well understood term, or should I name it Differentiate?

I have a class which checks for differences. I could call this class ViolationDiffer public IEnumerable<ViolationChange> Diff( IEnumerable<Violation> old, IEnumerable&...
5
votes
2answers
1k views

What do we call “IP” and “port”?

When I'm looping through files and coming up with dynamically created Ansible playbooks and stuff like that, I've quite frequently had to work with a single variable that contains the IP and port of ...
7
votes
2answers
3k views

What's the Java convention for names with a sequence of numbers, like “ISO 8859-1”?

If I'm creating a Java class for something that has a sequence of numbers in its name, e.g. “ISO 8859-1”, how should I name my class? Iso88591 seems wrong, since there's no boundary between the ...
9
votes
2answers
4k views

Should APIs be in en_US or en_GB or both? [closed]

Should I write APIs in US spelling or British spelling? Or should I provide with mapping both of them to a single one and internally using anyone which I like so that both of them works ? At present ...
1
vote
2answers
65 views

What's the standard term for removing data and embedded code modules from a database before publishing?

Hopefully this question isn't too application-specific; I'm thinking about it with regard to Excel, but I think it applies to any file-based database that includes embedded code. I'm working on an ...
0
votes
3answers
155 views

What to rename my order table? [closed]

I have a database table named order. It contains eCommerce orders. Problem is, that's a reserved word in MySQL, and while I can use back-ticks to prevent issues, it's probably a good idea not to use a ...
5
votes
4answers
17k views

Naming Convention for Private / Public Fields [duplicate]

I read the following on the MSDN: Use Pascal casing for all public member, type, and namespace names consisting of multiple words. Note that this rule does not apply to instance fields. For ...
44
votes
3answers
15k views

Boolean Method Naming Affirmative vs Negative

Should boolean methods always take the affirmative form, even when they will only ever be used in the negative form? Say I wanted to check whether an entity exists before creating one, my argument is ...
-3
votes
2answers
148 views

How to name the parameter that holds `next` middleware in the chain?

I am writing an implementation of middleware chain in Python. Here is how a middleware function looks like: async def logger(ctx, next): print(f"Started doing stuff with {ctx}") await next() ...
1
vote
1answer
1k views

If I package by feature, but have many homogeneous classes, what is preferable?

I am wondering whether this is the correct way to handle my situation when packaging-by-feature. Use the following project structure as an example: com.foobar.web.Bootstrap.java com.foobar.web....
2
votes
4answers
536 views

Naming a class representing a collection of objects of another class

This is always a problem for me. Say, in a game, there's a class representing an enemy spacecraft named EnemySpacecraft and there's a class representing some collection of those, say all that exist in ...
79
votes
4answers
7k views

What's the difference between “to” and “as” method name prefixes? [closed]

What's the difference between "to" and "as" method name prefixes like toList(), asList(), etc... When to use which when designing a method?
2
votes
5answers
2k views

Function names - “standardized” prefixes

Imagine you have such routines /*just do X. Fail if any precondition is not met*/ doX() /*take care of preconditions and then do X*/ takeCareOfPreconditionsCheckIfNeededAtAllAndThenDoX() A little ...
4
votes
1answer
2k views

Python class naming: nested classes or composed names?

I encountered a scenario where I cannot decide on which is the best (or worst) naming strategy. The context is the following: a bracket (as in a tournament) made up of nodes, where is node is made up ...
4
votes
2answers
189 views

Are there any grammatic conventions on naming functions?

For example, I have a Selenium WebDriver and as part of my initialization I would like to check if I am able to instantiate it and start up browser. I can't come up with a proper name. Is there any ...
1
vote
1answer
2k views

How to name a service that does CUD operations from CRUD tetrad?

There is a need to separate services working with data into two groups: ones that perform read-only operations and others doing Create(or Add) + Update(can also be called Modify) + Delete(Remove). ...
3
votes
1answer
86 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 ...
0
votes
1answer
65 views

If I'm explicitly using WCHAR strings in my Windows application, should I use the -W functions rather than the TCHAR #defines?

Basically, TCHAR and the associated macros (_T/TEXT) are only really necessary if you're targeting both ANSI and Unicode, and, like 99.9% of developers out there, the possibility that someone might be ...
0
votes
1answer
2k views

Naming collections of helper methods, and avoiding meaningless jargon words

While coding anything remotely useful, I inevitably find myself wanting to add methods to perform smaller bits and pieces. (It could be a method to return everything in a string to the left of the ...
3
votes
1answer
1k views

Why shouldn't you create a custom uri scheme?

In setting up deep linking to android and iOS apps, I've made some use of custom URI schemes, and they work great, especially as a fallback when the mechanism that allows maps from http: fails (as ...
91
votes
5answers
95k views

Naming classes, methods, functions and variables [duplicate]

There are 3 important naming conventions: with_underscores PascalCased camelCased Other variants are not important because they are not commonly used. For variables it seems that the one with ...
-1
votes
1answer
77 views

REST: Using singular to return logged-in info

Github uses the convention "/user" (singular) to interact with the logged-in user's info. They still have the full "/users" suite of paths to support getting info based on IDs (or usernames in their ...
0
votes
2answers
215 views

Is there a name for being able to substitute a variable for the source code assigned to it?

Consider the following (python) code x = [1, 2, 3, 4] y = 2 + 3 z = x[0] + y Here, I can substitute the expressions for x and y verbatim in the expression for z, possibly by surrounding then in some ...
54
votes
2answers
25k views

Naming of bool methods: Is vs. Can vs.?

Which is the better name for a method that returns a boolean? IsSupportContentType or CanSupportContentType
1
vote
1answer
160 views

Providing context in Class name, even though the namespace provides context

So I am reading Clean Code and I want to write my class names with the proper amount of context, but how does .NET namespaces play into the concept of Meaningful Names? Do I forego context in the ...
-6
votes
1answer
731 views

Class names with Verbs

So I am reading Clean Code. In the Meaningful Names chapter, they lay down a rule of no verbs in class names. However in the Adding Meaningful Context section of that chapter, on page 29, he uses a ...
2
votes
4answers
2k views

Naming procedure conventions - Where to place adjective in a verb followed by an object convention

I am reading on Coding Complete book the following statement: To name a procedure, use a strong verb followed by an object A procedure with functional cohesion usually performs an operation on an ...
4
votes
1answer
200 views

How do package managers generally deal with squatters?

How do package managers deal with packages that use a package name but then abandon it or from rogue package names that are similar that host malware in the hope that an unsuspecting developer will ...
2
votes
1answer
2k views

Project structure and folder naming

I have a cpp project which source code I want to split into 3 groups and want to define structure for these files by creating folders with nice name. First group are files related to socket ...
102
votes
11answers
9k views

What's the name of the antipattern opposite to “reinventing the wheel”? [closed]

The "Reinvent the wheel" antipattern is a pretty common one - instead of using a ready solution, write your own from scratch. Code base grows needlessly, slightly different interfaces that do the same ...
0
votes
1answer
717 views

Should objects be singular since arrays are plural?

Might be a silly question, but what is more logical: object.actions.bark() or object.action.bark()? Simply about plurality. I know arrays are usually pluralized. But if I were to be consistent; ...
1
vote
1answer
171 views

Is it good to include the type of a variable in its name? [duplicate]

This is a naming convention question. In C#, someone suggested that variables of type List<T> should be named as listBlah instead of just blah. Similarly for variables of type Dictionary<...
0
votes
2answers
168 views

How to name the classes that caries data to a different layer?

When I retrieve data from database I name the class as Model, for example UserModel. When I send data to the View I name the class as ViewModel, for example UserSettingsViewModel. How to name the ...
11
votes
6answers
1k views

Naming: Should you sacrifice briefness for clarity?

For example, the following function loops through an array which contains the name and errors of an input field. It does this by checking the name of the validating field and then pushing the error ...
0
votes
1answer
3k views

Do you name a dictionary by the key or the value? [closed]

Do you name a dictionary by the key or the value? I have a dictionary that will hold gradient data and the component: dictionary[gradient] = component; Do I name it gradientDictionary or ...
4
votes
7answers
819 views

How can I expand my vocabulary to improve my variable names? [closed]

There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors. - Tweeted by Jeff Atwood Agreed. All software engineers can understand this. Choosing ...
7
votes
2answers
2k views

Complex variable name with plural nouns [closed]

It's a language agnostic question. Seems like a common problem, but I can't find answer anywhere. I need to pick a name for a variable to hold the values of one attribute of a list of objects, and I ...
4
votes
6answers
4k views

Naming functions that retrieve a value

I have this personal rule to start all function/method names with a verb. My verb of choice for functions or methods that get a value based on some data structure or object is get. I'm wondering if ...
3
votes
2answers
138 views

One function to produce a couple or a function per item?

I have a dilemma. Let's say I have an AST that describes some grammar, for instance. I can write a function to stringify this AST back into human-readable BNF form or generate a parser from it. I can ...
0
votes
1answer
95 views

How would you name the function that takes a list of lists [L1, L2, L3] and returns a list of lists [l1, l2, l3] [closed]

What would you call the function that takes a list of n lists of values, and returns a list of all the unique lists of length n where the ith element is chosen from the ith input list? For example: [...
3
votes
2answers
986 views

C# Possible method name conflicts with optional parameters - why it is not forbidden? [closed]

Let's have a simple class, and main method: using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { ...
19
votes
3answers
6k views

What package name to choose for a small, open-source Java project? [closed]

I'd like to publish a small open-source library in Java. I wonder what package name should I choose? I'm not a company and I don't have a domain that I could use as the basis for naming the package ...
3
votes
1answer
328 views

Name of interface method “leak” implementation details

I have a class which implements an interface and have responsibility to create item and "maintain" collection of created items. Class have method GetOrCreate(int id) which return instance of ...
0
votes
6answers
177 views

How to name a method that fills in the blanks? [closed]

I have a method that checks a data structure for the presence of a thing that might be missing but is required. If it is missing, it adds it. Essentially it is this (although the method is much, ...
2
votes
3answers
521 views

Applying the label “Parent/Child” on inheritance vs composition

I just stumbled over an interesting problem with naming. I am writing automated tests for an Object-Relational mapper. This involves using super-generic classes that exist solely to exercise certain ...

1 2 3 4 5 12