coding-style

SQL Server 2005: “Protecting” stored procedures from FMTONLY mode used by MS Access

∥☆過路亽.° 提交于 2019-12-12 07:24:44
问题 Some of the stored procedures we have contain conditional logic, like this: Create Procedure dbo.DoSomething(Some Parameters) As ... If (Some Condition) Begin Set @SomeVariable = SomeValue End ... Select ... When such a stored procedure is used as a recordsource for an MS Access form, and user tries to use built-in sorting/filtering functionality of the form, MS Access tries to execute the stored procedure in FMTONLY mode (apparently, hunting for metadata of the rowset provided by the stored

Is there a standard in java for _ (underscore) in front of variable or class names?

天涯浪子 提交于 2019-12-12 07:07:00
问题 I have seen some programmers using _ (underscore) in front of class names, and others using it for local variables. Does the Java standard require/suggest the use of _ (underscore) in front of an private instance variable or class name? 回答1: It is a matter of personal taste. Martin Fowler appears to like it. I don't care much for it - it breaks the reading pattern, and the information it conveys is already subtly told by color in your IDE. I've experimented with using _ as the name of the

How to apply ReSharper Ultimate Naming Styles for C++

六月ゝ 毕业季﹏ 提交于 2019-12-12 06:55:32
问题 I don't know how to apply naming style for C++ language in Resharper Ultimate Extension for Visual Studio 2015 Update 3. My OS is Windows 10. Everything works fine for other languages (like C#) and I have only this problem with C++ language. In ReSharper>Options>Code Editing>C++>Naming Style, I stipulated class names to be all lowercase. I tried running ‘Cleanup Code’, ‘Find Code Issues’, and ‘Inspect Current Project for Code Issues’. Still, the class fields that do not conform to my

C# Winforms Panel with same style (shadow) as TabControl?

泪湿孤枕 提交于 2019-12-12 04:53:33
问题 I want a panel to have some sort of dropshadow like the TabControl has, is this possible? 回答1: BorderStyle = Fixed3D take a look for the shadow in this example: http://www.onteorasoftware.com/downloads/panelwithshadow.zip Finally, the custom panel could be like (in VB): Imports System.Drawing.Drawing2D Public Class ShadowPanel Inherits Panel Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As IntPtr) _ As IntPtr Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC

How to avoid violating the DRY principle when the boolean expression of a while loop is reassigned every loop pass?

喜欢而已 提交于 2019-12-12 03:49:34
问题 Both while MyFunction(1, 2, 3) > 0 do begin Temp := MyFunction(1, 2, 3); ShowMessage(IntToStr(Temp)); end; and Temp := MyFunction(1, 2, 3); while Temp > 0 do begin ShowMessage(IntToStr(Temp)); Temp := MyFunction(1, 2, 3); end; violate the DRY principle because there are two calls to MyFunction when only one is necessary. 回答1: Easy, function dotemp(a,b,c:integer;var value : integer):boolean; begin value:a*b+c; result:=value>0; end; begin while dotemp(a,b,c,temp) do begin Operateontemp(temp);

How do I avoid users of my code having to type redundant import lines?

前提是你 提交于 2019-12-12 02:45:49
问题 So I have a project called "Pants" that lives on GitHub.com. Originally the project was a single .py file called pants.py . Pants/ pants.py README.md and users could import and use it as follows: import pants w = pants.World() Both of these feel fine to me. Then I read up on how to structure a project with unit tests included, and initially reorganized my project thusly: Pants/ pants.py README.md test/ __init__.py test_world.py test_ant.py The problem with this is that although users can

Is there a more elegant way to write these loops?

南笙酒味 提交于 2019-12-12 02:39:19
问题 I have a script that requires a handful of parameters to run. I'm interested in exploring the results as the parameters change, so I define a few scan arrays at the top, wrap the whole code in multiple for loops and set the parameters values to the current scan values. This is error prone and inelegant. The process for changing the code is: 1) reset scan variables at the top, 2) comment out eg b = scan2(j2) and 3) uncomment b=b0 . What's a better method to allow variables to be set to arrays,

What's the preferred way to include unicode in python source files?

佐手、 提交于 2019-12-12 02:27:32
问题 When using unicode strings in source code, there seems to be many ways to skin a cat. The docs and the relevant PEPs have plenty of information about what's possible, but are scant about what is preferred. For example, the following each seem to give same result: # coding: utf8 u1 = '\xe2\x82\xac'.decode('utf8') u2 = u'\u20ac' u3 = unichr(0x20ac) u4 = "€".decode('utf8') u5 = u"€" If using the __future__ imports, I've found one more option: # coding: utf8 from __future__ import unicode

C++: Template Parameter Cyclic Dependency

好久不见. 提交于 2019-12-12 02:13:06
问题 This is more a best practice question than a language question in itself, since I already have a working solution to what seems to be a common stumbling block in C++. I'm dealing with a typical cyclic dependency issue in template parameter substitutions. I have the following pair of classes: template<class X> class A { /* ... */ }; template<class X> class B { /* ... */ }; and I want to instantiate each one as the following: // Pseudocode -- not valid C++. A<B> a; B<A> b; that is, I want to

Why/How to use passed constants in function?

社会主义新天地 提交于 2019-12-12 00:18:56
问题 I've seen classes where constants are passed to methods, I guess its done to define some kind of setting in that function. I cant find it anywhere now to try to find out the logic, so I though I could ask here. How and why do you use this concept and where can I find more information about it? The example below is written in PHP, but any language that handles constants would do I guess.. // Declaring class class ExampleClass{ const EXAMPLE_CONST_1 = 0; const EXAMPLE_CONST_2 = 1; function