definition

What is the meaning and reasoning behind the Open/Closed Principle?

独自空忆成欢 提交于 2019-12-17 10:25:11
问题 The Open/Closed Principle states that software entities (classes, modules, etc.) should be open for extension, but closed for modification. What does this mean, and why is it an important principle of good object-oriented design? 回答1: Specifically, it is about a "Holy Grail" of design in OOP of making an entity extensible enough (through its individual design or through its participation in the architecture) to support future unforseen changes without rewriting its code (and sometimes even

Is is a good practice to put the definition of C++ classes into the header file?

牧云@^-^@ 提交于 2019-12-17 10:22:45
问题 When we design classes in Java, Vala, or C# we put the definition and declaration in the same source file. But in C++ it is traditionally preferred to separate the definition and declaration in two or more files. What happens if I just use a header file and put everything into it, like Java? Is there a performance penalty or something? 回答1: The answer depends on what kind of class you're creating. C++'s compilation model dates back to the days of C, and so its method of importing data from

Is there any use for local function declarations?

五迷三道 提交于 2019-12-17 09:43:11
问题 Most C++ programmers like me have made the following mistake at some point: class C { /*...*/ }; int main() { C c(); // declares a function c taking no arguments returning a C, // not, as intended by most, an object c of type C initialized // using the default constructor. c.foo(); // compiler complains here. //... } Now while the error is pretty obvious once you know it I was wondering if there is any sensible use for this kind of local function declaration except that you can do it --

What exactly does “closure” refer to in JavaScript?

别说谁变了你拦得住时间么 提交于 2019-12-17 08:13:05
问题 I understand what closures are, but I am having some trouble grokking exactly what the term closure refers to. I have seen the term used in many websites, but rarely do they agree on the actual definition of it. Is it the variables that are kept on the stack frame? Is it the function that is being returned? Is it the scope of the outer function? Is it the scope of the inner (returned) function? Is it maybe the concept of keeping the variables on the stack-frame after returning the function?

What exactly does “closure” refer to in JavaScript?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 08:12:01
问题 I understand what closures are, but I am having some trouble grokking exactly what the term closure refers to. I have seen the term used in many websites, but rarely do they agree on the actual definition of it. Is it the variables that are kept on the stack frame? Is it the function that is being returned? Is it the scope of the outer function? Is it the scope of the inner (returned) function? Is it maybe the concept of keeping the variables on the stack-frame after returning the function?

What exactly do “IB” and “UB” mean?

妖精的绣舞 提交于 2019-12-17 03:00:52
问题 I've seen the terms "IB" and "UB" used several times, particularly in the context of C++. I've tried googling them, but apparently those two-letter combinations see a lot of use. :P So, I ask you...what do they mean, when they're said as if they're a bad thing? 回答1: IB: Implementation-defined Behaviour. The standard leaves it up to the particular compiler/platform to define the precise behaviour, but requires that it be defined. Using implementation-defined behaviour can be useful, but makes

What is this strange function definition syntax in C? [duplicate]

断了今生、忘了曾经 提交于 2019-12-17 02:50:13
问题 This question already has answers here : Alternative (K&R) C syntax for function declaration versus prototypes (5 answers) Closed 5 years ago . I've seen a few function definitions like this recently while playing with GNU Bison: static VALUE ripper_pos(self) VALUE self; { //code here } Why is the type of self outside of the parenthesis? Is this valid C? 回答1: Those are old K&R style function parameter declarations, declaring the types of the parameters separately: int func(a, b, c) int a; int

SOAP vs REST (differences)

半腔热情 提交于 2019-12-16 19:57:10
问题 I have read articles about the differences between SOAP and REST as a web service communication protocol, but I think that the biggest advantages for REST over SOAP are: REST is more dynamic, no need to create and update UDDI(Universal Description, Discovery, and Integration). REST is not restricted to only XML format. RESTful web services can send plain text/JSON/XML. But SOAP is more standardized (E.g.: security). So, am I correct in these points? 回答1: Unfortunately, there are a lot of

Selector for “Define” Edit Menu item in iOS 5

喜你入骨 提交于 2019-12-14 03:46:01
问题 I'm building my own custom Edit Menu (UIMenuController) and am using the typical -(BOOL)canPerformAction:(SEL)action withSender(id)sender method to conditionally enable / disable system defaults. The typical edit methods are well documented (copy:, cut:, etc.), but I can't find anything about what method is called by the "Define" menu option to pull up the new word dictionary in iOS 5. Maybe it's hiding in plain sight, but I've spent hours looking for it, so I'd appreciate any help.

Difference between framework and container?

时间秒杀一切 提交于 2019-12-13 12:19:08
问题 I was reading this question on SO: Framework vs. Toolkit vs. Library where is explained difference between framework and library. General opinion is that main difference is in Inversion of Control, so you have hot spots in framework where you attach your application functionality (in essence you choose between inheritance/template/heavyweight or composition/strategy/lightweight to achieve that). Ok, now I am curious what is difference between framework and container then? I saw following