Good design for calling private methods inside the constructor?

Let's say I have the following class:

public class FormContainer {

    @EJB
    private ExternalDao externalDao; // uses dependency Injection

    private final OrderForm orderForm;

    private final List<OrderFormContent> formContents;

    public FormContainer(OrderForm orderForm) {
        this.orderForm = orderForm
        initializeOrderForm();
    }

    private void initializeOrderForm() {
        formContents = externalDao.getFormContents(orderForm);
        // similar for any other properties
    }

    // getters & setters
}

I use this class to be able to hold all the fields that I need to access through the application. I'm still involved in good design and bad design practice, so I wonder if this bad design will initialize the orderForm properties.

If so, how can this be improved?

+4
source share
2 answers

Everything is fine.

this "escape", , - / "" ( ).

, , , .

+3

, , , . , " ", , , , .

, , Inititialize, , .

+1

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


All Articles