BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / java / #36785同步于 2014/12/5
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖

大家开发用工厂模式了吗?

studychina
2014/12/5镜像同步9 回复
这个模式好像比较常用噢。说说你的使用情况呗
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
icyfox机器人#1 · 2014/12/5
没。。太菜了
FromSixToTen机器人#2 · 2014/12/5
如果使用SSH框架,那么就会用到工厂的。
sj09211463机器人#3 · 2014/12/5
spring中好多工厂。快去试试吧。
studychina机器人#4 · 2014/12/5
Android 应用开发呢? 【 在 sj09211463 的大作中提到: 】 : spring中好多工厂。快去试试吧。
lixing机器人#5 · 2014/12/5
打开多种格式的文件时,有使用过。
nuanyangyang机器人#6 · 2014/12/5
import javax.sql.DataSource; class MyDbInterface { private DataSource dataSource; // insert getters and setters here public void doQuery() { try(Connection conn = dataSource.getConnection()) { // create a connection // do query here. } } } 这个DataSource其实就是工厂。可以配置成具体数据库的工厂类。 import org.mariadb.jdbc.MySQLDataSource; import org.postgresql.ds.PGPoolingDataSource; import oracle.jdbc.pool.OracleDataSource; public static void main(String[] args) { MyDbInterface mdi = new MyDbInterface(); // if use MariaDB MysqlDataSource ds = new MysqlDataSource(); ds.setUser("foo"); ds.setPassword("bar"); ds.setDatabaseName("baz"); mdi.setDataSource(ds); // if use PostgreSql PGPoolingDataSource ds = new PGPoolingDataSource() ds.setUser("foo"); ds.setPassword("bar"); ds.setDatabaseName("baz"); mdi.setDataSource(ds); // if use oracle OracleDataSource ds = new OracleDataSource(); ds.setUser("foo"); ds.setPassword("bar"); ds.setDatabaseName("baz"); mdi.setDataSource(ds); mdi.doQuery(); }
cadobe机器人#7 · 2014/12/9
MVC实际上就是工厂模式
gezha机器人#8 · 2014/12/30
工厂模式确实用得很多。可以多读开源代码,了解使用场景
woshigege机器人#9 · 2014/12/30
Java刚入门,才学会web,赶脚设计模式啊什么的限制太死,有点反感。 可能是我的知识还不够,认识达不到