Design Design Patterns illustrated Java mode face questions

1.1 Java design patterns Introduction

1.1.1 look at a few classic face questions

  • Prototype design pattern questions:
    1) Please use the UML class has a prototype model central role in drawing
    2) copies of the prototype design pattern deep and shallow copy of what it is. And write source code in two ways deep copy (overwriting deep copy clone implemented method, implemented using a deep copy of the sequence)
    3) used in the Spring Framework where the prototype model, the source code is analyzed and
    beans.xml
<bean id="id01" class="com.demo.spring.bean.Monster" scope="prototype" /> 

4) Spring bean created prototype, the prototype is the application mode
5) + Debug source code analysis

  • Seven principles of design patterns: Requirements:
    1) The core idea of the seven design principles
    2) in order to be able to explain the principles of design class diagram
    3) in the actual development project, you use the principle of arrival ocp where
    design patterns commonly used in the seven principles :
    1) single responsibility principle
    2) Interface Segregation principle
    3) dependency inversion principle
    4) Substitution principle Richter
    5) opening and closing principle OCP
    . 6) Demeter
    7) synthesis of multiplexing principles
    Here Insert Picture Description
  • Project finance lending platform: Orders lending platform, there are audit - Post - step grab one and so on, with different operations, will change the order of the state, this project will be used to implement the module status mode, you use the state pattern design, and complete the actual code
    analysis:
    This code is difficult to cope with change, when you add one state, we need to add if / else manually, when you add a function to judge all states. So the code will become more and more bloated, and once the process is not a state, it will happen very serious BUG, difficult to maintain.
    Here Insert Picture Description
    Here Insert Picture Description
  • Interpreter design pattern
    1) Introduction What Interpreter design pattern?
    2) Draw UML class diagram to explain design patterns, analyze what design patterns in each role?
    3) Please describe the Spring framework, the where to use the arrival of an interpreter design pattern, and do source-level analysis
    Here Insert Picture Description
    interpreter mode analysis in source Spring Framework applications
    1) Spring framework SpelExpressionParser on the use of the interpreter mode
    2) Code Analysis + Debug mode + source code analysis shows that the role of
    Here Insert Picture Description
    Here Insert Picture Description
  • Singleton design pattern There are several implementations? Please be implemented in code, respectively, and illustrate the advantages and disadvantages of the various implementations?
    Singleton design pattern, a total of eight kinds of writing, in turn mentioned later
    1) type two starving
    2) type three lazy
    3) double check
    4) internal static type
    5) Enumeration
    Here Insert Picture Description

1.1.2 The importance of design patterns

1) software engineering, design patterns (design pattern) software is ubiquitous (recurring) various design problems, solutions proposed. This term is Erich Gamma et al., Introduced in the 1990s from the architectural design to computer science
2) Building VS shacks
Here Insert Picture Description
3) Take practical work experience, when after a project development, if the customer put forward by the new function, how to do? (Scalability, use of design patterns, software has good scalability)
4) If the project development after the original programmers leave, you take over maintenance of the project how to do? (Maintenance [readability, normative])
5) current first-line IT companies, will ask what design model used in the actual project, to solve the problem of how to use.
6) design patterns in software where? Object-oriented (OO) = "+ function module design pattern algorithm [(result data)] =" Framework to use a variety of design patterns [=] "server cluster architecture []

Guess you like

Origin www.cnblogs.com/haizai/p/12153072.html