naming

Naming functions, methods, pointers, variables, arrays etc in C++

萝らか妹 提交于 2020-01-03 02:54:40
问题 Allright, doing some project with few friends, and I need some standard for naming things in c++. Does anyone have any good naming scheme for c++ that is well thought-out and not made in like 10min. Example, int* house should be named int* house_p, so that when someone reads the code, he doesn't need to scroll all the time wondering if a thing is a pointer, array, matrix, or whatever... Post your well thought-out naming schemes that you are using ! 回答1: Example, int* house should be named int

naming of physical quantities in python

被刻印的时光 ゝ 提交于 2020-01-02 10:18:02
问题 I would like to establish a good naming scheme for physical/mathematical quantities used in my simulation code. Consider the following example: from math import * class GaussianBeamIntensity(object): """ Optical intensity profile of a Gaussian laser beam. """ def __init__(self, intensity_at_waist_center, waist_radius, wavelength): """ Arguments: *intensity_at_waist_center*: The optical intensity of the beam at the center of its waist in W/m^2 units. *waist_radius*: The radius of the beam

What does “f” stand for in C standard library function names?

三世轮回 提交于 2019-12-31 19:19:11
问题 What does f stand for in the name of C standard library functions? I have noticed that a lot of functions have an f in their name, and this does not really make sense to me. For example: fgets , fopen , printf , scanf , sqrtf and so on. 回答1: Your question in general is too general but I can explain a few examples. f gets, f open, f close, … — The ”f“ stands for “file”. These functions accept or return a FILE * pointer as opposed to a file number as the POSIX functions do. print f , scan f , …

Function name for creating something if it's not there yet

前提是你 提交于 2019-12-30 06:43:21
问题 From time to time I write a function that just creates something if it's not there yet and otherwise does nothing. Names like CreateFooIfNecessary() or EnsureThereIsAFoo() do work but they feel a bit clumsy. One could also say GetFoo() but that name doesn't really imply that foo may be created first and it only works if the function returns a handle/pointer/reference to foo . Can those of you more familiar with the English language come up with a better way to name these functions? 回答1: How

Where can I find x86 register names? [duplicate]

一个人想着一个人 提交于 2019-12-29 08:16:31
问题 This question already has answers here : Why are x86 registers named the way they are? (5 answers) Closed 29 days ago . Where I can find the 80x86 register full names? I know that EAX means Extended AX. What is then, the meaning of AX? I.e. is AX an acronym? 回答1: Intel Register names and meaning 回答2: The register names have evolved over the past 40 years. The Intel 8080 processor, introduced in 1974, had 8-bit registers named A, B, C, D, E, H and L. A thru E seem fairly obvious but H and L?

Why do function prototypes include parameter names when they're not required?

不打扰是莪最后的温柔 提交于 2019-12-29 04:20:32
问题 I always thought that a function prototype must contain the parameters of the function and their names. However, I just tried this out: int add(int,int); int main() { std::cout << add(3,1) << std::endl; } int add(int x, int y) { return x + y; } And it worked! I even tried compiling with extreme over-caution: g++ -W -Wall -Werror -pedantic test.cpp And it still worked. So my question is, if you don't need parameter names in function prototypes, why is it so common to do so? Is there any

Create empty list names using a loop [duplicate]

混江龙づ霸主 提交于 2019-12-25 18:12:02
问题 This question already has answers here : How do I create a variable number of variables? (14 answers) Closed 2 years ago . Beginner's question. I want to create several empty lists and name them. Currently I am doing it the foolproof but cumbersome way, size_list=[] type_list=[] floor_list=[] I am trying to do it less cumbersome, for item in ['size', 'type']: item+'_list'=[] however, this results in the following error, item+'_list'=[] ^ SyntaxError: can't assign to operator Can this be fixed

Get EJB object inside rar deployed inside jboss

余生颓废 提交于 2019-12-25 14:48:45
问题 I have an activemq broker deployed within my jboss server. activemq is deployed as a rar file placed in jboss standalone/deployment repository. An other project is also deployed within my jboss as an ear file. This last is exposing some ejb objects in my jboss. I tried to get an ejb from a jar file that I put into my activemq rar file. A class placed within the jar is called when I connect a client to the broker. This is how I tried to get ejb within jar file: Context ctx; Properties

Why does the naming of RelatedFactory variables in factory-boy affect when the factories are executed/instantiated?

梦想的初衷 提交于 2019-12-23 16:01:06
问题 When I named my RelatedFactory variables pv_something , the factories wouldn't be run until after the post_generation method. When I renamed the variables to param_val_something they would be run before the post_generation method. In the following code, RelatedFactory is not run until after post_generation , so self.something_set.all() is empty, and the line t.something_else = 'abc' is never executed. class ThingFactory(factory.DjangoModelFactory): class Meta: model = Thing name = 'a thing'

How to reach iteratively few variables which names differ only by number in C++?

久未见 提交于 2019-12-23 15:04:53
问题 I need a method helping me, to reach variables named like "comboBox1", "comboBox2" etc each by each in a loop. I'd like to change code like: //proceed comboBox1 //proceed comboBox2 //proceed comboBox3 //proceed comboBox4 //proceed comboBox5 //proceed comboBox6 Into: for (int i = 1; i < numberOfBoxes; i++) { //proceed comboBox(i) } I tried to find somthing like 'eval', but google didn't give anything matching. I also tried preprocessing the name with operator ## but it seems there's no way to