Answer the question
In order to leave comments, you need to log in
Book on GUI Programming Techniques
Object-oriented programming patterns are a fairly common topic of discussion among developers. However, in addition to them, there is a set of programming techniques used primarily in the implementation of the GUI. For example, if it is necessary to access the same class in different GUI elements, a ServiceProvider can be used when it is possible to obtain a class object by the class name. For example, in Java it might look like this:
//ServiceProvider.java
public class ServiceProvider {
//Хранит объекты, которые можно получить передав класс
private final HashMap<Class<?>, Object> instances = new HashMap<Class<?>, Object>();
//Возвращает объект класса по переменной типа Class
public <T> T getService(Class<T> classObject){
return (T) instances.get(classObject);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question