ABSTRACT FACTORY structure

xiaoxiao2021-03-06  60

Name The Abstract Factory structure intent provides an interface to create a series of associated or interdependent objects without specifying their specific classes. applicability

A system is to be independent of its product creation, combination, and representation. A system is to be configured by one of a plurality of product lines. When you want to emphasize a series of related product objects for union use. When you provide a product class, just want to display their interfaces instead of implementation.

An important role is to change the appearance of the application. Let's take a look at the example of an abstract plant mode in the application layer. Suppose you bought a residential, there is a garden on the roof, and you need to design a garden layout. There is a flower stage on the right side of the garden, and a plant is needed, and the center needs a substrate plant. According to the style, the garden can be designed as elegant, used and lazy. This is changed by the Java example of others.

Pre {Font-Family: "Courier New", Courier, Arial; font-size: 12px;}

. galan {color: # 000000;

. readyword {color: # 993300;

.IDENTIFIER {color: # 000087;

.properties {color: # 000087;

{Color: # 000087;

.linecomment, .bockcomment {color: # 808080;

. String {color: # 0000ff;}

Class Garden

{

Private function garden ()

{

}

Public function getshade (): Plant in Plant / /

{

Return;

}

Public function getcenter (): Plant in Plant //

{

Return;

}

Public function getBorder (): Plant on the edge of Plant //

{

Return;

}

}

// ElegantGarden.as (Elegant)

Class ElegantGarden Extends Garden

{

Public function getshade (): Plant

{

Return New Plant ("Tulip");

}

Public function getcenter (): Plant

{

Return New Plant ("Banyan Tree");

}

Public function getBorder (): Plant

{

Return New Plant ("Islands");

}

}

// PracticalGarden.as (practical)

Class PracticalGarden Extends Garden

{

Public function getshade (): Plant

{

Return New Plant ("Grape");

}

Public function getcenter (): Plant

{

Return New Plant ("Pomegranate");

}

Public function getBorder (): Plant

{

Return New Plant ("Loofa");

}

}

// LasyGarden.as (lazy)

Class LasyGarden Extends Garden

{

Public function getshade (): Plant

{

Return New Plant ("Month");

}

Public function getcenter (): Plant

{

Return New Plant ("tea flower");

}

Public function getBorder (): Plant

{

Return New Plant ("Bamboo");

}

Download Source File This source file has a Gvent Skinner's gform class, you can refer to it when developing Form applications.

转载请注明原文地址:https://www.9cbs.com/read-112673.html

New Post(0)