Principles of Package Architecture

Below are three principles known as the Package Cohesion Principles, that attempt to help the software architect.

The Release Reuse Equivalency Principle (REP)1

The granule of reuse is the granule of release.

A reusable element, be it a component, a class, or a cluster of classes, cannot be

reused unless it is managed by a release system of some kind. Users will be unwilling

to use the element if they are forced to upgrade every time the author changes it.

Thus. even though the author has released a new version of his reusable element, he

must be willing to support and maintain older versions while his customers go about

the slow business of getting ready to upgrade. Thus, clients will refuse to reuse an element

unless the author promises to keep track of version numbers, and maintain old

versions for awhile.

Therefore, one criterion for grouping classes into packages is reuse. Since packages

are the unit of release, they are also the unit of reuse. Therefore architects would do

well to group reusable classes together into packages.

The Common Closure Principle (CCP)2

Classes that change together, belong together.

A large development project is subdivided into a large network of interelated packages.

The work to manage, test, and release those packages is non-trivial. The more

packages that change in any given release, the greater the work to rebuild, test, and

deploy the release. Therefore we would like to minimze the number of packages that

are changed in any given release cycle of the product.

To achieve this, we group together classes that we think will change together. This

requires a certain amount of precience since we must anticipate the kinds of changes

that are likely. Still, when we group classes that change together into the same packages,

then the package impact from release to release will be minimzed.

The Common Reuse Principle (CRP)3

Classes that aren’t reused together should not be grouped together.

A dependency upon a package is a dependency upon everything within the package.

When a package changes, and its release number is bumped, all clients of that pack-age must verify that they work with the new package -- even if nothing they used

within the package actually changed.

We frequently experience this when our OS vendor releases a new operating system.

We have to upgrade sooner or later, because the vendor will not support the old version

forever. So even though nothing of interest to us changed in the new release, we

must go through the effort of upgrading and revalidating.

The same can happen with packages if classes that are not used together are grouped

together. Changes to a class that I don’t care about will still force a new release of the

package, and still cause me to go through the effort of upgrading and revalidating.

The Package Coupling Principles.

The next three packages govern the interlationships between packages. Applications

tend to be large networks of interlated packages. The rules that govern these interrelationship

are some of the most important rules in object oriented architecture.

The Acyclic Dependencies Principle (ADP)1

The dependencies betwen packages must not form cycles.

Since packages are the granule of release, they also tend to focus manpower. Engineers

will typically work inside a single package rather than working on dozens. This

tedency is amplified by the package cohesion principles, since they tend to group together those classes that are related. Thus, engineers will find that their changes are

directed into just a few package. Once those changes are made, they can release those

packages to the rest of the project.

The Stable Dependencies Principle (SDP)1

Depend in the direction of stability.

Though this seems to be an obvious principle, there is quite a bit we can say about it.

Stability is not always well understood.

The Stable Abstractions Principle (SAP)1

Stable packages should be abstract packages.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值