0

We have a config.ini file with methods associated to tables, something like this:

[assoc]
people = getPeopleTable
food = getFoodTable

in our main program we instantiate a database object and we call them like this:

output = getattr(self.db, 'getTable')(config.get('assoc',table))

and in our database class we have the methods to fetch each table, and, getTable, which looks like:

def getTable(self, table):
  table = getattr(self, table)()
  return table

Is this by any chance a type of design pattern? Sorry if it seems stupid, this subject is new to me.

closed as unclear what you're asking by gnat, Samuel, Robert Harvey, Andy, Bart van Ingen Schenau Aug 7 '17 at 10:58

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2

No, this is not a Software Design Pattern. It is missing every single thing that makes a Pattern:

  • an Evocative Name
  • Context
  • a description of the conflicting Forces that both would pull you towards using the Pattern as well as push you away from it
  • a description of the Problem the Pattern solves
  • a description of the Solution the Pattern provides, including
  • How the Pattern solves the problem and
  • Why the Pattern solves the problem (and also why some other related Patterns don't solve the Problem)
  • Examples of applying the Pattern, both in high-level form (e.g. diagrams of the design) and in code (ideally, in multiple languages)
  • Known Uses: a Pattern is only a Pattern if it is a common solution to a recurring problem, here you should describe where you found the pattern in different systems
  • Related Patterns (and Anti-Patterns): Patterns have relationships with other Patterns (for example, Iterator and Subject/Observer are category-theoretical duals, Model-View-Controller is often used together with Subject/Observer, Front Controller and Page Controller are alternatives, and so on).
  • … and probably some more I forgot.
  • Sorry, I might have not expressed myself properly, I was wondering if this is by any chance an already existing pattern. – Onilol Aug 4 '17 at 13:30
  • @Onilol Then your question is written in a misleading way. You might want to rewrite it. – Philipp Aug 4 '17 at 13:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.