Pergunta

When i started to learn and spent 5 day learning nTier Architecture. My Boss is insisting me to learn Factory Pattern.

So some question arises in my mind..

  1. Can we apply nTier in Factory Pattern.

  2. what is benefit of Factory Pattern.

  3. What to choose between Factory Pattern and ntier Pattern

By the way i am c# coder in DOTNET

Foi útil?

Solução

'N-tier' and 'factory' are not comparable because they apply to different levels of detail. 'N-Tier' is a high-level concept that divides your system into very coarse components: client, application server, database. 'Factory' is a low-level pattern used to structure classes within a component - that a class or method responsible only for creating other classes can be beneficial in some cases. You should not take a single pattern like 'factory' and try to apply it - you should understand a range of patterns and learn when each is useful, because there are pros and cons to every pattern. The classic reference is http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612 - now 20 years old but still worth reading as a starting point.

Outras dicas

N-tier is a physical deployment architecture where your code could be following Architecture patterns such as Layering. Factory is a Design pattern.

You can deploy your application to distributed environments across physical tiers while still using the factory pattern for some logic. For example, if you are supporting multiple RDBMS, you can use Factories to get you the objects you want i.e. DatabaseFactory.Create("Sql") or DatabaseFactory.Create("Oracle");

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top