Design Mode 04 _ Abstract Factory mode, design mode 04 Abstract Factory
This article is in the study of the summary, welcome to reprint but please note the Source: http://blog.csdn.net/pistolove/article/details/46440915
Abstract Factory mode is the object creation mode, which is further promoted by the factory method mode.The biggest difference between the
Syntax differences:Abstraction: Abstract Class--there is a construction method; Interface (interface) is not;There are common member variables; interface not;There is a non-abstract common method; interface is not;The access type of the abstract method is public,protected; The abstract method of interface must be publi
Abstract interface polymorphism, abstract Polymorphism
Content: abstract, interface, and Polymorphism
######################################## ######################################## #########################
1. Abstract
The method is abstract, so the class must be abstract
1. Abstract classes and abstract functions1) The definition of an abstract class, plus the keyword abstract before the class, such as:Abstract class test{}2) The definition of an abstract function, with the keyword abstract before
First, virtual method (virtual method)The virtual keyword is used to decorate a method in a base class. There are two things you can do with virtual:Scenario 1: The virtual method is defined in the base class, but the virtual method is not overridden in the derived class. In a call to a derived class instance, the virtual method uses the method defined by the base class.Scenario 2: The virtual method is defined in the base class and then overridden in a derived class by using override. In a call
The examples in this article describe the PHP abstract methods and abstract classes. Share to everyone for your reference, specific as follows:
What is an abstract method?
A method that is defined within a class without a method is an abstract method that does not have curly braces and the contents of the method decl
Because both C + + and Java are object-oriented programming languages, their polymorphism is achieved by virtual functions and abstract functions, respectively.The virtual function of C + + can be overridden in subclasses, and the invocation is judged by the actual object, not by the pointer type (the invocation of the normal function is based on the current pointer type). A pure virtual function is a function that is defined only in the parent functi
I. Static)
1. Class: static classes cannot be instantiated. They can only be accessed through classes, can be inherited, and can only contain static members.
2. Members: static members can be declared in static classes or non-static classes.
Ii. Virtual members)
A virtual member can be overwritten in a derived class and cannot be set to private. After rewriting, in a multi-state application, calling this member always executes the rewritten code in the derived class.
Different from hiding
Java basics: abstract classes and interfaces, and Basic java Abstract Interfaces
Reprinted with the source: jiq •'s technical Blog
I. Introduction
Based on the following two principles in the five object-oriented principles, we should consider using interfaces and abstract classes:
Lee's replacement principle:Subclass can replace the parent class by implementin
Abstract classes cannot override abstract methods of abstract parent classes when they inherit another abstract class。 This usage can be understood as an extension of the abstract class.
The following example shows that an abstract
The concept of abstract classes:A class that contains an abstract method is an abstract classAbstract method:A method that is declared without being implemented is an abstract method that must be declared with the abstract keywordIt is important to note that1. When an
Product catalog creation-Abstract Factory model-Abstract FactoryThe factory method model solves the problem of excessive factory responsibilities in the simple factory model by introducing the factory level structure. However, in the factory method model, each factory only produces one type of products, there may be a large number of factory classes in the system, which will inevitably increase the overhead
Factory method mode And abstract factory mode, mode and Abstract Factory
I. Factory method model
The defect of the simple factory mode is that the creation of classes is too dependent on the factory. Once the program needs to be extended, the code of the factory class must be modified.
This violates the backpack principle.
The factory method mode has been improved to address this problem.
Public interface
In the OOP language, a class can have one or more subclasses, and each class has only one public method to access its interface as external code. Abstract methods are introduced to facilitate inheritance.When a class is represented by a method, it has no method body, that is, no curly braces, and the direct semicolon ends, like this method we call abstract methods, which must be defined using the keyword ab
Abstract classes must have abstract methods, but also can have non-abstract methods, can have a concrete implementation of the method, inheriting the subclass of the abstract parent class,If the subclass does not implement an abstract method in the
Build your own PHP Framework-abstract framework content, php Framework-abstract. Build your own PHP Framework-abstract framework content, php Framework-abstract in the previous blog, we set up the simplest framework, from a single entry to publicindex. php enters, parses and constructs its own PHP Framework-
Php abstract class usage instance analysis, php abstract instance analysis. Php abstract class usage example analysis, php abstract instance analysis this article describes the php abstract class usage. Share it with you for your reference. The details are as follows: php **
Section 10-abstract methods and abstract classesObject-oriented Programs are built through the hierarchical structure of classes. in a single inheritance language such as PHP, class inheritance is tree-like. A root class has one or more sub-classes, and then inherits one or more sub-classes from each sub-class. of course, there may be multiple root classes to implement different functions. in a well-designe
/* + --------------------------------------------------------------------------------- + | = This article is Haohappy read
> | = Notes in the middle Classes and Objects chapter | = translation + personal experience | = Do not repost to avoid unnecessary troubles, thank you | = welcome to criticize and correct, hope to make progress together with all PHP enthusiasts! + ----------------------------------------------------------------------------- + */Section 10 --
I. Abstract classes and abstract methods (B inheritance abstract Class A)Abstract classes: Abstract methods must be abstractAbstract method: The method name has an abstract adornment, and the method has no method body, that is {},
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.