2
votes
1answer
72 views

How can I optimize my insert function for the cuckoo hash table?

I'm working on class for a hash table where collisions are corrected using cuckoo hashing, I had difficulty writing the insert function, the function is supposed to insert the key if the ...
10
votes
1answer
322 views

When should I consider the number of my method arguments too big?

I'm writing a simple Pong game, I have a method bounce() that makes everything run: the ball, the paddles, score etc. and it uses 12 arguments: 3 counters, 2 ...
3
votes
1answer
58 views

Using classes vs. using functions

I am trying to learn how to tell if my code will be better off creating a class as opposed to using many functions. I am a new Python programmer trying to get the hang of when classes should be ...
4
votes
1answer
127 views

Generalized is() type-checking function for JavaScript

In a complex library I've been working on, I got pretty tired of all of the individual type functions and operators to determine whether I was working with an object or piece of data of a given type. ...
1
vote
2answers
134 views

What is a better way to organize this Python code in a class?

I wrote a script that will eventually go onto a Raspberry Pi. It takes a picture then uploads it to Twitter every 15 minutes from 5:30-9:00pm. It works fine as is, but I feel I need to organize ...
1
vote
2answers
86 views

In this script what can I turn into funtions and how can I go about doing it?

I have just made a simple script which spawns an alien that chases the player, but I want to move as much of the script into funtions so as to minimize the amount of code, to make it run better when ...
3
votes
2answers
98 views

I know I'm not doing these methods right

I'm having difficulty understanding the implementation of methods in classes. I'm pretty sure I'm not doing this the correct way. Can anyone show me the way it should be done. This code works by ...
2
votes
1answer
253 views

Should I use a class as a class factory in Python?

As a bit of a learning project, I decided to take the concept of proxying objects a bit further and extend it to creating proxy classes which create proxy'd objects. I originally found the idea of ...
0
votes
2answers
289 views

PHP PDO Custom class ple

i created a database class from a good tutorial and wanted to put it up here so it would get in some search results. it took me about 2 days to find it. also i added a few custom functions to it.. ...
4
votes
1answer
328 views

Wrapping bound methods

I've written this small class in Python that wraps bound methods but does not prevent the deletion of self. Do you have any thoughts on my code? Do you think I handle errors appropriately? Is it ...