Why does my App break when I upgrade to the new version of the Framework?
This thread is a general purpose Q&A on the topic of code breaking when a newer version of [GUI Framework] is used, and it is illustrated by a particular real-world scenario...
Example Question: "The following code was provided to us by [GUI Framework] team for auto complete in [widget] a long time ago when we were working on the [foo project] with the [GUI Framework] team. In there, you can see there are quite a few references to the private attributes. ... ... ... functionality is not working as before. Can you please provide pointers to resolve this."
Example Answer: "... A quick look at the code in the attachment makes me believe that it was a hack to replace the internal workings of the list filtering…you SHOULD have been provided an above-board way to subclass/decorate/configure [widget] (instead of that quick and dirty method)."
There are general software engineering principles of "encapsulation" and "information hiding" which come from the Modular Programming era in the mid-1970s (just before Object Oriented expanded upon it). To combat "brittleness" of a system, Components hide their (private) implementation details inside a (public) interface so that changes in one part of a system don't break other far-flung parts of that system (aka "loose coupling"). The warranty provided by the component is that as long as you use it as designed, and via the stable interface, the insides are free to be changed/fixed/enhanced without affecting you.
So, a component (where "widget" is just another word for component) is not just a collection of functionality like the collection of bits and wires below...
...but rather a collection of functionality that has had a stable interface published on the outside of a "black box" thus hiding the implementation inside that box, as shown below...
This warranty is voided however if you break into the box and connect to its private implementation (aka "hacking") as seen below...
In [GUI Framework], there are two major indicators as to whether a property or method of a widget is public interface versus private implementation:
- If the name of the property or method starts with an underscore ("_") then it is definitely private (or at best "protected")
- If the property or method is documented in the [GUI Framework] JsDoc API Docs then it is definitely public.





0 comments:
Post a Comment