|
1 | 1 | --- |
2 | 2 | myst: |
3 | 3 | html_meta: |
4 | | - "description": "Understanding deprecation in Plone - rationales, philosophy, and use cases." |
5 | | - "property=og:description": "Understanding deprecation in Plone - rationales, philosophy, and use cases." |
| 4 | + "description": "Understanding deprecation in Plone - rationale, philosophy, and use cases" |
| 5 | + "property=og:description": "Understanding deprecation in Plone - rationale, philosophy, and use cases" |
6 | 6 | "property=og:title": "Deprecation" |
7 | | - "keywords": "deprecation, Plone, Python, philosophy" |
| 7 | + "keywords": "deprecation, Plone, Python, Node.js, React, philosophy, rationale, use cases" |
8 | 8 | --- |
9 | 9 |
|
10 | 10 | (conceptual-deprecation-label)= |
11 | 11 |
|
12 | 12 | # Deprecation |
13 | 13 |
|
14 | | -This chapter describes rationales and philosophy of deprecations in Plone, Zope, and Python. |
15 | | -It is meant as a guide on how to think about deprecations in Plone core packages. |
| 14 | +This chapter describes the rationale and philosophy of deprecations in Plone. |
| 15 | +It is meant as a guide for how to think about deprecations in Plone core packages. |
16 | 16 |
|
17 | 17 | ```{seealso} |
18 | 18 | For implementation details and code examples, see {doc}`/developer-guide/deprecation`. |
19 | 19 | ``` |
20 | 20 |
|
| 21 | +(why-deprecation-label)= |
| 22 | + |
21 | 23 |
|
22 | 24 | ## Why deprecation |
23 | 25 |
|
24 | | -At some point we: |
| 26 | +Developers may need to get rid of old code, unify to a consistent API style, fix typos in names, move code or templates around, resolve technical debt, address security issues, or adapt to changes in external dependencies. |
25 | 27 |
|
26 | | -- need to get rid of old code, |
27 | | -- want to unify API style (consistent API), |
28 | | -- fix typos in namings, |
29 | | -- move code or templates around (inside package or to another package). |
| 28 | +When refactoring code, it's often necessary to move modules, functions, classes, and methods. |
| 29 | +It's critical not to break third party code imports from the old place. |
| 30 | +It's also important that usage of old functions or methods must work for a while to allow developers to migrate or update their code. |
30 | 31 |
|
31 | | -While refactoring code, moving modules, functions, classes and methods is often needed. |
32 | | -To not break third party code imports from the old place or usage of old functions/ methods must work for while. |
33 | 32 | Deprecated methods are usually removed with the next major release of Plone. |
| 33 | +Plone follows the [semantic versioning guideline](https://semver.org). |
34 | 34 |
|
35 | | -Following the [semantic versioning guideline](https://semver.org) is recommended. |
36 | 35 |
|
| 36 | +## Help programmers without annoyance |
37 | 37 |
|
38 | | -## Help programmers, no annoyance |
| 38 | +Developers should use code deprecations to support the consumers of the code, that is, their fellow Plone developers. |
| 39 | +From the consumer's point of view, Plone core code is an API. |
| 40 | +Any change may annoy them, but they feel better when deprecation warnings tell them how to adapt their code to the changes. |
39 | 41 |
|
40 | | -The developers should use code deprecations to support the consumers of the code. |
41 | | -From their point of view, Plone core code is an API to them. |
42 | | -Any change is annoying to them anyway, but they feel better if deprecation warnings are telling them what to do. |
| 42 | +Deprecations must always log at the level of warning. |
43 | 43 |
|
44 | | -Deprecations must always log at level *warning* and have to answers the question: |
| 44 | +Deprecations should always answer the following questions. |
45 | 45 |
|
46 | | -**"Why is the code gone from the old place? What to do instead?"** |
| 46 | +- Why is the code gone from the old place? |
| 47 | +- What to do instead? |
47 | 48 |
|
48 | | -A short message is enough., i.e.: |
| 49 | +A short message is enough, such as the following examples. |
49 | 50 |
|
50 | | -- "Replaced by new API xyz, found at abc.cde"., |
51 | | -- "Moved to xyz, because of abc.", |
52 | | -- "Name had a typo, new name is "xyz". |
| 51 | +- "Replaced by new API `xyz`, found at `abc.cde`". |
| 52 | +- "Moved to `xyz`, because of `abc`". |
| 53 | +- "Name had a typo, new name is `xyz`". |
53 | 54 |
|
54 | | -All logging has to be done once, i.e. on first usage or first import. |
| 55 | +All logging must be done only once, in other words, on the first usage or import. |
55 | 56 | It must not flood the logs. |
56 | 57 |
|
57 | 58 |
|
58 | 59 | ## Use cases |
59 | 60 |
|
60 | | -Renaming |
61 | | - |
62 | | -: We may want to rename classes, methods, functions or global or class variables in order to get a more consistent API or because of a typo, etc. |
63 | | - We never just rename, we always provide a deprecated version logging a verbose deprecation warning with information where to |
64 | | - import from in future. |
65 | | - |
66 | | -Moving a module, class, function, etc to another place |
| 61 | +The following use cases describe when to deprecate. |
67 | 62 |
|
68 | | -: For some reason, i.e. merging packages, consistent API or resolving cirular import problems, we need to move code around. |
69 | | - When imported from the old place it logs a verbose deprecation warning with information where to import from in future. |
| 63 | +Rename |
| 64 | +: Developers may want to rename classes, methods, functions, or global or class variables to get a more consistent API or because of a typo. |
| 65 | + Never just rename. |
| 66 | + Always provide a deprecated version that logs a verbose deprecation warning with information for where to import from in the future. |
70 | 67 |
|
71 | | -Deprecation of a whole package |
| 68 | +Move objects |
| 69 | +: For reasons described in {ref}`why-deprecation-label`, developers may need to move code around. |
| 70 | + When imported from the old place, it logs a verbose deprecation warning with information of where to import from in the future. |
72 | 71 |
|
73 | | -: A whole [package](https://docs.python.org/3/tutorial/modules.html#packages) |
| 72 | +Deprecation of a whole Python or npm package |
| 73 | +: A whole {ref}`Python package <python:tut-packages>` or [npm package](https://www.npmjs.com/) may be moved to a new location. |
74 | 74 |
|
75 | | - - all imports still working, logging deprecation warnings on first import |
76 | | - - ZCML still exists, but is empty (or includes the zcml from the new place if theres no auto import (i.e. for meta.zcml). |
| 75 | + - All imports still work. |
| 76 | + - Log deprecation warnings on first import. |
| 77 | + - The ZCML still exists, but is empty or includes the ZCML from the new place, if there's no auto import for `meta.zcml`. |
77 | 78 |
|
78 | | -Deprecation of a whole released/ installable package. |
79 | | - |
80 | | -: We will provide a last major release with no 'real' code, only backward compatible (bbb) imports of public API are provided. |
81 | | - This will be done the way described above for a whole package. |
82 | | - The README clearly states why it was moved and where to find the code now. |
| 79 | +Deprecation of a whole released or installable package |
| 80 | +: Plone developers provide a major release with no "real" code, but only backward compatible imports of the public API. |
| 81 | + This will be done the way described above for a whole package. |
| 82 | + The README clearly states why it was moved and where to find the code now. |
83 | 83 |
|
84 | 84 | Deprecation of a GenericSetup profile |
85 | | - |
86 | | -: They may got renamed for consistency or are superfluos after an update. |
87 | | - Code does not need to break to support this. |
| 85 | +: These may have been renamed for consistency or are superfluous after an update. |
| 86 | + Code does not need to break to support this. |
0 commit comments