members

The size of a Get method

故事扮演 提交于 2019-12-08 15:41:10
问题 Are there any guidelines or general consensus towards the size of a 'Get' in terms of lines of code? I have a Get method on a member that has quite easily grown to 30 lines of code here. I'm not sure at what point this should be pulled out into a method. But then I'd only be calling it something like GetMyString and assigning the value to another member and calling it in the constructor anyway. Is it ever worth doing this? Is this too subjective for SO? 回答1: dcastro's answer is good but could

How can I get all (non-final) object vals and subobject vals using reflection in Scala?

爷,独闯天下 提交于 2019-12-06 11:33:15
Note: This question is not a duplicate of How can I get all object vals and subobject vals using reflection in Scala? The answer provided in that question only works for final members. For example: scala> object Settings { | val Host = "host" | } defined module Settings deepMembers(Settings) res0: Map[String,String] = Map() It must be a duplicate, but I need a refresher: $ scala Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45). Type in expressions to have them evaluated. Type :help for more information. scala> object Settings { val Host = "host" ; val Guest =

DB design : members table separate or all in one table?

做~自己de王妃 提交于 2019-12-04 06:15:14
问题 I want to create a table of friends with personal information and log on details. What better to separate the members table to 2 tables , one contain minimal details , second with Other details. or remain in one table ? i have a lot of tables that contain the foreign key of the member. 回答1: It depends a lot on what those "other" details are. This is a common and interesting question, and there is no "hard and fast" answer at first glance. But if we think of the issue more abstractly, about

Testing private class member in C++ without friend [duplicate]

限于喜欢 提交于 2019-12-03 05:01:32
问题 This question already has answers here : How do I test a private function or a class that has private methods, fields or inner classes? (51 answers) Closed last year . Today I had a discussion with a colleague on whether to test or not to test private members or private state in the class. He almost convinced me why it makes sense. This question does not aim to duplicate already existing StackOverflow questions about the nature and reason of testing private members, like: What is wrong with

Testing private class member in C++ without friend [duplicate]

孤街浪徒 提交于 2019-12-02 19:23:43
This question already has an answer here: How do I test a private function or a class that has private methods, fields or inner classes? 51 answers Today I had a discussion with a colleague on whether to test or not to test private members or private state in the class. He almost convinced me why it makes sense. This question does not aim to duplicate already existing StackOverflow questions about the nature and reason of testing private members, like: What is wrong with making a unit test a friend of the class it is testing? Colleagues suggestion was in my opinion a bit fragile to introduce

DB design : members table separate or all in one table?

坚强是说给别人听的谎言 提交于 2019-12-02 10:34:47
I want to create a table of friends with personal information and log on details. What better to separate the members table to 2 tables , one contain minimal details , second with Other details. or remain in one table ? i have a lot of tables that contain the foreign key of the member. It depends a lot on what those "other" details are. This is a common and interesting question, and there is no "hard and fast" answer at first glance. But if we think of the issue more abstractly, about the actual relationship among the attributes ("details") of any particular thing you want to represent, we may

labeling a group of members as private/public in c#

情到浓时终转凉″ 提交于 2019-12-01 22:18:57
问题 in a c++ class declaration, you can label a group of members as private or public, e.g. private: int x; double y; seems like there's no way to do this in c#. am I wrong? 回答1: No, you can't not do this in C#. At best, you can use the default visibility for members, which is private, and not use private, but for public, you have to indicate it for all members. 回答2: You're correct. Although, if you leave visibility keyword off altogether, a member defaults to private. 回答3: No you're not wrong.

labeling a group of members as private/public in c#

烂漫一生 提交于 2019-12-01 20:32:57
in a c++ class declaration, you can label a group of members as private or public, e.g. private: int x; double y; seems like there's no way to do this in c#. am I wrong? No, you can't not do this in C#. At best, you can use the default visibility for members, which is private, and not use private, but for public, you have to indicate it for all members. You're correct. Although, if you leave visibility keyword off altogether, a member defaults to private. No you're not wrong. If you don't write any modifiers it will be assumed as private. 来源: https://stackoverflow.com/questions/546869/labeling

Why do I get “warning: missing initializer for member”? [-Wmissing-field-initializers]

无人久伴 提交于 2019-11-30 20:27:26
I'm wondering why I am getting an warning about initialization in one case, but not the other. The code is in a C++ source file, and using GCC 4.7 with -std=c++11 . struct sigaction old_handler, new_handler; The above produces NO warnings with -Wall and -Wextra . struct sigaction old_handler={}, new_handler={}; struct sigaction old_handler={0}, new_handler={0}; The above produces warnings: warning: missing initializer for member ‘sigaction::__sigaction_handler’ [-Wmissing-field-initializers] warning: missing initializer for member ‘sigaction::sa_mask’ [-Wmissing-field-initializers] warning:

Union tested for current member in use

倾然丶 夕夏残阳落幕 提交于 2019-11-30 19:17:33
Do unions have a control structure to test which member is currently in use (or if it has any at all)? I'm asking this because undefined behavior is never a good thing to have in your program. No, no such mechanism exists off-the-shelf. You'll have to take care of that yourself. The usual approach is wrapping the union in a struct : struct MyUnion { int whichMember; union { //whatever } actualUnion; }; So you have MyUnion x; and x.whichMember tells you which field of x.actualUnion is in use (you have to implement the functionality though). 来源: https://stackoverflow.com/questions/11035534/union