naming-conventions

Is it possible to name a constant a protected word in PHP?

谁说我不能喝 提交于 2019-12-11 07:34:53
问题 In C#, variables and other things can be named protected names such as "class" by prepending the name with an @ sign. So, @class is a valid name. Is it possible to do this same thing in PHP? I am using a class of constants to simulate an enum for HTML attributes such as ID, and Class. For now I am using "CssClass" but I'd rather use the name Class somehow. 回答1: Nope, not possible, at least not for class constants. You cannot use any of the following [reserved] words as constants, class names,

PHP security and unique naming conventions

我只是一个虾纸丫 提交于 2019-12-11 07:31:33
问题 Is anything wrong with naming images uploaded by users (for example avatars) like that: /user_id-username.jpg Example: /1-feont.jpg All images has unique name (becouse user_id is primary key), but what about security? Has that any bad influence? If has, what conventions should I do instead? 回答1: Make sure that the username is appropriately sanitized before using it as part of the filename. User id should be system generated so that should not cause any problems. 回答2: The name that you give

Java package naming and non .com domains

孤者浪人 提交于 2019-12-11 07:07:37
问题 From what I understand Java packages often use a company's website as a package namespace. For example if stackoverflow had a Java widget library it might be called com.stackoverflow.widget. But what happens if you use an obscure TLD. Is info.example.widget acceptable? 回答1: Sure, no problem. Whatever your company's domain name and whatever its TLD is, reverse the order of its components for your Java packages. 回答2: The intent of using a domain name is that it helps ensure uniqueness using

When to use `parent` and when to use `root` as first argument in a GraphQL-resolver function

坚强是说给别人听的谎言 提交于 2019-12-11 07:05:15
问题 I've seen some tutorials and examples out there who are sometimes using parent and sometimes using root for their first argument in a graphql resolver. What would be the correct naming in which situation and why? For example(nodejs): signup: (root, args, context, info) => signup(root, args, context, info) vs signup: (parent, args, context, info) => signup(parent, args, context, info) or in the function which does the signup: const signup(root, args, context, info) = { // do magic stuff } vs

Does ActiveRecord assign a key to every table using the naming convention “ID”, and if so, why?

空扰寡人 提交于 2019-12-11 06:49:45
问题 My understanding is that Actice Record is based on a object-relational mapping (ORM) pattern described by Martin Fowler in his book Pattern of Enterprise Application Architecture (Addison-Wesley, 2002); which states a one-to-one mapping relationship exists between a database record and the object that represents it in an object-oriented program (OOP). When Rails creator David Heinemeier sought to implement an ORM for his Rails framework, he based it on Fowler's pattern. Here's the problem,

standard naming convention for servlet package?

爱⌒轻易说出口 提交于 2019-12-11 06:41:26
问题 what should be the standard naming convention of a package which contains a servlet class? if my project name is "Employee" and I work in company "XYZ" , then what should come in this: com.xyz.employee. _ _ 回答1: There is no standard naming convention (other than the name should be in lowercase). Choose what is the most logical to you. Classes are typically arranged by technical and/or functional domain. So the servlet could be in a package com.xyz.employee.web (all the web-related stuff of

Python name mangling

本小妞迷上赌 提交于 2019-12-11 04:36:32
问题 In other languages, a general guideline that helps produce better code is always make everything as hidden as possible. If in doubt about whether a variable should be private or protected, it's better to go with private. Does the same hold true for Python? Should I use two leading underscores on everything at first, and only make them less hidden (only one underscore) as I need them? If the convention is to use only one underscore, I'd also like to know the rationale. Here's a comment I left

Database columns type prefix

那年仲夏 提交于 2019-12-11 03:29:48
问题 I’ve been developing solutions with databases for more than 11 years now, and it seems I’ve “developed” a rather controversial opinion about naming columns in my tables: I always give them a 3 or 4 character type prefix, i.e. intGroupID, nvcTitle, dtmCreated, bitPlayerHater, etc. I’ve worked with several other developers who all absolutely despised the old-school prefix convention. (yeah, I know, I didn’t invent anything here, I’m just refusing to give it up:) My primary reasoning is to

Naming convention for private modules

孤街醉人 提交于 2019-12-11 03:24:17
问题 I have multiple internal functions in a module. Because the module is getting too large, I want to factor out these internal functions into a separate "utility" module in the same package. The utility module would only contain package-internal functions which should not be considered part of the package's public API. Is there an accepted naming convention for such internal modules? Intuitively, I'd prefix the module name with an underscore. However, that is the naming convention for C/C++

In Python, what's the best way to avoid using the same name for a __init__ argument and an instance variable?

冷暖自知 提交于 2019-12-11 03:11:23
问题 Whats the best way to initialize instance variables in an init function. Is it poor style to use the same name twice? class Complex: def __init__(self, real, imag): self.real = real self.imag = imag It looks sloppy to me to come up with arbitrary alternative names like this: class Complex: def __init__(self, realpart, imagpart): self.r = realpart self.i = imagpart I don't think that this is addressed in the PEP 8 style guide. It just says that the instance variable and method names should be