conventions

Round brackets or not? Whats the difference?

喜你入骨 提交于 2019-12-06 02:15:42
I've seen these two things lately and I'm a bit confused. var blah = new MyClass() { Name = "hello" } and var blah = new MyClass { Name = "hello" } Whats the difference? and why do they both work? Update: Does this mean that if i have something in a constructor which does some computation that i would have to call the first one?? As far as I know, they're exactly equivalent. The C# specification (or at least Microsoft's implementation of it) allows you to omit the () when using the default constructor (no parameters) as long as you're using curly brackets (i.e. the syntax for object

VS Code PyLint Error E0602 (undefined variable) with ProtoBuf compiled Python Structure

北战南征 提交于 2019-12-05 19:11:28
I was using Visual Studio for a long time, but it was becoming too complicated to maintain. Now I tried to move to VS Code, but it throws a number of PyLint error messages that don't make sense to me (and the program still works as expected). These errors happen primarily with Python code generated from a GoogleProtoBuf structure. For example: from lbsnstructure.lbsnstructure_pb2 import lbsnPost def geoaccuracy_within_threshold(post_geoaccuracy, min_geoaccuracy): """Checks if geoaccuracy is within or below threshhold defined""" if min_geoaccuracy == lbsnPost.LATLNG: allowed_geoaccuracies =

What's the clearest way to indicate a function uses the 'arguments' object?

落花浮王杯 提交于 2019-12-05 18:26:26
What's the best way to indicate a function uses the 'arguments' object? This is obviously opinion based but are there any conventions? When would it be better to use an array of arguments? Some examples: // Function takes n arguments and makes them pretty. function manyArgs() { for (var i = 0; i < arguments.length; i++) console.log(arguments[i]); } function manyArgs( /* n1 , n2, ... */ ) function manyArgs(n1 /*, n2, ... */ ) function manyArgs(argArray) // Using ES6 syntax ... var foo = function(/*...args*/){ // shim Array.from, then var args = Array.from(arguments); // or var args = [].slice

python code convention using pylint

半世苍凉 提交于 2019-12-05 17:06:15
问题 I'm trying out pylint to check my source code for conventions. Somehow some variable names are matched with the regex for constants ( const-rgx ) instead of the variable name regex ( variable-rgx ). How to match the variable name with variable-rgx ? Or should I extend const-rgx with my variable-rgx stuff? e.g. C0103: 31: Invalid name "settings" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$) 回答1: Somehow some variable names are matched with the regex for constants (const-rgx) instead of the

Where to declare class constants?

本小妞迷上赌 提交于 2019-12-05 12:31:49
问题 I'm using class members to hold constants. E.g.: function Foo() { } Foo.CONSTANT1 = 1; Foo.CONSTANT2 = 2; This works fine, except that it seems a bit unorganized, with all the code that is specific to Foo laying around in global scope. So I thought about moving the constant declaration to inside the Foo() declaration, but then wouldn't that code execute everytime Foo is constructed? I'm coming from Java where everything is enclosed in a class body, so I'm thinking JavaScript might have

Which namespace does operator<< (stream) go to?

不打扰是莪最后的温柔 提交于 2019-12-05 11:46:36
问题 If I have have some overloaded ostream operators, defined for library local objects, is its okay for them to go to std namespace? If I do not declare them in std namespace, then I must use using ns:: operator << . As a possible follow-up question, are there any operators which should go to standard or global namespace? 回答1: According to Koenig Lookup (C++ Standard 3.4.2) operator<< will be searched in namespaces of arguments. No need to declare it in std namespace. 回答2: operator<<( ...,

How to organize “projects” and “solutions” in Eclipse?

自闭症网瘾萝莉.ら 提交于 2019-12-05 11:33:17
问题 I've been told that an Eclipse workspace is the equivalent of a Visual Studio solution. But I've also been told that people commonly use a single workspace for all their work. Are these apparently conflicting statements correct? If yes, how do we then create and maintain the equivalent of multiple VS solutions in Eclipse? Secondly, in the case of VS, I check in my solution (.sln) files, too, into source control. Correspondingly, should I or should I not check in the Eclipse workspace's

Do you think a software company should impose developers a coding-style? [closed]

牧云@^-^@ 提交于 2019-12-05 10:31:14
问题 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 8 years ago . If you think it shouldn't, explain why. If yes, how deep should the guidelines be in your opinion? For example, indentation of code

NodeJS best practices: Errors for flow control?

别说谁变了你拦得住时间么 提交于 2019-12-05 09:18:19
In Node.js, should I use errors for flow control, or should I use them more like exceptions? I'm writing an authentication controller and some unit tests in Sails.js, and currently, my registration method checks to see if a user with the same username exists. If a user already exists with the username, my model method calls its callback arguments with a new Error object, like so: Model: exists: function (options, cb) { User.findOne({ where: { username: typeof options === 'Object' && options.username ? options.username : options }, }).exec(function (err, user) { if (err) return cb(err); if

AmazonS3: custom error pages

不问归期 提交于 2019-12-05 03:42:00
I am planning to share URLs (time limited) for private objects. Is there a way to set custom error pages for 404/403 http responses ? Yes, it's possible, see this announcement . In the Developer guide there is a paragraph about "Custom Error Document Support" where I read the following sentence. You can optionally provide a custom error document with a user-friendly error message and with additional help. You provide this custom error document as part of adding website configuration to your bucket. Amazon S3 returns your custom error document for only the HTTP 4XX class of error codes. How to