-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add observer
pattern.
#5
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello zoziha,
Here are my comments:
- More comments needed describing the behavior of the observer and that of the subject.
- The code is breaking the Liskov substitution principle: The functions should accept arguments from the base classes.
remove_from_slice
andappend_slice
are utility functions and not necessarily part of the pattern.- The only functions that you need in the abstract interface to illustrate the pattern are: register, deregister, notify and update. Get_Id is a utility function
- Put the base classes in one file and the concrete classes in a second file.
Best regards,
Daniel.
Hello Daniel, thanks for your comments!
For detailed information, see the reference in the header of every file.
In fact, yes, I can't find a better way to replace the existing writing.
This may also be an obstacle. It is not possible to allocate memory for the same variable multiple times in the same Fortran variable domain. I tried to use these two functions (
I refer to the Go language code here. It uses this method (
I continued the writing style of |
!> Specific objects | ||
|
||
type, extends(subject) :: item | ||
type(node), allocatable :: o_list(:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to use class(observer), allocatable :: o_list(:)
here, but this writing method faces some incompatibility issues with the existing grammar of Fortran. I need help! Who can try to solve this problem?
Maybe here (?) my code is breaking the Liskov substitution principle: The functions should accept arguments from the base classes.
observer
pattern example.Hope this PR gets your approval, thank you! 😘