K
K
Kolya Vantukh2017-06-05 11:54:45
PHP
Kolya Vantukh, 2017-06-05 11:54:45

Where to put the image upload method?

There is a registration class and a user profile class. And there , and there the same method of loading the image is needed . The question is where is the best place to put this method? Create a separate class that only works with images and then use delegation to load those images ? or how ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D3lphi, 2017-06-05
@vkolya

Each class should only be responsible for one thing. This is indicated by the letter S in the abbreviation SOLID (single responsibility, single responsibility). Therefore, neither the user nor the registration class "needs" to know anything about how images are loaded. This functionality needs to be moved to a separate class (service).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question