记录下来,以便以后查看
thinking in java 4th
chapter one
resuing the implementation
[b]The simplest way to reuse a class is to just use an object of that class directly, but you can also place an object of that class inside a new class. We call this “creating a member object.” Your new class can be made up of any number and type of other objects, in any combination that you need to achieve the functionality desired in your new class. Because you are composing a new class from existing classes, this concept is called [color=red]composition[/color] (if the composition happens dynamically, it’s usually called [color=red]aggregation[/color]). Composition is often referred to as a “has-a” relationship, as in “A car has an engine.”[/b]
thinking in java 4th
chapter one
resuing the implementation
[b]The simplest way to reuse a class is to just use an object of that class directly, but you can also place an object of that class inside a new class. We call this “creating a member object.” Your new class can be made up of any number and type of other objects, in any combination that you need to achieve the functionality desired in your new class. Because you are composing a new class from existing classes, this concept is called [color=red]composition[/color] (if the composition happens dynamically, it’s usually called [color=red]aggregation[/color]). Composition is often referred to as a “has-a” relationship, as in “A car has an engine.”[/b]
本文探讨了在面向对象编程中复用已有类的两种主要方法:直接使用该类的对象和通过组合创建新类。解释了如何利用现有类的功能来构建更复杂的应用程序。
516

被折叠的 条评论
为什么被折叠?



