不断地关于编程

程序,功能和方法 (Procedures, functions and methods)

Subprograms that are called are referred as “procedures”. In general, function returns value of a certain type, whereas procedure doesn’t return anything. But C-like languages which have only functions, see procedures as functions returning Void. Void means returns nothing. And methods in OO languages behave as functions and procedures but connected with a class. (Dragon Book).

称为“子程序”的子程序。 通常, 函数返回某种类型的值,而过程则不返回任何值。 但是只有功能的类似于C的语言,将过程视为返回Void的函数。 无效意味着什么也不返回。 OO语言中的方法充当函数和过程,但与类联系在一起。 (龙书)。

静态范围 (Static scope)

Inner blocks(scope) can see parameters from outer blocks(scope). But if a variable is defined in an inner block with similar name, the inner redefined variable is used when called.

内部块(范围)可以从外部块(范围)查看参数。 但是,如果在内部块中使用相似的名称定义了变量,则在调用时使用内部重新定义的变量。

动态范围 (Dynamic scope)

#define a (x + 1)

#定义一个(x + 1)

void b() { int x = 1; printf(“%d\n”, a); }

无效b(){int x = 1; printf(“%d \ n”,a); }

void c() {printf(“%d\n”, a); }

void c(){printf(“%d \ n”,a); }

void main() { b(); c(); }

void main(){b(); C(); }

When we define macros a with body { x + 1 }, x is undeclared yet, so it will search for definition of x variable when executed. For example, in main method b is called, which calls macros a in its turn in its definition. b defines int x = 1; when macros a is executed its x will refer to local x inside function b. Similar with function c. (Dragon Book)

当我们使用主体{x + 1}定义宏a时,尚未声明x,因此执行时它将搜索x变量的定义。 例如,在main方法中调用了b,它依次在其定义中调用了宏a。 b定义int x = 1; 当执行宏a时,其x将引用函数b中的局部x。 与功能c相似。 (龙书)

参量 (Parameters)

Procedures have parameters. Parameters are usually actual(фактические) and formal(формальные).

程序具有参数。 参数通常是实际的(фактические)正式的(формальные)。

Formal parameters are those used in procedure definition. func add(a: Int, b: Int) -> Int

形式参数是过程定义中使用的参数。 func add(a:Int,b:Int)-> Int

Actual parameters are those values/variables passed to procedure when it’s called. add(2, 5), add(x, y); (Dragon Book)

实际参数是在调用过程时传递给过程的那些值/变量。 add(2,5),add(x,y); (龙书)

传递价值 (Pass by value)

All changes are made to local copy of an actual parameter. But it’s possible to pass a pointer to a variable, so that function can change its value. Similar when a is the name of an array and passed to a formal parameter x, then x[i] = 10 will be equivalent to a[i] = 10. Although Java uses only passing by value, actually arrays, strings, class examples are passed by reference. (Dragon Book)

所有更改都是对实际参数的本地副本进行的。 但是可以将指针传递给变量,以便函数可以更改其值。 类似地,当a是数组的名称并传递给形式参数x时,x [i] = 10将等效于a [i] =10。尽管Java仅使用按值传递,实际上是数组,字符串,类示例通过引用传递。 (龙书)

通过参考 (Pass by reference)

It is the memory address which is passed when a parameter is passed by reference. So changing formal parameter will result in changing the actual parameter. Is used in C++ and other popular languages for passing large objects, arrays etc. Because passing those elements by value is very costly because of copying and locating.(Dragon Book)

它是通过引用传递参数时传递的内存地址。 因此,更改形式参数将导致更改实际参数。 在C ++和其他流行语言中用于传递大对象,数组等。因为按值传递这些元素非常昂贵,因为复制和定位非常困难。(《龙书》)

假名 (Pseudonyms)

When the same parameter is passed to procedure, whose parameters are passed by reference then they are pseudonyms. It’s crucial for compiler to optimize program to know that a variable has no pseudonyms and defined only in one place. (Dragon Book)

当相同的参数传递给过程时,其参数通过引用传递,则它们是假名。 对于编译器来说,优化程序以使其知道变量没有假名并且仅在一个位置进行定义至关重要。 (龙书)

工作区,生产力 (Workspace, productivity)

An ideal workspace for a programmer is where less people, less disturbing factors like phone ringing, coworker talking etc. Per day one should work at least 2–3 productive hours. Productive means in the flow. The flow is a state when you don’t realize how time passes by. (Peopleware)

对于程序员来说,理想的工作空间是更少的人,更少的干扰因素(例如电话铃声,同事交谈等)。每天,人们应该至少工作2-3个工作小时。 流动中的生产性手段。 当您不了解时间的流逝时,流程就是一种状态。 (人文软件)

The Parkinson’s law is not somehow valid for developers, and the more you put pressure on them doesn’t guarantee you succeeding project on time. But it gives only pressure and kills passion in developers. As a manager your responsibility isn’t to control developers and make them work, but to provide conditions for work. (Peopleware)

帕金森定律在某种程度上对开发人员无效,您对开发人员施加的压力越大,并不能保证您按时完成项目。 但这只会给开发人员带来压力,并杀死他们的热情。 作为经理,您的责任不是控制开发人员并使他们工作,而是为工作提供条件。 (人文软件)

10倍规则 (10x rule)

The best performers are in 1:10 ratio with the worst in terms of productivity. Usually, best performers, developers work mostly in specific companies. It might mean that specific conditions that those companies provide helps to raise productivity and improve as a developer, and also that best performers choose the one with specific workspace, conditions etc. My recap may somehow differ from what’s written in the book. But overall meaning is correct. (Peopleware)

表现最佳的是1:10的比率,而生产力最差的是。 通常,表现最好的开发人员大多在特定的公司工作。 这可能意味着这些公司提供的特定条件有助于提高生产率并改善开发人员的状况,并且最佳执行者会选择具有特定工作区,条件等条件的条件。我的总结可能与本书中所写内容有所不同。 但是总体含义是正确的。 (人文软件)

翻译自: https://medium.com/@Yerazhas/continuously-about-programming-a74ee7b29228

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值