向前兼容与向后兼容

http://en.wikipedia.org/wiki/Forward_compatibility


[总结]向前兼容: 老版本必须能理解/处理新版本的部分数据.
          向后兼容: 新版本处理老版本的数据.




向下兼容(downward compatibility),又称向后兼容(backward compatibility)、向后兼容,在计算机中指在一个程序和/或库更新到较新版本后,用旧版本程序创建的文档或系统仍能被正常操作或使用(包括写入),或在旧版本库的基础上开发的程序仍能正常编译运行的情况。
在文件系统中,ext4文件系统的设计就是向后兼容的,ext3的文件系统可以被当作ext4文件系统挂载。
但情况并不总是这样,有时为了考虑向下兼容会带来一些累赘,尤其是进行过较多升级后。Python 3.0 便是放弃向下兼容的一个例子[2][3]。
如果一个软件的旧的版本保存的文档不能被新版本读取,即使厂商提供了额外工具对旧文档进行不可逆转的转换,这也不能称作向下兼容。这可能是软件厂商的一种市场战略,强迫用户购买升级软件,随着升级用户逐渐增加,逐渐地使得旧软件能读取的文档越来越少。




向前/向上兼容(Forward compatibility or upward compatibility)
Forward compatibility aims at the ability of a design to gracefully accept input intended for later versions of itself. The concept can be applied to entire systems, electrical interfaces, telecommunication signals, data communication protocols, file formats, and computer programming languages. A standard supports forward compatibility if older product versions can receive, read, view, play or execute the new standard.


Although forward compatibility and extensibility concepts are similar, they are not the same. A forward compatible design can accept data from a future version of itself and pick out the "known" part of the data. An example is a text-only word processor ignoring picture data from a future version. An extensible design is one that can be upgraded to fully handle the new data in the newer input format. An example is a text-only word processor that can be upgraded to handle picture data.
A forward compatible system is expected to "gracefully" handle input which is intended for a newer version, by ignoring the unknowns and selecting the known subset of the data that the system is capable of handling.
Forward compatibility is harder to achieve than backward compatibility because a system needs to cope gracefully with an unknown future data format or requests for unknown future features. Backward compatibility does not have this issue because it accepts a known data format.


向前/向上兼容是指老版本的产品可以接收、读取、查看、执行新版本的数据或者标准.应用于系统设计、通信,文件格式,编程语言。
向前兼容也就意味着老版本必须能理解/处理新版本的部分数据,忽略未知数据。由于要求系统能优雅地处理将来未知的功能引入的未知数据格式, 向前兼容比向下兼容实现的难度要大。


Examples:


Document formats

An example of forward compatibility is with a word processor. Assume that Version 1 of a word processor only allows text, and no graphics. It saves files with only information about the text typed, and the font, color, and size of the text. Let's say that the program adds the mark [VERSION1 END] to denote the end of the file. However, next year Version 2 is released that accepts graphics. However, the new word processor saves all of the text at the beginning of the file, puts the [VERSION1 END] mark, and then stores the picture data next, and puts a [VERSION2 END] mark after the picture data. The Version 1 word processor would still be able to read the text data up to the [VERSION1 END] mark, but would ignore the picture data afterward. When Version 3 is released that allows videos in the word processor file, it would save in this format: text data [VERSION1 END], picture data [VERSION2 END], and video data [VERSION3 END].

[edit]Adobe Reader / Adobe Acrobat

Although the above file design allows forward compatibility, there are additional features that can be added to be more useful to the user. One would be if Version 1 of a program printed a message that the file was created with a newer version of the software, and that some data was not available. The Adobe Reader program generates a message notifying the user of a PDF file that it was created in a newer version of Adobe Acrobat, and some features will not be available.

[edit]MS Word

Another useful feature is if Version 1 of a program offered to download a viewer or converter that allows the user to at least read files from newer versions of the program, even though the user may not be able to edit them. In the above word processor example, Version 1 would download updates from the internet that allows the user to see the pictures and videos in later versions of the word processor, even though the user cannot add, edit, or modify the multimedia data, due to that functionality not being in Version 1. An example of this functionality is Microsoft Word. When a document is created in Microsoft Word 2007 and opened in an earlier version (like Microsoft Word 2003), Microsoft Word 2003 tells the user it can download a converter to read files in the newer Microsoft Word 2007 format. This allows Microsoft Word 2003 to read data created by Microsoft Word 2007, even though the user cannot use Microsoft Word 2003 to build new data in the advanced format.

[edit]PNG

An example of forward compatibility is the Portable Network Graphics (PNG) format, which divides data into "chunks", and indicates whether these are "critical" or "ancillary", where ancillary chunks can be ignored by programs that do not understand them.

More subtly, it also indicates whether chunks are safe to copy by readers that do not recognize them – thus ensuring that data does not become out of sync.



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值