tgoop.com/emacsway_log/1407
Create:
Last Update:
Last Update:
Обратимся к первоисточнику термина "сокрытие информации" - к статье "On the Criteria to Be Used in Decomposing Systems Into Modules." by David Parnas:
💬 Information-hiding objects can be created in any language; my first experiments used primitive versions of FORTRAN.
Это противоречит англоязычной версии статьи Википедии о том, что сокрытие информации является свойством ЯП.
💬 When it is applied properly it is usually successful. Abstractions such as Unix pipes, postscript or X-win-dows achieve the goal of allowing several implementations of the same interface. However, although the principle was published 30 years ago, today’s software is full of places where information is not hidden, interfaces are complex, and changes are unreasonably difficult.
💬 While the basic idea is to hide information that is likely to change, one can often profit by hiding other information as well because it allows the re-use of algorithms or the use of more efficient algorithms.
Здесь мы видим цель сокрытия информации - упростить изменение программы путем управления Coupling, т.е. относится к области конструкции с точки зрения дихотомии функции и конструкции.
Инкапсуляция же отделяет конструкцию от функции. Она защищает интерфейс, который экспонирует поведение, т.е. функцию.
Мы разбиваем систему на компоненты, чтобы управлять сложностью, и на модули - чтобы управлять измением системы.
💬 The terms "module" and "component" are often used interchangeably, which causes confusion. As I mentioned earlier, any system is composed of components. Therefore, a module is a component. However, not every component is a module. To design a flexible system it’s not enough to decompose a system into an arbitrary set of components. Instead, a modular design should enable you to alter the system by combining, reconfiguring, or replacing its components — its modules.
-- "Balancing Coupling in Software Design: Universal design principles for architecting modular software systems" by Vlad Khononov
В качестве примера модуля Vlad приводит кубик конструктора Lego.
О том, что всякий модуль есть компонент, можно подискутировать по поводу примера с ножницами, но выделим главное: модуль - это о конструкции, компонет - о функции.
Таким образом, отличие между инкапсуляцией и сокрытием информации такое же, как между DIP и DI - второе является способом достижения первого.
💬 Encapsulation is most often achieved through information hiding (not just data hiding).
-- "Object-Oriented Analysis and Design with Applications" 3rd edition by Grady Booch, Robert A. Maksimchuk, Michael W. Engle, Bobbi J. Young Ph.D., Jim Conallen, Kelli A. Houston
💬 InformationHiding should inform the way you encapsulate things
-- https://wiki.c2.com/?EncapsulationIsNotInformationHiding
В контексте управления существенной сложностью имеет значение именно инкапсуляция, поскольку она обеспечивает целостность инвариантов доменных моделей (модель - есть абстракция). Не важно, насколько быстро можно изменить программу, которая делает не то, что нужно.
💬 Encapsulation provides explicit barriers among different abstractions and thus leads to a clear separation of concerns.
-- "Object-Oriented Analysis and Design with Applications" 3rd edition by Grady Booch, Robert A. Maksimchuk, Michael W. Engle, Bobbi J. Young Ph.D., Jim Conallen, Kelli A. Houston
Определение encapsulation от автора OO-парадигмы (не путать с автором термина OOP):
💬 Encapsulation means that access to the implementation part of a module is not possible from outside the module, i.e. the implementation of a module is hidden. This means that the usage of a module cannot depend upon internal details of its implementation, and thus it is possible to change the implementation of a module without affecting its usage.
-- "Object-Oriented Programming in the BETA Programming Language" by Ole Lehrmann Madsen, Birger Møller-Pedersen, Kristen Nygaard
BY emacsway-log: Software Design, Clean Architecture, DDD, Microservice Architecture, Distributed Systems, XP, Agile, etc.
Share with your friend now:
tgoop.com/emacsway_log/1407