Does this behavior have a better design pattern?

Peter Otten __peter__ at web.de
Thu Nov 8 11:54:22 EST 2018


Grant Edwards wrote:

> On 2018-11-07, Peter Otten <__peter__ at web.de> wrote:
>> lampahome wrote:
>>
>>> Above is I thought to make code clear, and this pattern is called simple
>>> factory?
> 
> [...]
> 
>>> *Is there better design pattern for me?*
> 
>> Generally speaking you get better solutions when you ask yourself
> 
>>     "How can I solve this problem efficiently?"
>> rather than
>>     "What fancy design patterns can I use while solving this problem?"
> 
> I'd rather start with "how can I solve this problem simply and
> clearly".  By "clearly" I mean that the source code is easy to
> understand and reason about.
> 
> I don't worry about "efficiency" unless testing shows that the simple,
> clear solution isn't efficient enough to meet requirements.

You are absolutely right. 





More information about the Python-list mailing list