# .NET デザインパターン (.NET) > Singleton、Factory、Builder、Strategy、Decorator、Repository、Unit of Work、SOLID - 24 面接問題 - Senior - [面接問題: .NET](https://sharpskill.dev/ja/technologies/dotnet/interview-questions.md) ## 1. Dependency Injection を使用したモダンな .NET において、Singleton パターンの主な問題は何ですか? **回答** 従来の Singleton パターン(静的インスタンス)は、強い結合を生み出しテストを困難にするため、Dependency Injection と相性が悪くなります。モダンな .NET では、DI 経由でサービスの 'Singleton' ライフタイム(services.AddSingleton)を使用するほうが望ましく、単一インスタンスの保証を維持しつつ、インジェクション、モック化、テスト容易性を実現できます。静的な Singleton は DI コンテナを迂回し、隠れた依存関係を生み出します。 ## 2. Factory Method パターンにおいて、.NET での Factory Method と Abstract Factory の違いは何ですか? **回答** Factory Method は単一の型のオブジェクト(例: CreateLogger)を生成する仮想メソッドを定義し、サブクラスがどの具象クラスをインスタンス化するかを決定できるようにします。Abstract Factory は関連するオブジェクト群(例: CreateButton や CreateTextBox を持つ IUIFactory)を生成するためのインターフェースを定義し、一貫した複数の製品をまとめて生成できるようにします。Factory Method はポリモーフィズムによる単一製品に焦点を当て、Abstract Factory は同一ファミリーの複数製品を扱います。 ## 3. 多くのオプションパラメーターを持つ複雑なオブジェクトを生成する際、.NET における Builder パターンの主な利点は何ですか? **回答** Builder パターンは、オブジェクトを段階的に構築するためのフルーエントなインターフェースを提供することで、テレスコーピングコンストラクター(異なるパラメーターの組み合わせを持つ複数のオーバーロード)を回避します。10 個以上のパラメーターを持つコンストラクターとは異なり、オプションパラメーターを持つ複雑なオブジェクトを読みやすく保守しやすい形で生成できます。モダンな C# では、単純なケースでは init プロパティや record が Builder を置き換えられますが、複雑な検証や多段階の構築には Builder が依然として有用です。 ## さらに21問利用可能 - SOLID における Single Responsibility Principle(SRP)とは何であり、.NET でどのように適用しますか? - SOLID における Open/Closed 原則 (OCP) とは何ですか。また、.NET で interface を使ってどのように実装しますか。 無料で登録: https://sharpskill.dev/ja/login ## その他の.NET面接トピック - [C# の基礎](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/csharp-basics.md): 25問, Junior - [LINQ & Delegates](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/csharp-linq-delegates.md): 20問, Junior - [C#言語の基礎](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/csharp-language-essentials.md): 15問, Junior - [ASP.NET Core の基礎](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/aspnet-core-fundamentals.md): 18問, Junior - [ASP.NET Core のリクエストライフサイクル](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/aspnet-core-request-lifecycle.md): 20問, Junior - [Configuration & Settings](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/configuration-settings.md): 20問, Junior - [アプリケーションのライフサイクル](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/application-lifecycle.md): 20問, Junior - [Dependency Injection](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/dependency-injection.md): 24問, Mid-Level - [Entity Framework Core](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/entity-framework-core.md): 25問, Mid-Level - [Minimal APIs](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/minimal-apis.md): 18問, Mid-Level - [Web API開発](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/web-api-development.md): 22問, Mid-Level - [ASP.NET Core における Async](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/async-aspnet-core.md): 20問, Mid-Level - [Authentication & Authorization](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/authentication-authorization.md): 18問, Mid-Level - [HttpClient & ネットワーキング](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/httpclient-networking.md): 20問, Mid-Level - [JSONシリアライズ](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/json-serialization.md): 20問, Mid-Level - [Entity Framework Core 応用](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/ef-core-advanced.md): 25問, Mid-Level - [C# の高度な機能](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/csharp-advanced-features.md): 20問, Mid-Level - [Clean Architecture](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/clean-architecture.md): 20問, Mid-Level - [Logging, Monitoring & Observability](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/logging-monitoring.md): 22問, Mid-Level - [ユニットテストとxUnit](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/unit-testing-xunit.md): 20問, Mid-Level - [統合テスト](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/integration-testing.md): 18問, Mid-Level - [Docker & Containerization](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/docker-containerization.md): 16問, Mid-Level - [NuGet パッケージ管理](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/nuget-package-management.md): 16問, Mid-Level - [Memory Management & GC](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/memory-management-gc.md): 22問, Senior - [リアクティブプログラミング](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/reactive-programming.md): 24問, Senior - [Async/await とパターン](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/async-await-patterns.md): 26問, Senior - [パフォーマンス最適化](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/performance-optimization.md): 22問, Senior - [セキュリティとベストプラクティス](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/security-best-practices.md): 24問, Senior - [SignalR とリアルタイム](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/signalr-realtime.md): 22問, Senior - [マイクロサービスアーキテクチャ](https://sharpskill.dev/ja/technologies/dotnet/interview-questions/microservices-architecture.md): 25問, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ja/technologies/dotnet/interview-questions/dotnet-design-patterns