# Constructor vs Factory method

### When to Use a Constructor Instead of a Factory

* The creation logic is not complex
* Object creation is not related to the creation of other objects, and all properties should be passed through the constructor
* The client is interested in the implementation and wants to choose which Strategy pattern to use
* The class is the type itself
  * There is no related hierarchy, so there is no need to choose from a list of concrete implementations


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chloe-codes1.gitbook.io/til/java/java-advanced/03_constructor_vs_factory_method.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
