Meaning of Leaky Abstraction?

后端 未结 11 1059
面向向阳花
面向向阳花 2020-12-23 02:33

What does the term \"Leaky Abstraction\" mean? (Please explain with examples. I often have a hard time grokking a mere theory.)

11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 03:16

    Here's an example familiar to .NET developers: ASP.NET's Page class attempts to hide the details of HTTP operations, particularly the management of form data, so that developers don't have to deal with posted values (because it automatically maps form values to server controls).

    But if you wander beyond the most basic usage scenarios the Page abstraction begins to leak and it becomes hard to work with pages unless you understand the class' implementation details.

    One common example is dynamically adding controls to a page - the value of dynamically-added controls won't be mapped for you unless you add them at just the right time: before the underlying engine maps the incoming form values to the appropriate controls. When you have to learn that, the abstraction has leaked.

提交回复
热议问题