OCP

设计模式---设计原则(OCP,SRP...)

╄→尐↘猪︶ㄣ 提交于 2019-11-27 04:28:22
1、顺口溜: 开里和依单迪 合成聚合复用 面向对象中的五大设计原则: solid: srp ocp lod isp dip srp: Single responsibility principle ocp: Open Closed Principle lod: Law of Demeter isp: Interface-Segregation Principle dip: Dependence Inversion Principle 2、开闭原则(OCP): 开放封闭原则(OCP,Open Closed Principle)是所有面向对象原则的核心。软件设计本身所追求的目标就是封装变化、降低耦合,而开放封闭原则正是对这一目标的最直接体现。 关于开放封闭原则,其核心的思想是: 软件实体应该是可扩展,而不可修改的。也就是说,对扩展是开放的,而对修改是封闭的。 因此,开放封闭原则主要体现在两个方面: 对扩展开放,意味着有新的需求或变化时,可以对现有代码进行扩展,以适应新的情况。 对修改封闭,意味着类一旦设计完成,就可以独立完成其工作,而不要对类进行任何修改。 3、里氏替换原则(LSP): 父类可以由子类替换 里氏替换原则(Liskov Substitution Principle LSP)面向对象设计的基本原则之一。 里氏替换原则中说,任何基类可以出现的地方,子类一定可以出现。

【2019年8月】OCP 071认证考试最新版本的考试原题-第32题

我们两清 提交于 2019-11-25 21:57:56
choose three Examine this SQL statement: SELECT cust id, cus last_name "Last Name" FROM customers WHERE country_id = 10 UNION SELECT cust_id CUST_NO, cust_last_name FROM customers WHERE country_id = 30 Identify three ORDER BY clauses, any one of which can complete the query successfully. A) ORDERBY 2, 1 B) ORDER BY "CUST_NO" C) ORDER BY 2,cust_id D) ORDER BY CUST_NO E) ORDER BY "Last Name" Answer:ACE (解析:此题的解析跟下面的解析一样,答案就是按照解析的总结规律找出来的。) 071-140 题目: SELECT department_id "DEPT_ID", department_name, 'b' FROM departments WHERE department_id=90 UNION SELECT department_id, department_name DEPT_NAME

【2019年8月版】OCP 071认证考试原题-第36题

拟墨画扇 提交于 2019-11-25 21:10:01
Choose three Which three statements are true about sequences in a single instance Orade database? A) A sequence's unallocated cached values are lost if the instance shuts down. B) Two or more tables cannot have keys generated from the same sequence. C) A sequence number that was allocated can be rolled back if a transaction fails. D) A sequence can issue duplicate values. E) Sequences can always have gaps. F) A sequence can only be dropped by a DBA. Answer::ADE (解析:虚拟可以一下子产生一组的数字缓存在内存中,但是实例关闭,没有用到的数字也将丢失;序列可以产生重复的值在定义的时候用 cycle 关键字,步长如果不是定义为 1,则产生的数字就不是连续的。) 来源: oschina 链接: https://my.oschina

【2019年8月版】OCP 071认证考试原题-第33题

≡放荡痞女 提交于 2019-11-25 20:21:46
Choose three. Which three statements are true about a self join? A) It must be an inner join. B) It can be an outer join. C) The ON clause must be used. D) It must be an equijoin. E) The query must use twodifferent aliases for the table. F) The ON clause can be used. Answer::BCD (解析:左连接其实就是左外连接,是不同的称呼而已,其结果都是一样的,ANSI 语法有左连接的语法,而 oracle 语法中用(+)来表示。) select emp.empno,emp.deptno,dept.deptno,dept.dname from emp left join dept on emp.deptno=dept.deptno; select emp.empno,emp.deptno,dept.deptno,dept.dname from emp left outer join dept on emp.deptno=dept.deptno; select emp.empno,emp.deptno,dept.deptno

【2019年8月版】OCP 071认证考试原题-第34题

梦想的初衷 提交于 2019-11-25 20:21:43
Choose two. Which two statements are true about the results of using the INTERSECT operator in compound queres? A) Reversing the order of the intersected tables can sometimes affect the output. B) Column names in each SELECT in the compound query can be dfferent. C) INTERSECT returns rows common to both sides of the compound query. D) The number of columns in each SELECT in the compound query can be dfferent. E) INTERSECT ignores NULLs Answer::BC (解析:intersect 会以第一个查询的第一个列的值进行排序输出,由于求的是交集,所以表的查询顺序可以不分先后;列的名字可以不一样,但是数据类型必须匹配。) 来源: 51CTO 作者: cto_5359 链接: https://blog.51cto.com/13854012/2451746