All Questions
Tagged with design-patternspython
126 questions
24votes
1answer
11kviews
Strategy design pattern with various duck type classes
I've recently picked up the Head First Design Patterns book in an effort to become a more efficient and better Python programmer. Unfortunately, the code examples in this book are in Java. I'm not ...
18votes
2answers
3kviews
A KenKen puzzle/solver in Python
I've written a simple KenKen puzzle/solver in Python. I'd love some feedback on the design of the puzzle, as well as the architecture for the solver. To model the puzzle, I have the following classes:...
11votes
1answer
247views
Creating an app for selecting a folder
The script creates a simple app with a GUI containing an input field and a button to select a folder. On startup a default value is set to the input field. If the user types a value or selects a ...
10votes
3answers
39kviews
Text-based Blackjack game in Python
I am new to programming in Python and wrote a simple Blackjack project. I am looking for experienced peers to provide a high level code review about the overall design patterns and proper usages. The ...
10votes
2answers
214views
System design - Jaipur board game learning agent
Link to my previous question. I've implemented the other features of the board game, and made a simple learning method that stores state values and makes optimal moves based on that. I've used some ...
10votes
2answers
141views
Adapting a bilingual program to support users with learning disabilities
I have a very large class which serves as the BaseClass for many AdapterClasses. The base class consists of methods that can be ...
10votes
1answer
1kviews
State and Borg design patterns used in a Telegram wizard bot
I'm making a sort of a user interface for a telegram bot and my idea was to use State design pattern for making sort of a wizard for all the process, with user inputting data in each step or pressing /...
8votes
1answer
235views
Making argument parsing more streamlined and readable than if-statements
I am working on an API wrapper for calls to a website. Each of several types of calls can take a large number of optional arguments, some of which contradict. In the interest of preventing the user ...
8votes
1answer
3kviews
Testing lower- and upper bound values in Python
Code functionality The following code tests whether the values that a user specifies for a lower bound and upper bound on two properties: The lower bound is smaller than the upper bound. The values ...
7votes
1answer
6kviews
Creating a Kinesis stream, Firehose, and lambda event source from config file
I'm in the process of writing a python script for automating a data ingestion pipeline using Amazon Web Service's Kinesis stream, Firehose and lambda. This is my first stab at writing Python, but I do ...
7votes
1answer
511views
Refactoring of a client API to avoid duplicated code and unclear passage of parameters
I need to develop an API. The functions of the API are requests that call the services exposed by a server. Initially the API worked like this: ...
7votes
1answer
1kviews
Observer pattern implementation without subclassing
I have not yet seen an implementation of the observer pattern in Python which satisfies the following criteria: A thing which is observed should not keep its observers alive if all other references to ...
7votes
1answer
246views
Create six hash tables - 2 hashing schemes x 3 collision handling schemes
I was asked to solve the following task: Given two methods for hashing (division and multiplication) and three methods for collision handling (chaining, open addressing w/ quadratic probing, and ...
6votes
2answers
784views
Implementing web scraping in a function and in a class
The goal of my code is to implement a web scraping routine to obtain the name and the price of a product. I want to put this routine separated from the main program file. Sample url to scrape: https://...
6votes
2answers
1kviews