conventions

Annotating methods with no implementation

て烟熏妆下的殇ゞ 提交于 2019-12-13 00:36:04
问题 In the interest of clean and beautiful code, I've been looking for an answer to a question that's popped up whist documenting my latest project. Often times, there will be an abstract class or interface with methods requiring implementation; and occasionally, the class inheriting these methods have other specific and unique methods which make those inherited obsolete, and thus never referenced. To avoid adding functionality where functionality is not used, I've left these obsolete inherited

When to throw exceptions?

爱⌒轻易说出口 提交于 2019-12-12 19:04:28
问题 Exceptions are wonderful things, but I sometimes worry that I throw too many. Consider this example: Class User { public function User(user){ // Query database for user data if(!user) throw new ExistenceException('User not found'); } } I'd argue that it makes as much sense to simply return false (or set all user data to false in this case), rather than throwing an exception. Which do you prefer? 回答1: Throw exception in exceptional circumstances. If the condition is something you expect in the

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} $

Named numbers as variables [closed]

旧巷老猫 提交于 2019-12-12 07:32:35
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I've seen this a couple of times recently in high profile code, where constant values are defined as variables, named after the value, then used only once. I wondered why it gets done? E.g. Linux Source (resize.c) unsigned five = 5; unsigned seven = 7; E.g. C#.NET Source

c# coding convention public/private contexts

蓝咒 提交于 2019-12-12 04:33:19
问题 I'm learning C# and I'm creating a simple WinForms application, and what it does is starting a simple OpenVPN client: void button_Connect_Click(object sender, EventArgs e) { var proc = new Process(); proc.StartInfo.FileName = "CMD.exe"; proc.StartInfo.UseShellExecute = false; proc.StartInfo.WorkingDirectory = @"C:\Program Files (x86)\OpenVPN\bin"; proc.StartInfo.Arguments = "/c openvpn.exe --config config.ovpn --auto-proxy"; // set up output redirection proc.StartInfo.RedirectStandardOutput =

Guide for working with Linux thread priorities and scheduling policies? [closed]

纵然是瞬间 提交于 2019-12-12 01:53:17
问题 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'm having trouble getting the hang of thread(/process) prioritization on Linux, scheduling policy selection, what to choose when and how, and what the exact effects are. Is there any documentation (like a guide) somewhere, preferably with concrete examples and timelines, which I could consult? 回答1: I'm having

Overwriting arguments object for a Javascript function

痴心易碎 提交于 2019-12-11 16:58:42
问题 If I have the following: // Clean input. $.each(arguments, function(index, value) { arguments[index] = value.replace(/[\W\s]+/g, '').toLowerCase(); }); Would that be a bad thing to do? I have no further use for the uncleaned arguments in the function, and it would be nice not to create a useless copy of arguments just to use them, but are there any negative effects to doing this? Ideally I would have done this, but I'm guessing this runs into problems since arguments isn't really an Array:

Is it better to have more Java classes, or have fewer classes doing more work? [closed]

末鹿安然 提交于 2019-12-11 10:05:39
问题 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 6 years ago . I'm currently working on a game. At the moment, I have one class (the game's environment) responsible for holding collections of game

Is there a convention, when using Java RMI, to use the dollar sign $ in a variable name?

半世苍凉 提交于 2019-12-11 05:45:33
问题 I realize that it is a valid part of a variable name, but I've never seen variable names actually use the symbol $ before. The Java tutorial says this: Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. However, since this is geared toward Java beginners, I'm wondering if in the distributed world, the $ lives on with a special

Entity Framework Ignore property by conventions

可紊 提交于 2019-12-10 15:17:52
问题 I have a code-first model where all entities are derived from a Entity base class. I have a property IsDeleted in base class which I want to ignore in all entities (I cannot remove/comment IsDeleted property since base class is used in many projects). Is there a way to configure modelBuilder to ignore this property form all entities (by conventions, I think), without to specify modelBuilder.Entity<...>().Ignore(l => l.IsDeleted) for all entities from my model? Thanks, Ion 回答1: You can do this