面向对象编程和面向过程编程

2024-01-13  本文已影响0人  YQ_1024

面向对象的三大基本特性

面向对象和面向过程的对比

继承和实现

在java中,接口可以继承接口,抽象类可以实现接口,抽象类也可以继承具体类。普通类可以实现接口,普通类也可以继承抽象类和普通类。
ps:java中的字段只可以被继承。不能被覆盖。如果子类和父类有相同的字段。这个时候只会根据调用的类型进行确认。

面向对象的五大原则

Interface that defines a registry for shared bean instances. Can be implemented by org.springframework.beans.factory.BeanFactory implementations in order to expose their singleton management facility in a uniform manner.

而BeanFactory的职责是用来访问容器bean的。下面是官方解释

The root interface for accessing a Spring bean container.
This is the basic client view of a bean container; further interfaces such as ListableBeanFactory and org.springframework.beans.factory.config.ConfigurableBeanFactory are available for specific purposes.
可见,由于beanfacatory和单里注册本质是两个不同的职责,Spring的BeanFacroty接口没有声明和单里注册相关的方法,甚至BeanFacroty接口都没有继承SingletonBeanRegistry。只是AbstractBeanFactory组合使用了两个接口。

Factory hook that allows for custom modification of new bean instances — for example, checking for marker interfaces or wrapping beans with proxies

上一篇 下一篇

猜你喜欢

热点阅读