naming-conventions

Naming convention for Private Properties

北战南征 提交于 2019-12-13 15:23:20
问题 I've seen underscore used as a prefix for private properties private var _aPrivateVar: String = "I am private" I've seen them not used private var aPrivateVar: String = "I am private" Syntactically, it makes no difference and my preference is to not use them. However, what's the accepted convention in Swift so that I pick the right habit up? 回答1: In this Swift Guide style, you can find a similar reference: private var centerString: String { return "(\(x),\(y))" } In The swift Programming

Can ServiceStack operation naming convention be overriden?

送分小仙女□ 提交于 2019-12-13 14:42:21
问题 I need to define a DTO class for a ServiceStack service. Service stack uses convention based on class names, so if my class is called Transmission, the corresponding service will use expose metadata with a type "Transmission" used in HTTP operations. But I already have Transmission class - the one my DTO object will be mapped to. To avoid confusion I want to define TransmissionRequest DTO (probably something better than just "Request" suffix) but keep "Transmission" in exposed service

What does an underscore “_” mean in Swift?

丶灬走出姿态 提交于 2019-12-13 13:26:12
问题 I just found this while browsing through the Swift module headers: protocol _ObjectiveCBridgeable { Similarly: protocol _SequenceType { Coming from an Objective-C background, this seems highly unconventional to me. The underscore _ usually implies that the concerned entity is private, and is often hidden in terms of header visibility. Why is it that in Swift they are publicly visible? Have the naming conventions changed for Swift? 回答1: It seems that the conventions have changed as far as

Naming conventions for function parameter variables?

∥☆過路亽.° 提交于 2019-12-13 13:24:11
问题 Is there a naming convention or maybe some guideline on how to name function parameters? Since forever, I have been doing it like this: function divide( $pDividend, $pDivisor ) { ... } That way I'll always know which variables were passed as parameters. (This one's PHP, but it should be applicable to most programming languages) Is there one major reason against this? Is there a better way to do this or is it probably best to just avoid such naming schemes? 回答1: If : your functions/methods are

How should I name this method? [closed]

谁说胖子不能爱 提交于 2019-12-13 13:01:23
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am designing the API for a service that deals with Job entities. I need to retrieve jobs given a status. So, I ended up naming my

Id or [TableName]Id as primary key / entity identifier

送分小仙女□ 提交于 2019-12-13 12:27:46
问题 Is it preferred to use "Id" as the column name for a primary key or "[TableName]Id" as a naming convention? Table: Account Primary Key: Id -- versus -- Table: Account Primary Key: AccountId It seems to be split about 50% / 50% in the implementations that I've seen. What are the advantages and disadvantages in each approach? Follow-up: Does it make sense to use one convention in my database, and another on my entities in code? Or should I keep them consistent? How would does this work best in

Python module names starting with numerals [duplicate]

徘徊边缘 提交于 2019-12-13 05:04:59
问题 This question already has answers here : In python, how to import filename starts with a number (3 answers) Closed 6 years ago . When I try to import a module in python(.py file) it gives a syntax error. The module name starts with a numeral. Is that the reason for the syntax error? 回答1: Yes, that is the reason for the syntax error. There are various ways of importing it anyway, but it's better to rename the module. The reason is that variable names can't start with a numeral. Hence you can't

Generic Java Package Name

徘徊边缘 提交于 2019-12-13 03:35:24
问题 When I create a stand-alone Java program, which only has one or two java/class files and is not shared with other programs, I never take the time to say org.domain.scripts.purpose in the package name. I typically just make my main class main.Main . Perhaps this is against protocol, but when duplicating a program in order to fill another small niche requirement (like converting tab delimited to csv or recursively listing files sorted by modify date), I will not be made to rename the package

Opinions on using My as a class name prefix

☆樱花仙子☆ 提交于 2019-12-12 17:03:39
问题 Personally, I've never liked the MyObject naming of classes. I would guess that the status quo would agree but I'd like to see the other side of the argument and if there's any validity to it. 回答1: I've never seen it done in production code, although I dare say it exists. It's like the metasyntactic variables "foo" and "bar" - it's usually used as a placeholder for a real name. So for example, if I know that someone has their own class deriving from Form , but I don't know anything else about

What is the naming convention for CMake scripts?

时光总嘲笑我的痴心妄想 提交于 2019-12-12 16:12:11
问题 I know that CMake makes use of the standard name "CMakeLists.txt" and the add_subdirectory function for calling scripts directly in the build process. I have some CMake code that I use to turn files into C++ strings that can then be baked into the program using #include directives. The relevant code in my root CMakeLists file looks like this (greatly simplified, of course): add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/path/to/example.json.txt COMMAND ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR} $