确切地说,“上下文”命名约定是什么

时间:2022-01-23 23:31:25

I am trying to define when to name a class as a Context and I am having a very difficult time. Could someone please define "Context" for me and explain when to name a class "Context"?

我正在尝试定义何时将类命名为上下文,我遇到了困难。有人能帮我定义“Context”并解释什么时候命名一个类“Context”吗?

2 个解决方案

#1


1  

Dictionary.com (Random House Dictionary, © Random House, Inc. 2011) defines context as:

Dictionary.com(兰登书屋字典,©兰登书屋,2011年Inc .)将上下文定义为:

  1. the parts of a written or spoken statement that precede or follow a specific word or passage, usually influencing its meaning or effect: You have misinterpreted my remark because you took it out of context.
  2. 在一个特定的词或段落之前或之后的书面或口头陈述的部分,通常会影响它的意思或效果:你误解了我的话是因为你断章取义。
  3. the set of circumstances or facts that surround a particular event, situation, etc.
  4. 围绕某一事件、情况等的环境或事实的集合。

The second definition is the applicable definition in this case. Taking the HTTPContext class for example, we know that the class contains information about the web site at the current moment (including the request, the response, the session, the user, etc.)

第二个定义是在本例中适用的定义。以HTTPContext类为例,我们知道这个类包含关于当前站点的信息(包括请求、响应、会话、用户等)。

Therefore, I would define a 'Context' in this regard as a class that provides information about a particular application or service; or provides access to objects and methods that describe the current state of an application (or a particular facet of an application, such as a DataContext class in Linq To SQL or Entity Framework).

因此,我将在这方面定义一个“上下文”,作为提供关于特定应用程序或服务的信息的类;或者提供对描述应用程序当前状态的对象和方法的访问(或应用程序的特定方面,如Linq to SQL或实体框架中的DataContext类)。

#2


1  

If you look up the Oxford English Dictionary for "context" it tells us:

如果你查《牛津英语词典》查找“上下文”,它会告诉我们:

the circumstances that form the setting for an event, statement, or idea, and in terms of which it can be fully understood:

形成事件、陈述或想法的环境,并使其能够充分理解:

In programming a "context" class would be a class that provides your application code or code running within a framework with a set of data or objects relevant and meaningful to the task at hand.

在编程中,“上下文”类将是一个类,它提供应用程序代码或在框架内运行的代码,其中包含一组与当前任务相关且有意义的数据或对象。

For example, ASP.NET's HttpContext object provides information about the current HttpRequest (cookies, headers, user agent and so on). This data is meaningful only in the "context" of the current request as it may and will change for other requests.

例如,ASP。NET的HttpContext对象提供关于当前HttpRequest (cookies、header、user agent等)的信息。此数据仅在当前请求的“上下文中”才有意义,因为它可能会对其他请求进行更改。

#1


1  

Dictionary.com (Random House Dictionary, © Random House, Inc. 2011) defines context as:

Dictionary.com(兰登书屋字典,©兰登书屋,2011年Inc .)将上下文定义为:

  1. the parts of a written or spoken statement that precede or follow a specific word or passage, usually influencing its meaning or effect: You have misinterpreted my remark because you took it out of context.
  2. 在一个特定的词或段落之前或之后的书面或口头陈述的部分,通常会影响它的意思或效果:你误解了我的话是因为你断章取义。
  3. the set of circumstances or facts that surround a particular event, situation, etc.
  4. 围绕某一事件、情况等的环境或事实的集合。

The second definition is the applicable definition in this case. Taking the HTTPContext class for example, we know that the class contains information about the web site at the current moment (including the request, the response, the session, the user, etc.)

第二个定义是在本例中适用的定义。以HTTPContext类为例,我们知道这个类包含关于当前站点的信息(包括请求、响应、会话、用户等)。

Therefore, I would define a 'Context' in this regard as a class that provides information about a particular application or service; or provides access to objects and methods that describe the current state of an application (or a particular facet of an application, such as a DataContext class in Linq To SQL or Entity Framework).

因此,我将在这方面定义一个“上下文”,作为提供关于特定应用程序或服务的信息的类;或者提供对描述应用程序当前状态的对象和方法的访问(或应用程序的特定方面,如Linq to SQL或实体框架中的DataContext类)。

#2


1  

If you look up the Oxford English Dictionary for "context" it tells us:

如果你查《牛津英语词典》查找“上下文”,它会告诉我们:

the circumstances that form the setting for an event, statement, or idea, and in terms of which it can be fully understood:

形成事件、陈述或想法的环境,并使其能够充分理解:

In programming a "context" class would be a class that provides your application code or code running within a framework with a set of data or objects relevant and meaningful to the task at hand.

在编程中,“上下文”类将是一个类,它提供应用程序代码或在框架内运行的代码,其中包含一组与当前任务相关且有意义的数据或对象。

For example, ASP.NET's HttpContext object provides information about the current HttpRequest (cookies, headers, user agent and so on). This data is meaningful only in the "context" of the current request as it may and will change for other requests.

例如,ASP。NET的HttpContext对象提供关于当前HttpRequest (cookies、header、user agent等)的信息。此数据仅在当前请求的“上下文中”才有意义,因为它可能会对其他请求进行更改。