You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,12 +160,12 @@ In some parts of this documentation you will find the words "**HIGHLY RECOMMENDE
160
160
161
161
The omission of "**HIGHLY RECOMMENDED**" conventions (like naming conventions, or implementation conventions) might not break your code and it might work without them, even you might found a way to create your own way to implement them, HOWEVER, this could lead to readability, clarity, maintenance and scalability issues of the code.
162
162
163
-
For this reason always **FOLLOW THE CONVENTIONS** since this is necessary to keep the readability, clarity, maintenance and scalability of your code, in this way other collaborators can go over your code easily and improve the work flow.
163
+
For this reason, always **FOLLOW THE CONVENTIONS** since this is necessary to keep the readability, clarity, maintenance and scalability of your code, in this way other collaborators can go over your code easily and improve the work flow.
164
164
165
165
166
166
## Use cases and examples:
167
167
168
-
In this repository there are 2 main files "python_sharp.py" (which is the module file) and "test.py". This last file contains all the features applied into one single script, this could be really useful if you want to do a quick check about how something is implemented, however, since it is a "testing" script and not a "walk through" it could be confusing if you do not know what is going on, so it is **Highly recommended** read the documentation below which explains step by step how to implement every single feature in the module.
168
+
In this repository there are 2 main files "python_sharp.py" (which is the module file) and "test.py". This last file contains all the features applied into one single script, this can be really useful if you want to do a quick check about how something is implemented, however, since it is a "testing" script and not a "walk through" it could be confusing if you do not know what is going on, so it is **Highly recommended** read the documentation below which explains step by step how to implement every single feature in the module.
169
169
170
170
### Delegates
171
171
@@ -402,13 +402,13 @@ Below this text, the use cases and explanation about the events are shown, pleas
402
402
403
403
On this example an event *name_changed*is implemented to notify when the person's name change.
404
404
405
-
To implement a *simple event* the first thing you have to do is create a variable to store the subscribers, look at this variable as a "To do list"due it contains the callables that are going to be executed at some specific time.
405
+
To implement a *simple event* the first thing you have to do is create a variable to store the subscribers, look at this variable as a "To do list"because it contains the callables that are going to be executed at some specific time.
406
406
407
407
```Python
408
408
self._name_changed = Delegate() # it can be viewed as a "To do list"
409
409
```
410
410
411
-
As you might notice the variable that is going to store the subscribers is a Delegate and the name starts with'_' to "protect" the attribute. Expose the attribute "publicly"isnot a good practice, due other part of the code can manipulate the attribute wrongly or get/set information in a way that was not mean to. To fix this, we can define 2 methods to encapsulate the delegate (add/remove methods), Through these 2 methods the other objects in the code can subscribe/unsubscribe (add/remove) callables to our delegate.
411
+
As you might notice the variable that is going to store the subscribers is a Delegate and the name starts with'_' to "protect" the attribute. Expose the attribute "publicly"isnot a good practice, because other parts of the code can manipulate the attribute wrongly or get/set information in a way that was not mean to. To fix this, we can define 2 methods to encapsulate the delegate (add/remove methods), Through these 2 methods the other objects in the code can subscribe/unsubscribe (add/remove) callables to our delegate.
412
412
413
413
```Python
414
414
@event
@@ -504,7 +504,7 @@ The next snipped code shows and example of how the *simple events* should be imp
504
504
self._name_changed -= value
505
505
```
506
506
507
-
This is done with the intention of clarify what is the event expecting from its subscribers signature.
507
+
This is done with the intention of clarifying what is the event expecting from its subscribers signature.
508
508
509
509
The omission of this event annotation convention do not affect how the code works, however, it could lead to problems of readability, clarity, maintenance and scalability. For these reasons **ALWAYS** place the event annotations, this is the only way for the event to communicate what is he expecting from its subscribers.
510
510
@@ -628,7 +628,7 @@ It is **HIGHLY IMPORTANT** to realize *moved* event signature is *Callable[[obje
628
628
-*Callable[[object, MovedEventArgs], None]*
629
629
-*Callable[[object, EventArgs], None]*
630
630
631
-
These 2 signatures are ok because of polymorphism, it can be confusing due at first sight seems like we are assigning an *EventArgs* objeect to a *MovedEventArgs* variable (*MovedEventArgs*<-*EventArgs*), this case in OOP (Object Oriented programming) isnot valid, due it might throw a Traceback if a *MovedEventArgs* member is trying to be accessed in a *EventArgs*object.
631
+
These 2 signatures are ok because of polymorphism, it can be confusing due at first sight seems like we are assigning an *EventArgs* objeect to a *MovedEventArgs* variable (*MovedEventArgs*<-*EventArgs*), this case in OOP (Object Oriented programming) isnot valid, because it might throw a Traceback if a *MovedEventArgs* member is trying to be accessed in a *EventArgs*object.
632
632
633
633
However in this example isnot the case, the subscriber with*Callable[[object, EventArgs], None]* signature defines how the parameter objectis going to be treated by the callable, in this case, the parameter will be used/treated as an *EventArgs*, and the event will provide a *MovedEventArgs*object to the callable so in reallity we are assigning a *MovedEventArgs*object to an *EventArgs* variable (*EventArgs*<-*MovedEventArgs*) which by polymorphism will not cause any issue trying to access any of the *EventArgs* members in a *MovedEventArgs*object.
634
634
@@ -829,7 +829,7 @@ As you can see our custom *EventArgs* is *LocationChangingEventArgs* this class
829
829
830
830
Key factor to know when an event is an *Event with modifiable argument*isif the ***EventArgs*classclass contains a propertywith a setter**.
831
831
832
-
*LocationChangingEventArgs* does not contain a propertywith a setter by itself, but due it inherits from an *EventArgs* which contains it (*CancellableEventArgs*), we can consider that *LocationChangingEventArgs* actually contains a propertywith a setter.
832
+
*LocationChangingEventArgs* does not contain a propertywith a setter by itself, but because it inherits from an *EventArgs* which contains it (*CancellableEventArgs*), we can consider that *LocationChangingEventArgs* actually contains a propertywith a setter.
833
833
834
834
For this particular example *cancel*propertyisset to *False* by default, when the *EventArgs*objectis passed to the subscribers now they have the ability to change *cancel* value property:
0 commit comments