terminology

What is Stateless Object in Java?

让人想犯罪 __ 提交于 2019-12-17 08:18:10
问题 Currently I'm reading "Java concurrency in practice", which contains this sentence: Since the action of a thread accessing a stateless object can't affect the correctness of operations on other threads, stateless objects are thread-safe. So, what is stateless object? 回答1: Stateless object is an instance of a class without instance fields (instance variables). The class may have fields, but they are compile-time constants (static final). A very much related term is immutable . Immutable

Difference between a deprecated and a legacy API?

我只是一个虾纸丫 提交于 2019-12-17 07:17:21
问题 I was studying the legacy API's in the Java's Collection Framework and I learnt that classes such as Vector and HashTable have been superseded by ArrayList and HashMap . However still they are NOT deprecated, and deemed as legacy when essentially, deprecation is applied to software features that are superseded and should be avoided, so, I am not sure when is a API deemed legacy and when it is deprecated. 回答1: From the official Sun glossary: deprecation : Refers to a class, interface,

Is Java really passing objects by value? [duplicate]

耗尽温柔 提交于 2019-12-17 07:10:19
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Is Java pass by reference? public class myClass{ public static void main(String[] args){ myObject obj = new myObject("myName"); changeName(obj); System.out.print(obj.getName()); // This prints "anotherName" } public static void changeName(myObject obj){ obj.setName("anotherName"); } } I know that Java pass by value, but why does it pass obj by reference in previous example and change it? 回答1: Java always passes

What is the 'cls' variable used for in Python classes?

只谈情不闲聊 提交于 2019-12-17 05:16:19
问题 Why is cls sometimes used instead of self as an argument in Python classes? For example: class Person: def __init__(self, firstname, lastname): self.firstname = firstname self.lastname = lastname @classmethod def from_fullname(cls, fullname): cls.firstname, cls.lastname = fullname.split(' ', 1) 回答1: The distinction between "self" and "cls" is defined in PEP 8 . As Adrien said, this is not a mandatory. It's a coding style. PEP 8 says: Function and method arguments : Always use self for the

What is an opaque value in C++?

百般思念 提交于 2019-12-17 05:01:30
问题 What is an "opaque value" in C++? 回答1: An example for an Opaque Value is FILE (from the C library): #include <stdio.h> int main() { FILE * fh = fopen( "foo", "r" ); if ( fh != NULL ) { fprintf( fh, "Hello" ); fclose( fh ); } return 0; } You get a FILE pointer from fopen() , and use it as a parameter for other functions, but you never bother with what it actually points to . 回答2: "Opaque" is defined, in English, as "not able to be seen through; not transparent". In Computer Science, this means

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

When is a language considered a scripting language? [closed]

不问归期 提交于 2019-12-17 02:52:18
问题 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 . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. What makes a language a scripting language? I've heard some people say "when it gets interpreted

Why are two different concepts both called “heap”?

无人久伴 提交于 2019-12-17 02:30:11
问题 Why are the runtime heap used for dynamic memory allocation in C-style languages and the data structure both called "the heap"? Is there some relation? 回答1: Donald Knuth says (The Art of Computer Programming, Third Ed., Vol. 1, p. 435): Several authors began about 1975 to call the pool of available memory a "heap." He doesn't say which authors and doesn't give references to any specific papers, but does say that the use of the term "heap" in relation to priority queues is the traditional

What is this practice called in JavaScript?

你说的曾经没有我的故事 提交于 2019-12-17 02:27:05
问题 When you wrap your JavaScript code in a function like this: (function(){ var field = ...; function doSomthing(){... ... })(); I noticed that this fixes scoping problems for me on a lot of web pages. What is this practice called? 回答1: The pattern is called self-invocation , a self-invoking function . It can create a closure, but that is an effect of the pattern (perhaps the intended effect), not the pattern itself. 回答2: To clarify a bit for the comments below, most of the time it's creating a

Green Threads vs Non Green Threads

久未见 提交于 2019-12-17 00:52:52
问题 I'd like to understand the advantages provided by these type of threads. In what environments are green threads better than non-green? Some say green threads are better for multi core processors. Any expected behaviour problems. 回答1: The Wikipedia article Green Threads explains it very well. Green threads are "user-level threads". They are scheduled by an "ordinary" user-level process, not by the kernel. So they can be used to simulate multi-threading on platforms that don't provide that