coding-style

Legible or not: C# multiple ternary operators + Throw if unmatched [closed]

爱⌒轻易说出口 提交于 2019-12-18 11:41:34
问题 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 . Do you find the following C# code legible? private bool CanExecuteAdd(string parameter) { return this.Script == null ? false :

Setting top and left CSS attributes

懵懂的女人 提交于 2019-12-18 10:58:49
问题 For some reason I'm unable to set the "top" and "left" CSS attributes using the following JavaScript. var div = document.createElement('div'); div.style.position = 'absolute'; div.style.top = 200; div.style.left = 200; document.body.appendChild(div); Using Firebug I can see that the div gets the position set to "absolute" but the top and left attributes are not set! This is for Firefox 3.6. 回答1: div.style.top = "200px"; div.style.left = "200px"; 回答2: You can also use the setProperty method

Netbeans 7.4 introduces “10 lines max” per method rule. Where does this rule come from?

半城伤御伤魂 提交于 2019-12-18 10:44:12
问题 NetBeans 7.4 beta is currently available for public download, and it introduces a weird warning rule by default: Method length is 16 lines (10 allowed) My question is: Is this an accepted code convention rule, that can be proven somehow, somewhere ? NetBeans support/devs say it's not a bug, but don't give a statement why they only allow 10 lines, and where exactly this rule has its origin. 回答1: You can change the maximum method/function length warning behavior in NetBeans options (it's under

List of highly-regarded PHP style guides?

偶尔善良 提交于 2019-12-18 10:33:19
问题 I've recently been shaking up my coding habits and have been toying with various approaches to coding style... things like using a space between method call parentheses and the parameters they contain, how to deal with multi-line array definitions and method calls, etc. I'm wary of creating my personal flavor of everything, though, and want to skim through some well-regarded "authoritative" style guides. Which ones should I look at? I've had a hard time finding much other than the Zend guide.

Android Code Style in Intellij Idea / Android Studio

让人想犯罪 __ 提交于 2019-12-18 10:23:17
问题 Before Android Studio, I was using android-formatting.xml as Code Style in Eclipse. How can I setup Android Studio / Intellij Idea to format code as in Eclipse? UPDATE I tried Eclipse Code Formatter plugin. It seems to work, but you cannot edit any setting at all. My team prefers 120 columns instead of 100. I tried @CrossleSong answer too. It's a bit tricky, but more powerful. You can save this https://android.googlesource.com/platform/development/+/android-4.2.2_r1.2/ide/intellij/codestyles

Any reason NOT to always use keyword arguments?

泪湿孤枕 提交于 2019-12-18 10:16:10
问题 Before jumping into python, I had started with some Objective-C / Cocoa books. As I recall, most functions required keyword arguments to be explicitly stated. Until recently I forgot all about this, and just used positional arguments in Python. But lately, I've ran into a few bugs which resulted from improper positions - sneaky little things they were. Got me thinking - generally speaking, unless there is a circumstance that specifically requires non-keyword arguments - is there any good

How do you implement unit-testing in large scale C++ projects? [closed]

六月ゝ 毕业季﹏ 提交于 2019-12-18 10:16:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I believe strongly in using unit-tests as part of building large multi-platform applications. We currently are planning on having our unit-tests within a separate project. This has the benefit of keeping our code base clean. I think, however, that this would separate the test code from the implementation of the

Confused about the Interface and Class coding guidelines for TypeScript

百般思念 提交于 2019-12-18 10:06:02
问题 I read through the TypeScript Coding guidelines And I found this statement rather puzzling: Do not use "I" as a prefix for interface names I mean something like this wouldn't make a lot of sense without the "I" prefix class Engine implements IEngine Am I missing something obvious? Another thing I didn't quite understand was this: Classes For consistency, do not use classes in the core compiler pipeline. Use function closures instead. Does that state that I shouldn't use classes at all? Hope

Is using assert() in C++ bad practice?

为君一笑 提交于 2019-12-18 10:05:59
问题 I tend to add lots of assertions to my C++ code to make debugging easier without affecting the performance of release builds. Now, assert is a pure C macro designed without C++ mechanisms in mind. C++ on the other hand defines std::logic_error , which is meant to be thrown in cases where there is an error in the program's logic (hence the name). Throwing an instance might just be the perfect, more C++ish alternative to assert . The problem is that assert and abort both terminate the program

What is the recommended coding style for PowerShell?

你。 提交于 2019-12-18 10:04:40
问题 Is there any recommended coding style how to write PowerShell scripts? It's not about how to structure the code (how many functions, if to use module, ...). It's about ' how to write the code so that it is readable '. In programming languages there are some recommended coding styles (what to indent , how to indent - spaces/tabs, where to make new line , where to put braces ,...), but I haven't seen any suggestion for PowerShell. I'm interested particularly in: How to write parameters function