The goal of factory objects / benefits of using a single instance to return a type

What is the advantage of a static factory class as opposed to using an instance of the same object to return this object?

For example, from the N2 CMS take a look at this code:

News News = Factory.Persister.Get (itemID);

// A news variable can set news-related properties.

Factory.Persister.Save (news);

Factory is static, and I know that there are / are factory objects, but I don't see the benefits of a static factory (which probably takes responsibility for setting up different types), as opposed to using a Newspage object for this.

thank

+3
source share
4

factory :

  • , new, , . factory , , .

  • ; . , , . , .

  • , , , . , . , , , .

  • , - new.

  • , . factory .

+3

, , . A factory , , . , , Newpages Google, NNTP? , , factory?

, , factory . , ? , . , , - main().

0

, factory factory . , , . - factory, . , , , .

0

, factory , , , , .

, , , , .

, , , , , factory, / .

0

Source: https://habr.com/ru/post/1730934/


All Articles