Python Forum
Which method name would you choose?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Which method name would you choose?
#5
Thank you all for your input. I think get_preamble_and_content() is too specific. It gives the impression that a mediator is a container which it is not, I want to keep it clear that it is some kind of pointer. get_pointer_data() and read_data() are a little verbose, the 'data' could be avoided. I think I'll use the following
resource = mediator.get()
# resource has members
resource.preamble
resource.text
The .get() makes it clear that we are dereferencing something. A known example is
response = requests.get(url)
We can see a url as a pointer to a resource on the internet, and it suffices to indicate that we dereference this pointer. A benefit of returning a single object is that this object's content can change later more easily.

There is an example of a smart pointer in the standard library: weak references
>>> from weakref import ref
>>> class A: pass
... 
>>> a = A()
>>> r = ref(a)
>>> r
<weakref at 0x7fedeedb1350; to 'A' at 0x7fedeed7f490>
>>> r()
<__main__.A object at 0x7fedeed7f490>
Here the __call__() is used to dereference the pointer, but I think it is cryptic for the reader of the program. get() is better than call.

Another example is that of tkinter variables, which are just pointers dereferenced by the get() method.
string = stringvar.get()
Thanks again, if you have more ideas about this, please add them to this thread.
PyDan likes this post
« We can solve any problem by introducing an extra level of indirection »
Reply


Messages In This Thread
RE: Which method name would you choose? - by PyDan - May-29-2024, 04:57 AM
RE: Which method name would you choose? - by Gribouillis - May-29-2024, 10:53 AM
RE: Which method name would you choose? - by PyDan - May-30-2024, 01:29 AM
RE: Which method name would you choose? - by buran - May-30-2024, 07:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mac os choose file name howard687 1 1,997 Jan-05-2022, 06:54 AM
Last Post: Larz60+
  Loop with choose Irv1n 5 3,420 Sep-16-2021, 09:31 PM
Last Post: deanhystad
  Choose an element from multidimensional array quest_ 2 2,775 Nov-25-2020, 12:59 AM
Last Post: quest_
  Choose your own adventure game noahc2004 2 2,736 Jun-26-2020, 02:06 PM
Last Post: DPaul
  Please help a newbie choose which programming language to learn. yeto 2 3,659 Feb-25-2019, 12:56 AM
Last Post: yeto
  User Input to Choose from Dictionary anelliaf 9 26,283 Mar-27-2018, 02:22 PM
Last Post: anelliaf
  Reasons to choose Python over C++? RandoomDude 62 47,608 May-03-2017, 05:29 PM
Last Post: micseydel
  Need a little more help in a Choose Your Own Adventure Program Goldberg291 13 19,006 Jan-31-2017, 08:33 AM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020