Tagged Questions
12
votes
2answers
965 views
Design decision - why generate <p> without </p>?
tl;dr
Some widely used programs, which generate html, will only generate opening paragraph tags, and not closing ones, assuming that the browser will properly close paragraphs.
On the face of it, it ...
9
votes
1answer
1k views
How to refactor a Python “god class”?
Problem
I’m working on a Python project whose main class is a bit “God Object”. There are so friggin’ many attributes and methods!
I want to refactor the class.
So Far…
For the first step, I ...
7
votes
1answer
3k views
python factory function best practices
Suppose I have a file foo.py containing a class Foo:
class Foo(object):
def __init__(self, data):
...
Now I want to add a function that creates a Foo object in a certain way from raw ...
5
votes
4answers
519 views
Why doesn't Haskell have a 'format' function for string interpolation?
I'm trying to use Shake and I stumbled upon the following problem: there's no easy and convenient way to interpolate a string. I know about Text.Printf — it's not what I'm looking for. The ...
4
votes
4answers
2k views
What is the simplest human readable configuration file format?
Current configuration file is as follows:
mainwindow.title = 'test'
mainwindow.position.x = 100
mainwindow.position.y = 200
mainwindow.button.label = 'apply'
mainwindow.button.size.x = 100
...
4
votes
6answers
1k views
How does rapid prototyping fit into an agile methodology?
I work for a large company, which dictates the use of agile processes. For example, for our projects, we use cloud-based services that are specifically targeted at managing agile development.
The ...
4
votes
2answers
251 views
Ensuring conceptual integrity in Python project with multiple programmers
One objection that I have often heard raised against Python that it is difficult to synchronize a team of many programmers on large Python project. Note: that synchronization is possible in such a ...
4
votes
4answers
228 views
Design: multiple algorithms on the same large data sets
I have several algorithms that I would like to test against the same data sets to compare their results. I don't know how to design it so there is maximum readability and maximum efficiency.
I have ...
4
votes
2answers
188 views
Designing a function with many optional components
I'm trying to figure out a good practice for designing a function with (many) optional components.
For a specific example, say I am interested in designing a feature extractor function that takes as ...
4
votes
1answer
648 views
How to design a composite pattern in Python?
The concept
I'm programming an interface over pygame as a personal project, to make the creation of games easier for me.
So far I managed to design an architecture that behaves like this :
Objects ...
4
votes
2answers
278 views
What is the preferred way of communicating between applications on the same system?
I'm designing a system that is built on several small applications written in python, some of these will be services and others will be programs that only run during special situations. What I need to ...
3
votes
5answers
774 views
When should use of database be preferred over parsing data from a text file?
I was making a Python program to measure the growth of codereview.SE. My approach was to get the "Site stats" shown on the front page and store them on my hard drive. I plan to do this once every day. ...
3
votes
5answers
529 views
Designing for an algorithm that reports progress
I have an iterative algorithm and I want to print the progress. However, I may also want it not to print any information, or to print it in a different way, or do other logic. In an object oriented ...
3
votes
4answers
308 views
Representing complex object dependencies
I have several classes with a reasonably complex (but acyclic) dependency graph. All the dependencies are of the form: class X instance contains an attribute of class Y. All such attributes are set ...
3
votes
1answer
596 views
Is this an acceptable approach to undo/redo in Python?
I'm making an application (wxPython) to process some data from Excel documents. I want the user to be able to undo and redo actions, even gigantic actions like processing the contents of 10 000 cells ...
3
votes
2answers
905 views
Caching factory design
I have a factory class XFactory that creates objects of class X. Instances of X are very large, so the main purpose of the factory is to cache them, as transparently to the client code as possible. ...
2
votes
2answers
260 views
Removing an element not currently in a list: ValueError?
This is something that's bothered me for a while, and I can't figure out why anyone would ever want the language to act like this:
In [1]: foo = [1, 2, 3]
In [2]: foo.remove(2) ; foo # okay
Out[2]: ...
2
votes
2answers
268 views
How to structure a class in python
I have come to python from C++ (I also know a little Java). I am writing code to exercise a server so I basically use http methods to send a load of requests to the server. As part of my code I ...
2
votes
1answer
388 views
Python simulation-scripts architecture
Situation:
I've some scripts that simulate user-activity on desktop. Therefore I've defined a few cases (workflows) and implemented them in Python. I've also written some classes for interacting with ...
1
vote
5answers
506 views
Decoupling Components - Design
I have created a a number of non-trivial scripts in Python that do some long running reporting. At first these reports started off as scripts with a config file. Then I added in the a database ...
0
votes
3answers
4k views
Browser-based GUI for a python application [closed]
I want to create a web/browser-based GUI for a command-line python application. The goal is to make use of HTML/JS technologies to create this GUI. As the application itself, it needs to run on Linux ...
0
votes
2answers
159 views
Python — when should a class have-a rather than be-a?
This is related to "Extends is evil" vs. OCP? but separate because the idea of "implement the interface" doesn't exist in Python.
I'm writing a class to pull some data off a webpage. It's ...
0
votes
1answer
238 views
Scientific software design [closed]
I asked this question over at stackoverflow and it was suggested a tighter form be posted here.
Many early career numerical researchers face the prospect of having to create performance critical ...
0
votes
1answer
68 views
Pythonic design for controlling multiple devices through an I2C bus
I'm writing a piece of software in python that will communicate with a bunch of devices via an I2C bus. Each of these devices are going to need some sort of a module or class to handle the ...
0
votes
1answer
471 views
Python datetime timedelta attributes
In the python datetime module, timedelta objects take weeks, days, hours, minutes, seconds, and microseconds as arguments upon instantiation. However, after the timedelta is created, the only two ...
0
votes
1answer
222 views
Code design: is this specific case of monkeypatching in python acceptable?
I'm using python to do some research tasks. I have a class hierarchy for "tools", where each object is an instance of a particular tool. They all share some functionality and have many similarities in ...
0
votes
0answers
49 views
Distributing Contestant Entries Between Multiple Bins, Is this Knapsack?
I am an algorithm novice and am faced with a rather difficult problem. I working with contest's. There are
contestant - individual player
entry - contestants can have multiple entries into a ...
0
votes
0answers
100 views
How to algorithmically add notes to an existing midi file relative to positions of existing notes in python
I have a midi file that I'd like to algorithmically add notes to relative to other notes that already exist in the midi file using python, or if it's easier using a different language I'm open to that ...