Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cca9272

Browse filesBrowse files
committed
Fix minor spelling, grammar, and consistency errors in the Object-oriented programming section.
The paragraph about context and side effects was very difficult to parse and contained the word "decelable". I attempted to capture the meaning of the paragraph in a way that was more readable.
1 parent e79aa47 commit cca9272
Copy full SHA for cca9272

File tree

Expand file treeCollapse file tree

1 file changed

+22
-22
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-22
lines changed

‎docs/writing/structure.rst

Copy file name to clipboardExpand all lines: docs/writing/structure.rst
+22-22Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ repetition of `very.deep.module`.
176176
Object-oriented programming
177177
---------------------------
178178

179-
Python is sometime described as an object-oriented programming language. This
180-
can be somewhat misleading and need to be clarified.
179+
Python is sometimes described as an object-oriented programming language. This
180+
can be somewhat misleading and needs to be clarified.
181181

182182
In Python, everything is an object, and can be handled as such. This is what is
183183
meant when we say that, for example, functions are first-class objects.
@@ -188,46 +188,46 @@ object-oriented language.
188188

189189
However, unlike Java, Python do not impose object-oriented programming as the
190190
main programming paradigm. It is perfectly viable for a Python project to not
191-
be object-oriented, ie. to use no or very few class definitions, class
192-
inheritance, and any other mechanism that are specific to object-oriented
191+
be object-oriented, i.e. to use no or very few class definitions, class
192+
inheritance, or any other mechanisms that are specific to object-oriented
193193
programming.
194194

195195
Moreover, as seen in the modules_ section, the way Python handles modules and
196-
namespaces gives directly to the developer a natural way to ensure
196+
namespaces gives the developer a natural way to ensure
197197
encapsulation and separation of abstraction layers, both being the most common
198198
reasons to use object-orientation. Therefore, Python programmers have more
199199
latitude to not use object-orientation, when it is not required by the business
200-
model to be constructed.
200+
model.
201201

202-
There are some reasons to avoid unnecessary object-orientation. Definining
202+
There are some reasons to avoid unnecessary object-orientation. Defining
203203
custom classes is useful when we want to glue together some state and some
204-
functionality. The problem, as pointed out by the discussions about functional
204+
functionality. The problem, as pointed out by the discussions about functional
205205
programming, comes from the "state" part of the equation.
206206

207-
In some architectures, typically web applications, instances of Python
208-
processes are spawned simultaneously to answer to external requests that can
209-
happen at the same time. In this case, holding some state into instanciated
207+
In some architectures, typically web applications, multiple instances of Python
208+
processes are spawned to respond to external requests that can
209+
happen at the same time. In this case, holding some state into instantiated
210210
objects, which means keeping some static information about the world, is prone
211-
to concurrency problems or race-conditions: between the initialization of the
211+
to concurrency problems or race-conditions. Sometime between the initialization of the
212212
state of an object, usually done with the __init__() method, and the actual use
213-
of the object state through one of its method, the world may have changed, and
213+
of the object state through one of its methods, the world may have changed, and
214214
the retained state may be outdated. For example, a request may load an item in
215215
memory and mark it as read by a user. If another request requires the deletion
216-
of this item at the same, it may happen that the deletion actually occur after
216+
of this item at the same, it may happen that the deletion actually occurs after
217217
the first process loaded the item, and then we have to mark as read a deleted
218218
object.
219219

220220
This and other issues led to the idea that using stateless functions is a
221221
better programming paradigm.
222222

223-
Another way to say the same thing is to propose to use functions and procedures
224-
with as few implicit context and side-effects as possible. A function's
225-
implicit context is decelable when the function body refers to some global
226-
variables or fetches data from the persistence layer. Side-effects are the
227-
opposite: if a function body modifies the global context or save or delete data
228-
on the persistence layer, it is said to have side-effect.
223+
Another way to say the same thing is to suggest using functions and procedures
224+
with as few implicit contexts and side-effects as possible. A function's
225+
implicit context is made up of any of the global variables or items in the persistence layer
226+
that are accessed from within the function. Side-effects are the changes that a function makes
227+
to it's implicit context. If a function saves or deletes data in a global variable or
228+
in the persistence layer, it is said to have a side-effect.
229229

230-
Isolating carefully functions with context and side-effects from functions with
230+
Carefully isolating functions with context and side-effects from functions with
231231
logic (called pure functions) allow the following benefits:
232232

233233
- Pure functions are more likely to be deterministic: given a fixed input,
@@ -239,7 +239,7 @@ logic (called pure functions) allow the following benefits:
239239
- Pure functions are easier to test with unit-tests: There is less
240240
need for complex context setup and data cleaning afterwards.
241241

242-
- Pure functions are easier to manipulate, decorate_, pass-around.
242+
- Pure functions are easier to manipulate, decorate_, and pass-around.
243243

244244
In summary, pure functions, without any context or side-effects, are more
245245
efficient building blocks than classes and objects for some architectures.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.