iOS

iOS Design Patterns

Singleton, Factory, Builder, Observer, Coordinator, Repository, Dependency Injection, SOLID

24 câu hỏi phỏng vấn·
Senior
1

Which pattern guarantees only one instance of a class throughout the application?

Câu trả lời

The Singleton pattern restricts instantiation to a single global instance. In iOS, it enables centralized access to shared resources like configurations or managers. However, Singletons reduce testability by creating hard-to-mock global dependencies.

2

Which pattern abstracts object creation without exposing the exact instantiation logic?

Câu trả lời

The Factory pattern encapsulates object creation in a dedicated method or class. This allows modifying creation logic without affecting client code. In iOS, factory methods simplify managing complex dependencies and facilitate testing through easy substitutions.

3

Which pattern constructs complex objects step-by-step while separating construction from representation?

Câu trả lời

The Builder pattern enables creating objects with many optional parameters without overloading constructors. In iOS, it improves code clarity and maintenance. Unlike Factory that returns immediately, Builder allows progressive and fluid configuration.

4

Which pattern defines a one-to-many dependency where observers are automatically notified of changes?

5

What is the main use of a Factory to create objects with conditional logic?

+21 câu hỏi phỏng vấn

Nắm vững iOS cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí