F
F
foonfyrick2021-03-13 17:58:44
Java
foonfyrick, 2021-03-13 17:58:44

What is a general purpose code and a special purpose code?

What is a general purpose code and a special purpose code?
Please with examples.

I understand it this way:
the code that resizes the button is a special purpose, and the extension functions for fragments, for example, are general purpose code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2021-03-13
@foonfyrick

foonfyrick ,

timecode 8:51
https://www.youtube.com/watch?v=SZLdme0zvV4

I understood.
To begin with, the video touches on aspects of Clean Code. You can read Robert Martin's book - Clean Code or, for example, take a short course on refactoring - https://refactoring.guru/refactoring/course
As for your question, first of all, we are talking about SOLID principles.
S - single responsibility principle (principle of single responsibility). Those. one class must have one purpose. For example, creating an Employee class that cooks and serves and washes dishes , etc. not entirely correct. But you can create an Employee class and extend it with classes like Cook, Waiter, and Cleaner, each of which will cook, serve food and wash dishes respectively.
Also, what he said in the video can be correlated with the ISP (interface segregation principle). The principle of separation of interfaces. For example, suppose you have an MFP interface that has print() , scan() , and fax() methods . If you have a class for an MFP that implements this interface, then everything is OK, since this device has all the functions. Another thing is that if a certain Printer class implements the MFP interface, but at the same time it can implement the print () method, it turns out that it cannot implement the other 2 methods, but it must. Accordingly, the ISP principle recommends dividing the common interface into several parts.
Also, for example, the pojo class must not also be a "util" class or a service class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question