RSS
热门关键字:
当前位置 :| 主页>JAVA Development>

The blemish of Java line Cheng

来源: 作者:Stand originally 时间:2008-12-21 Tag: 点击:


The problem of the visit

If lack good visit control, can make line Cheng process designing very difficult. Below most circumstance, if can make sure line Cheng is called from inside synchronous subsystem only, need not consider line Cheng safety (Threadsafe) problem. I suggest to the visit of Java programming language attributive concept does following restriction; Answer to use Package key word accurately to restrict a bag to visit authority. I think the existence when default behavior is a flaw of a kind of any computer languages, I feel to be being put in attributive of this kind of default now very puzzle (and this kind of default is “ bag (Package)” form is other and not be “ demesne (Private)” ) . In other respect, java programming language does not offer the default key word that be equal. Although use the definitive of explicit Package to be able to destroy existing code, but it will make the readability of code stronger, can eliminate whole kind potential mistake (for example, if as a result of,visit authority is mistake by oversight, is not by intended oversight) . Introduce Private Protected afresh, its function should be mixed present Protected is same, but the visit that should not allow to include level. The visit ” that allows Private Private grammar to appoint “ to come true to all and external object it is illicit some, it is current even same to what seem kind. To “ . ” cites exclusively leftly (concealed type or explicit) should be This. The grammar of patulous Public, with accredit it can be made specific kind visit. For example, the code below should allow Fred kind the object can call Some_method() , but to other kind object, this method should be illicit some.

This kind of proposal is different from the "friend" mechanism of C . In "friend" mechanism, its accredit kind of visit another kind all demesne part. Here, I suggest to finite method gather undertakes strict pilot is visited. With this kind of method, kind can be another kind of definition an interface, and this interface is right systematic the others kind it is sightless. An apparent change is:

Unless region cites, is truly changeless (main type of the object of Immutable) or Static Final, otherwise the definition of all region should be Private. To kind in two when the direct visit of region disobeyed OO to design basic regulation: Abstraction and enclose. From the point of the viewpoint of line Cheng, allow to visit region to make undertake to it only directly asynchronous the visit is a few easier.

Add $property key word. The target that contains this key word can be visited by process of application of ” of box of a “bean, this program is used in Class kind in the reflex of the definition is operated (Introspection) API, be the same as effect with Private Private otherwise. $property attribute can be used in region and method, so existing JavaBean Getter/setter method can be defined easily to be attribute.

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册