Starting March 9, our app group began organizing technical training courses designed to improve the team's development skills. Each person in the group studies a technique every week and then explains it to other members. I believe that the words are right, only can speak out so that others can understand the things that really belong to their own, I hope that each of us can get their own skills.
Let me give you an example. When we finish our work, we will take a knife to chop wood.
Chopping wood quickly and often depends on several factors:
1, our strength is good enough; our firewood is virtual, this factor can not be considered, as long as the health is good.
2, whether we are diligent enough, this depends on their own factors, completely can control, I think we are diligent.
3, our knives are sharp enough, we can work on only one factor, sharpening.
In the development, learning is equivalent to sharpening, can play a multiplier effect; The knife is not fast, cut the opposite, less than half. This is why some developers work overtime and do nothing.
Ax
------------------------------
Software developers are divided into two types: programmer, coder. The latter becomes the coder, mainly responsible for writing code according to business logic, the state we are currently in, the former becomes a programmer, also known as the program designer, the focus is on design.
Every technology God is not busy coding every day, he must be good at solving problems, and from the technical framework to avoid problems, such as the encapsulation of anomalies and logs, unified by specialized components to deal with.
It goes without saying that the work he does is designed. And the design pattern is the tool that the great God uses skillfully.
Interface, English is called interface, in software engineering, the interface refers to the method or function for others to call. From here, we can realize the original intention of the Java language Designer, which is the abstraction of the behavior.
1, we all know, Java interface defined in the member variables are automatically finalstatic, why. What good is this? Why can't I define a variable? Here is a brief talk for you.
An interface is a uniform "protocol", and the attributes in an interface are members of the Protocol. They are public, static, and final constants. Equivalent to a global constant. An abstract class is a class that is not "full" and is equivalent to an interface and a middle layer of a concrete class. That satisfies the abstraction of the interface and satisfies the concrete implementation.
If an interface can define a variable, but the method in the interface is abstract, the property cannot be modified by behavior in the interface. Some people will say, no relationship, you can modify the properties of an interface by implementing the behavior of the interface's objects. This is of course not a problem, but consider such a situation. If interface A has a static variable A that has public access permissions. According to Java semantics, we can change the value of variable A in the interface without accessing the variable A through the object that implements the interface, by A.A =xxx. As can be done in an abstract class, all objects that implement interface A will automatically have the value of the changed a, which means that a place has changed a, and the value of a in all these objects has changed. What is the difference between this and the abstract class, how to embody the higher level of abstraction of the interface, how to embody the unified protocol provided by the interface, that also interface this abstraction to do what. Therefore, the interface can not appear in the variable, if there are variables, and the interface provided by the unified abstraction of the idea is inconsistent. Therefore, the attribute in the interface must be constant, can only be read and cannot be changed, so as to provide a uniform property for the object that implements the interface.
In layman's words, what you think is to change is put in your own implementation, not in the interface, interface is just a kind of things of the properties and behavior of a higher level of abstraction. For the modification to close, the extension (different implementation implements) Open, interface is a manifestation of the principle of closure.
2. The difference between an interface and an abstract class
Abstract class: Is an abstraction that has a logical relationship to a set of properties and methods. is a
Interfaces: Logically unrelated abstractions that have the same properties and methods on a set. Like a
Illustrate design patterns:
On the construction site, workers are building houses, but you can't see the people making bricks. In the car factory, you see the people who assemble the cars, not the people who make the parts. Or you go to buy a car with a complete whole, not buy a lot of parts.
In software development, it is divided into Project manager, UI, program architect, program code, test engineer and so on.
1. Opening and closing principle
Ocp:openforextension,closed formodification)
Core idea: An object to the extension development, to modify the close.
2. Single duty principle: Low coupling, high cohesion
3, the Richter replacement principle: Where the parent class appears, you can replace it with a subclass.
4, the Dependency Injection principle: the interface becomes.
5, interface Separation principle: The interface should not provide too much behavior.
6, Dimitri Principle: an object as far as possible to other objects less understanding, low coupling. such as the order item in the order.
Simple Factory mode
The roles contained in the pattern and their responsibilities
Factory ( Creator ) Role
The core of the simple factory pattern, which is responsible for implementing the internal logic of creating all instances. The method of creating a product class for a factory class can be called directly by the outside world to create the desired product object.
Abstract Products ( Product ) Role
The parent class of all objects created by the simple factory pattern, which is responsible for describing the common interfaces common to all instances.
Specific Products ( Concrete Product ) Role
is the creation target of the simple factory pattern, and all created objects are instances of a specific class that acts as the role.
Factory method Mode
definition: defines an interface that is used to create an object, so that subclasses decide which class to instantiate, and the factory method defers the instantiation of a class to its subclasses.
Compare simple Factory mode and factory method mode
The factory method model is designed to overcome the shortcomings of the simple factory model (mainly the OCP principle).
Complexity of structure
Complexity of code
Client Programming Difficulty
The difficulty of management