Skip to main content

Questions tagged [classes]

Core to Object-Oriented Programming (OOP), a class is a template for creating new objects that describes the common state(s) and behavior(s).

Filter by
Sorted by
Tagged with
3 votes
1 answer
135 views

Snail matrix in Java - version III (generalizing)

Once again, in the previous version, Alexander Ivanchenko helped me with his awesome answer. Now, I have improved the toString() and, also, generalized the class ...
coderodde's user avatar
  • 28.3k
4 votes
1 answer
294 views

Snail matrix in Java - version II

(This post is the continuation of Snail matrix in Java. Also, this post has an continuation.) As previously, a snail matrix is any square matrix \$M_n = \mathbb{N}^{n \times n}\$ with cell elements ...
coderodde's user avatar
  • 28.3k
5 votes
2 answers
804 views

Snail matrix in Java

(This post has an continuation: Snail matrix in Java - version II.) Inspired by this post, I decided to solve that problem in Java. The idea is to decide on an \$n \in \mathbb{N}\$, create a square ...
coderodde's user avatar
  • 28.3k
4 votes
1 answer
72 views

Terminal based game: Part 3 (Using templated game)

Working from previous posts In this post: Terminal based game: Part 2 I introduced the concept of a Game object. To build a game like Terminal Base Snake you could ...
Martin York's user avatar
  • 95.1k
1 vote
1 answer
62 views

Dynamically mapping an API's setting IDs to instance methods using Descriptors

I'm working with an API, where the url can be constructed with setting_ids. To more clearly indicate the functionality of the setting ids I am mapping them to a WriterClass' methods, with relevant ...
Floriancitt's user avatar
-1 votes
1 answer
55 views

Should the SqlConnection Be a Class Field or Should I Pass It In and Out Of Functions As Needed?

I am writing a C# Database connection class and I am trying to adhere to best practices and produce clean code. In the CreateAndOpenDatabaseConnection function ...
BeeFriedman's user avatar
0 votes
1 answer
42 views

Updating class method to use data from new weather API endpoint while keeping same return value object structure as with old endpoint

I needed to update a class in Node.js that parses the response from a new weather API endpoint but still preserves the same object structure and key values from having been using the old weather API ...
Aaron Goldsmith's user avatar
5 votes
5 answers
369 views

Using MergeSort to sort data structured in Person class based on object attributes (DRY)

I am working on a program that sorts data using mergesort. I implemented functions to 'Person' class to make it comparable, sortable, subscriptable, iterable, and castable (to float, int, and string). ...
Pitre's user avatar
  • 51
1 vote
2 answers
126 views

Mapping an API's setting IDs to setting names with class methods, enabling clearer utilization

I'm trying to access an API using the requests library in as clean a manner as possible. The API is accessing various settings of various devices. I'd like to keep my code as readable and ...
Floriancitt's user avatar
1 vote
1 answer
65 views

An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++

This is a follow-up question for Multi-dimensional Image Data Structure with Variadic Template Functions in C++. Considering the suggestion from G. Sliepen: Make everything work for more than 5 ...
JimmyHu's user avatar
  • 4,748
2 votes
2 answers
112 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 ...
JDT's user avatar
  • 81
5 votes
1 answer
275 views

Multi-dimensional Image Data Structure with Variadic Template Functions in C++

This is a follow-up question for Three dimensional data structure in C++. I am trying to implement multi-dimensional image data structure with variadic template functions. For example, ...
JimmyHu's user avatar
  • 4,748
3 votes
1 answer
81 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 ...
Jin22's user avatar
  • 33
5 votes
2 answers
823 views

Three dimensional data structure in C++

This is a follow-up question for Three dimensional gaussian image generator in C++. Considering the suggestion from G. Sliepen: Structure of a 3D image Your 2D ...
JimmyHu's user avatar
  • 4,748
0 votes
3 answers
144 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....
Abcd's user avatar
  • 103
1 vote
1 answer
69 views

Python3 tokenizer abstract baseclass ( Without the permission to be instantiated directly )

I'm a newbie python developer, and fortunately I have been introduced to the principle of abstract base classes and they seemed pretty interesting to tackle while going forward in my Python journey. I'...
KhodeNima's user avatar
  • 349
1 vote
1 answer
198 views

Python3 currency abstract class (without the permission to be instantiated directly)

I'm a newbie python developer who accidentally studied the concept of Abstract classes and I found it pretty much helpful to implement due to the SOLID principles. At the very moment of testing and ...
KhodeNima's user avatar
  • 349
3 votes
2 answers
123 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: ...
Dead1nside's user avatar
4 votes
1 answer
61 views

Improving readability of semi-nested classes for loading data of separate runs of a joint testing campaign

A bit of background: Most often I am analysing data (mostly timeseries) of mechanical machine conditions (vibrations, temperatures...) that were acquired in different 'runs'. All runs were acquired ...
Jorre Goossens's user avatar
1 vote
0 answers
53 views

Memory game code quality

I am making an incremental-memory-game similar to this https://www.crazygames.com/game/incremental-memory I am not very satisfied of how spaghetti this code is. I am trying to learn to improve my code ...
jerma lover1's user avatar
4 votes
1 answer
185 views

Blog site generator in python

Summary: This project is a simple static blog site generator written in python, utilizing pandoc to convert posts written in Markdown to HTML. It is essentially a follow up to my previous post: blog ...
766F6964's user avatar
  • 901
7 votes
3 answers
197 views

C++ String Class Reimplementation

I started learning C++ about a week ago and I was hoping somebody can critique my code. I decided to implement my own basic String class just for the sake of applying all that I've learned about ...
Janriz Libres's user avatar
0 votes
1 answer
94 views

PHP Class to render HTML div styled tables v2 [reviewed by me]

After my previous question I made several changes and came up with this. Remember: I wrote this for PHP 7.0.33. I'm aware I should upgrade, save the advice :) ...
julio's user avatar
  • 199
5 votes
3 answers
799 views

Library: Point class

Recently I made a point dataclass and a point_calc class which performs various commonly used algorithms on a point. ...
TheHappyBee's user avatar
2 votes
1 answer
456 views

PHP Class to render HTML div styled tables v1

This class aims to render an HTML compliant div styled table. I added a help() method that provides usage and styling in a more user-friendly way. Besides the ...
julio's user avatar
  • 199
2 votes
1 answer
102 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 ...
julio's user avatar
  • 199
3 votes
2 answers
657 views

PHP HTML form Class - so far so good?

I am writing this class to render HTML forms. It is working as expected, so far. There are many things to be done yet (including testing). Is it ok to keep this way? ...
julio's user avatar
  • 199
2 votes
1 answer
100 views

PHP Pagination class (Clase para paginar resultados)

This is my first question in Code Review. I apologize in advance for using Spanish (my native language). I thought there was a spanish version of Code Review. This class is meant for pagination. It ...
julio's user avatar
  • 199
-4 votes
1 answer
86 views

any bits unsigned integer [closed]

This is a class that acts as an unsigned integer with a variable amount of bits. ...
RhinoRunner's user avatar
1 vote
0 answers
101 views

Storing multiple PyTorch tensors of different shapes with names that are not known by advance

I need to create a container for instances of torch.Tensor of different shapes, where I can call them by their name. It is a use case for a dict except that: I don't want to rely on the heavy syntax ...
Xiiryo's user avatar
  • 111
2 votes
1 answer
105 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: ...
Ake's user avatar
  • 123
1 vote
2 answers
147 views

A simple String class and its special member functions

I am learning the behavior of C++'s special member function, using a naive String class as example. (The code is modified from this tutorial) Here is the ...
Lion Lai's user avatar
  • 297
2 votes
1 answer
155 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 ...
Aloy's user avatar
  • 21
0 votes
1 answer
77 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 ...
Anthony Pulse's user avatar
2 votes
3 answers
134 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 ...
Beginner's user avatar
  • 189
1 vote
1 answer
145 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 ...
Benjamin Basmaci's user avatar
4 votes
1 answer
205 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 ...
whiteman808's user avatar
2 votes
0 answers
65 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 (...
schuelermine's user avatar
3 votes
2 answers
1k views

Football team match result summary table

The program is taken on the standard input a list of football team games with the result of the match and displays on the standard output a summary table of the results of all matches. A team is ...
Sefora Abigail's user avatar
1 vote
0 answers
79 views

Powershell Outlook Email Security custom classes

This provides custom classes to work with Outlook 2016's email security settings in trust center. Included are some top level functions to list outlook profiles, retrieve the data from a given profile,...
timothy-byles's user avatar
2 votes
1 answer
220 views

Fetch data from two exchanges

I'm trying to fetch the latest price from two exchanges and to do further actions based on the prices. exchanges.py: ...
tung's user avatar
  • 97
0 votes
0 answers
83 views

Investment capital calculator(Python)

The program is simulate a situation where my goal is to lose money in Corresponding exchange, however I will win max_lose times ...
tung's user avatar
  • 97
1 vote
1 answer
51 views

Sparse String Matrix Storage Class C++

Introduction I implemented a class to store a matrix with entries at positions (i,j) that are strings. The matrices I would like to efficiently store in this class have strings as entries and it ...
jan0155's user avatar
  • 113
2 votes
1 answer
168 views

Create a string "Build" number for procedures and module

The class assigns various strings to the build number. So the build might look like 3.4.5.1 which would be of the format ...
DanM's user avatar
  • 121
1 vote
1 answer
168 views

A greedy approach to the Knapsack problem with C++ templates

The assignment is to be implemented on the following instructions: You are to write a Knapsack class and the main() to support and demonstrate the functionality required here. A function generate(int)...
user avatar
3 votes
1 answer
558 views

Movie app using fetch API

The code will create a new Movie class and then with the response of the API call, will render html using the data. Although the code works, I imagine it will get quite convoluted, now that everything ...
DonnyRodriguez's user avatar
2 votes
2 answers
57 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 ...
Infinite Grasp's user avatar
2 votes
2 answers
523 views

Python: Sorting Marbles with switch and rotate - Need help in optimizing a working solution

I have made a couple modifications to the switch/rotate routine for the classic Marbles game. The modifications are Using a random_select method that can help pick either switch or rotate Create a ...
gaurav8936's user avatar
0 votes
1 answer
488 views

What can I do better in my C++ serialization implementation?

I want to serialize a class Mango recursively. ...
James_sheford's user avatar
4 votes
1 answer
158 views

Alpha finance trader singleton

I used to write singleton in Python, which actually Alpha only need to initialize once and the trading bot will run forever. For example in main.py: ...
tung's user avatar
  • 97

1
2 3 4 5
9