All Questions
Tagged with object-oriented classes
134 questions
7
votes
4
answers
969
views
6
votes
2
answers
706
views
What is the best way to set a class value to a variable in Python if it exists in a dictionary?
I have this code which sets values in a location class from values from JSON data.
...
2
votes
2
answers
134
views
Alternate **kwargs for class __init__ function [closed]
I want to set up a Python class so that it can be constructed with one set of parameters or another. I'm trying to mimic C++ function templates. I tried alternate constructors. In the actual code I'm ...
3
votes
1
answer
97
views
Random generation of points for the graphs of 3 stock share parameters
I currently studying OOP and related design patterns, and tried to implement random data generation for some stock charts using OOP as an exercise.
This code randomly generates data points for 3 ...
0
votes
3
answers
167
views
Declaring type definition once for all variables
To avoid the use of magic numbers, I created a static class to store some integer values that are represented inside a database. I avoided using enums because I need to cast them every time I use them....
3
votes
2
answers
132
views
Defining hardware components structure
I'm writing firmware for my Arduino project, and I'm struggling with a clean, scalable hardware mapping structure. Initially, I had the following namespace:
...
2
votes
1
answer
107
views
HTML form Class
After my previous question I revised the code to the code below. I am using PHP 7.0.33 and tried to accomplish PSR-12 as much as I could. In "condensed usage" in the docblock you can find a ...
2
votes
1
answer
109
views
Making a game using python and pygame
I am making a game using python and pygame and as my game started to grow, in some of my classes the number of instance variables started to get big.
Like in the settings class is like this:
...
2
votes
1
answer
162
views
Java program for complex math utilities
I've got 2 Java programs, with the aim of solving some matrix math that involves complex numbers (an EE problem). Both programs have main functions, the one with all the complex math operations has a ...
0
votes
1
answer
81
views
GPG class for AJAX calls
I want to know if this GPG class in PHP is up to snuff as a professional-level class. I did my best to include everything and make it easy to use. I'm calling the object by invoke(). If anyone can ...
2
votes
3
answers
139
views
Rock Paper Scissors with file save/load
Took me a couple days and I had to make 2 versions. Version 1.2 is better looking and more readable, with better functionality. No where near optimized though, as I know nothing about that.
Save and ...
1
vote
1
answer
147
views
Interconnect Recipe and Notes
I'm currently working through a tutorial. The project is a recipe website.
One of the lessons to "save some lines of code" and use bidirectional setters for bidirectional relations of ...
4
votes
1
answer
218
views
Simple console menu backend with calculator implementation in Python
I've written a simple calculator in Python. I want to show not much effect of the action but the logic behind it, by that I mean console menu implementation in the ...
3
votes
0
answers
75
views
A Haskell-style "maybe" type in Python, version 2
I have decided on a preferred solution to my question A maybe type in Python. Which implementation is best?, and have expanded it to be more ergonomic. I have implemented a host of utility functions (...
2
votes
2
answers
58
views
Object Oriented Hangman in Python (version 1.0)
As always, I am looking for as much criticism as possible. Forums and exchanges like this are where I have received my most solid feedback.
Enjoy!
Github hangman repository
The code that I import is ...