Let's take a thread example to illustrate how the abstract factory works. we usually send and receive emails, so we can create a mail engine thread. definition: Abstract Factory mode is a creation mode. The above metaphor shows that the abstract factory is the thing that produces the same series of products, because these series of products are related. If they are mixed, problems may occur, therefore, it is uniformly created in the abstract factory. To add a new product series, you can add a factory subclass and a product subclass.
Let's look at a class chart.
In the figure, we can see that when the customer needs to obtain a series of products, they can directly create products using the corresponding factory subclass.
We have designed a mail sending thread instance:
First, create an interface ISaaSProcess. cs:
Html # viewSource "commandName =" viewSource "highlighterId =" highlighter_548602 "> view sourceprint?
/// Call the interface Asynchronously |
public interface ISaaSProcess |
List< string > GetResult(); |
Then create a factory base class saasproccorner. cs:
View sourceprint?
public abstract class SaaSProcessBase : ISaaSProcess |
/// Record the Log Content |