Evgenii Legotckoi
Oct. 1, 2018, 2:34 p.m.

Design PatternsStructural Design Patterns - Adapt

шаблоны проектирования, приспособленец, flyweight

Goals

  • Using sharing to effectively use a large number of objects.
  • Motif's GUI strategy to replace heavyweight widgets with lightweight widgets.

Problems

Designing objects down to the lowest levels of system "granularity" provides optimal flexibility, but can be prohibitively expensive …

Read
Evgenii Legotckoi
Sept. 26, 2018, 5:55 p.m.

PythonExample - Object Pool in Python

python, pool, пул, шаблоны проектирования

Example of the design pattern An object pool in the Python programming language.


  1. """
  2. Offer a significant performance boost; it is most effective in
  3. situations where the cost of initializing a class instance is high, the
  4. rate of instantiation of …
Read
Evgenii Legotckoi
Sept. 26, 2018, 5:53 p.m.

JavaExample - Object Pool in Java

Java, пул, шаблоны проектирования

Example of the design pattern An object pool in the Java programming language.


  1. // ObjectPool Class
  2.  
  3. public abstract class ObjectPool<T> {
  4. private long expirationTime;
  5.  
  6. private Hashtable<T, Long> locked, unlocked;
  7.  
  8. public ObjectPool() {
  9. expirationTime = 30000; // 30 seconds
  10. locked =
Read
Evgenii Legotckoi
Sept. 26, 2018, 4:55 p.m.

C++Example - Object Pool in C++

шаблоны проектирования, пул, C++

Example of the design pattern An object pool in the C ++ programming language.


  1. #include <string>
  2. #include <iostream>
  3. #include <list>
  4. class Resource
  5. {
  6. int value;
  7. public:
  8. Resource()
  9. {
  10. value = 0;
  11. }
  12. void reset()
  13. {
  14. value = 0;
  15. }
  16. int
Read
Evgenii Legotckoi
Sept. 26, 2018, 4:01 p.m.

Design PatternsStructural Design Patterns - Decorator

шаблоны проектирования, decorator, декоратор

Goals

  • Add additional features and functionality to the object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
  • Client-specified decoration of the interface of the main object by recursively wrapping it.
  • Wrap the gift, put it in the …
Read
Evgenii Legotckoi
Sept. 25, 2018, 4:16 p.m.

PHPExample - Factory method in PHP

шаблоны проектирования, factory, method, PHP

In the Factory Method Pattern, a factory method defines what functions must be available in the non-abstract or concrete factory. These functions must be able to create objects that are extensions of a specific class. Which exact subclass is created …

Read
Evgenii Legotckoi
Sept. 25, 2018, 4:09 p.m.

DelphiExample - Factory method in Delphi

Delphi, шаблоны проектирования, factory, method

This pattern is useful when you want to encapsulate the construction of a class and isolate knowledge of the concrete class from the client application through an abstract interface.

Один из примеров этого может возникнуть, если у вас есть объектно-ориентированное …

Read
Evgenii Legotckoi
Sept. 25, 2018, 3:46 p.m.

Design PatternsStructural Design Patterns - Composite

шаблоны проектирования, composite, компоновщик

Goals

  • Arrange objects into tree structures to represent entire parts of the hierarchy. The linker allows clients to treat individual objects and compositions of objects in the same way.
  • Recursive composition
  • "Directories contain entries, each of which can be a …
Read
Evgenii Legotckoi
Sept. 24, 2018, 8:43 p.m.

PythonExample - Factory method in Python

шаблоны проектирования, factory, Python, method

An example of a factory method in the Python programming language


  1. """
  2. Define an interface for creating an object, but let subclasses decide
  3. which class to instantiate. Factory Method lets a class defer
  4. instantiation to subclasses.
  5. """
  6.  
  7. import abc
  8.  
  9.  
  10. class
Read
Evgenii Legotckoi
Sept. 24, 2018, 8:34 p.m.

JavaExample - Factory Method in Java

шаблоны проектирования, factory, method, Java, JAVA

In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. This is done …

Read
  • Last comments
  • AK
    April 1, 2025, 11:41 a.m.
    Добрый день. В данный момент работаю над проектом, где необходимо выводить звук из программы в определенное аудиоустройство (колонки, наушники, виртуальный кабель и т.д). Пишу на Qt5.12.12 поско…
  • Evgenii Legotckoi
    March 9, 2025, 9:02 p.m.
    К сожалению, я этого подсказать не могу, поскольку у меня нет необходимости в обходе блокировок и т.д. Поэтому я и не задавался решением этой проблемы. Ну выглядит так, что вам действитель…
  • VP
    March 9, 2025, 4:14 p.m.
    Здравствуйте! Я устанавливал Qt6 из исходников а также Qt Creator по отдельности. Все компоненты, связанные с разработкой для Android, установлены. Кроме одного... Когда пытаюсь скомпилиров…
  • ИМ
    Nov. 22, 2024, 9:51 p.m.
    Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильн…
  • Evgenii Legotckoi
    Oct. 31, 2024, 11:37 p.m.
    Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup