我已经编程好几个月了,在课堂上经常使用的一个词是“上下文”。比如ServletContext (Java), Activity (Android), Service (Java, Android), NSManagedContext (Objective-C, iOS)。
通过查字典,我知道这个词的意思是:处境,环境,情况等。然而,因为我的母语不是英语,我不知道我应该直接翻译成什么。例如,如果我要编写一个命名为SomeClassContext的类,或者一个具有上下文参数的方法,我就不知道什么时候应该将其命名为context,因为我不理解它。
我一直在Stack Overflow上搜索上下文,但没有问题/答案能够帮助我。
如果有人能给我解释一下,我将非常高兴。
作者常常假定读者对“上下文”这个词所处的语境有详细的了解。
如何在下面的句子“the ?”运行时创建一个上下文,其中可以存储可能的注入值。这个上下文可以被修改,例如,应用程序和框架可以向上下文添加元素。
It would seem the author is using context to mean some kind of container, perhaps a heap, that holds the context of something. It has become buzz word that is taking on many meaning and confusing things. Is it the elements that are the context and are being stored in a context. To reduce the confusion of the context that the word context is being used it could be said that "the runtime creates a container to store the context in the form of elements." Better yet "the runtime creates a container to store the state in the form of elements and this container with it's state is called the CONTEXT."
这是2015年,在这篇文章开始的5年之后。
尽管如此,我发布这条消息是为了帮助那些像我一样难以理解“上下文”的人
我绝不声称在Java程序中使用了Context——所以完全取决于你用硬编码来编写Context
所以是这样的:-
"概念上的上下文"和"告诉我更多"是一样的当客户
向服务器发出请求-以便执行请求
服务员说:“给我更多的信息,这样我可以帮助你。”因此,
除了请求,客户端还提供了一组详细信息。的
服务器从包中选择所需的所有信息
为请求服务。这个bundle叫做Context
E.g.
病人去找医生说给我治疗(“我头痛”)医生
办公室给了病人一张表格让他们填写。病人填写表格。表单
由医生用于执行“treat_me”请求。
下面是请求现在的样子:
treat_me ( "i have a headache", filled_form_num_23321 )
下面是filled_form_num_23321的外观:
问题:什么导致了这种情况?A.昨晚喝了10杯纯苏格兰威士忌
病人姓名?年龄?98
在这个事务中,filled_form_num_23321是“context”。
希望这有助于澄清“上下文”的概念。