naming-conventions

Naming variables describing the same thing but of different type

半城伤御伤魂 提交于 2019-12-11 03:05:39
问题 What is a commonly accepted approach in variable naming when dealing with variables that are of different type but describe the same thing? private String contentFolder = "/tmp/"; private File contentDirectory = new File(contentFolder); The above seems sloppy. But what is better? private String contentDirectoryStr = "/tmp/"; private File contentDirectory = new File(contentDirectoryStr); Looks just as bad. What is a common convention you follow to describe same things of different type?

Proper folder structure for lots of source files

不羁岁月 提交于 2019-12-11 02:49:00
问题 I apologize if this has been asked before, but I believe that for me, this question falls under the "I have no idea what I should even google" category. So, as a noobie to the coding world, I have only recently begun delving into projects that encompass more than a few source files. I am beginning my first "big" project, and before I begin, I would like to know the best way to go about managing many different pieces of a system. For example: I have Project0 which is built from the pieces A

Library name for x32 vs x64

柔情痞子 提交于 2019-12-11 02:44:48
问题 I have a C++ static library that supports both x32 and x64 platforms. My question is: should I name the .lib file different depending on which platform? i.e. MyLib32.lib vs MyLib64.lib Intel Math library and TBB handle this using folder name to differentiate between the 2 libraries instead. i.e. x32\Math.lib vs x64\Math.lib Is there a better way compared to the other? I think explicitly naming the lib to correspond to the intended platform should be better? That way we dont depend on folder

Java variable value as new variable name

Deadly 提交于 2019-12-11 02:44:33
问题 I was wondering if in Java there was any way to give a new variable a name which is the value of another variable. The below code is an non working example of what I'm trying to do. int a = 0; while(true){ String (a) = "newValue"; a = a + 1; } or String b = "newVariableName"; int (b) = 1; Thank for any help given. 回答1: You cannot create dynamic variable names in Java. I would recommend placing these variables in a Map with a string as a key. The key can be whatever String you would like. 回答2:

mSomeVar names - where from and why?

给你一囗甜甜゛ 提交于 2019-12-11 02:14:45
问题 Variables in Android sources are prefixed with m , like mStream or mHeaderValueIndex . What's the rationale behind Hungarian notation here? 回答1: The "m" is short for member. It's just a way of letting you know you're dealing with a class member variable. In other environments or programming languages, you might use an underscore prefix instead. 回答2: The rationale for putting prefixes like "m" or "m_" or "_" on attribute names is to make them easier to distinguish from local variables and

Naming an object that is an attribute of another object with the same getter/setter as Object Type

删除回忆录丶 提交于 2019-12-10 23:29:53
问题 This is a fundamental question. When using objects as an attribute for an object, So Object2 has an attribute Object1. Can you use the Object name as the type and name for the getter and setter or the second object. Class Object1{} Class Object2 { Object1 Object1 {get; set;} // OR Object1 Object1_{get; set;} } As I've tried it using the same name for simple programs and it works (though I've not dare to venture into complex code with it). I understand that there could be ambiguity, but will

How to use reserved keyword as the name of variable in python?

只谈情不闲聊 提交于 2019-12-10 23:19:47
问题 I want to use reserved keyword "from" as the name of variable. I have it in my arguments parser: parser.add_argument("--from") args = parser.parse_args() print(args.from) but this isn't working because "from" is reserved. It is important to have this variable name, I don't want answers like "from_". Is there any option? 回答1: You can use getattr() to access the attribute: print(getattr(args, 'from')) However, in argparse you can have the command-line option --from without having to have the

CakePHP Unit Testing Fixture Name Conventions Argh?

做~自己de王妃 提交于 2019-12-10 21:39:00
问题 I've been bashing my head against the wall trying to figure out why I can't get my fixture to load properly. When I attempt to run my test, my layout is rendered. If I comment out the fixture, the test runs properly. I've gone over this 100 times and I can't seem to see what's wrong. Heres my Videosview.test.php App::import('Model','Videosview'); class VideosviewTest extends Videosview { var $name = 'Videosview'; //var $useDbConfig = 'test_suite'; } class VideosviewTestCase extends

Best naming for a column in a SQL Server table

。_饼干妹妹 提交于 2019-12-10 21:07:27
问题 Which of the following three options would you choose for a column name in a SQL Server table, and why? YearToDateWages YTDWages YtdWages Follow up: SSN Ssn SocialSecurityNumber 回答1: For the first one, I would use WagesYTD because YTD is a modifier on Wages. For the second one, SSN, or SocialSecurityNumber I never use camelCase in database field or table names, and Ssn is not a real word, nor is it a valid abbreviation. 回答2: I'd suggest using more or less the same rules as naming classes. If

Naming convention: singular vs plural for classes describing entities in PHP

◇◆丶佛笑我妖孽 提交于 2019-12-10 19:54:05
问题 I think that the standard practice to name tables in MySQL is to use plural names. The classes refering to those tables should also be plural? For example, imagine that you have a table called Users, that is used for authentication purposes. This table would be described in an entity class more or less like this using the doctrine ORM: namespace Company\BlogBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="Users") */ class Users { /** * @ORM\Id * @ORM\Column