Construct that is used as template for creating new objects. Class describes the state and behavior that the objects of the class all share.
10
votes
5answers
1k views
ASP.net c# class design (simple)
Here's a class I'm designing:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
namespace Artworking.classes
{
...
8
votes
2answers
363 views
Object Paradigm for PHP, Practice in Design
I've created and I manage a point of sale web application built in PHP which has thus far followed no clear guidelines or methodology for development; it's operation is completely procedural. In turn, ...
7
votes
3answers
331 views
Class with a sometimes unused property
From times to times I stumble over the following situation:
I have got a class with a property that's only used if another property has a particular value, for instance:
public enum ...
7
votes
2answers
318 views
Any way to improve the performance of this PHP class?
I have been developing this class, and was wondering if anyone had any thoughts on how I can improve the performance of it.
<?php
class Something {
private $APIUsername, $APIPassword;
...
6
votes
3answers
817 views
New to OOP; is this a good class design?
I have a few different classes in my application, but this specific class is the one I'm interested about. Please review for good practices and potential problems.
using ...
6
votes
0answers
380 views
How can I manage different problems in Math Quiz?
Ok, this will be the first question for this project.
This is a Math quiz system. Always must generate different problems for each problem, but at the same time, I have to generate the same exam for ...
5
votes
2answers
136 views
Improve/Correct PHP Class
I'm looking for code correctness and improvements for the following code. It's my first step into class based programing.
What the class does, is simply to read a directory (path is passed as ...
5
votes
2answers
190 views
How can I make this method less verbose?
I point to my problem in the comments of my code.
I have a class RomanNumeral:
public class RomanNumeral {
private String romaNumera;
private String romans = "IVXLCDM";
public ...
5
votes
3answers
376 views
Is it wrong to write an entire program under one class/method in Java?
I'm new to programming an created a simple rock, paper, scissors game. The entire program is under a single class and the main method, i hear that's probably not the best way to code.
How should i ...
5
votes
2answers
368 views
Please review this C-style array class
I often use C API's in C++ that force me to use C-style arrays. I got sick of constantly using a dynamic vector with &vec[0], so I wrote this C-style array container. Please review and give ...
5
votes
2answers
436 views
Splitting code, am I doing it right?
I would like to have my code reviewed, I'm trying to get a general model I'm using for my stuff going and I don't want to keep using wrong or inefficient code if I can.
My file structure is like ...
5
votes
1answer
218 views
Javascript inheritance
I have a simple class inheritance in JS:
var Class = function(){};
Class.extend = function(){
var Extended = function(constructor){
function extend_obj(destination, source) {
...
5
votes
1answer
101 views
Playing Cards in C++
I am currently learning C++ (note: I am using C++11) and have begun working on a small project to practice what I've been learning. This project is a deck of cards that I hope to use later to create ...
5
votes
1answer
109 views
ClassHierarchy Design in java for a small project
I have written a java code which does following:-
Main goal is to fetch emails from (inbox, spam) folders and store them in database. It fetches emails from gmail,gmx,web.de,yahoo and Hotmail. ...
4
votes
4answers
148 views
General advice on a practice linked_list for C++ classes/templates
Introduction
I'm learning C++ (Coming from Haskell, C, and Assembly - and other languages sparsely) and this was my practice with classes and templates. It's a linked list that you can call in this ...
4
votes
3answers
187 views
OOP Classes, how to put class in class
I've started to learn an OOP and I've built a class called accountactions, and I would like to know if I did a good job writing it.
The class is in the file: accountactions.class.php.
<?php
...
4
votes
2answers
237 views
Is it a good practice to wrap datatypes in custom classes?
So in my current application, I was thinking to make a extended class for all the datatypes. For int, it will be something like ExtendedInt, for bool it will be something like ExtendedBool.
These ...
4
votes
1answer
250 views
Should I split class or keep it all in one?
Currently, in my project I have one class that is dedicated to the all of the queries for the IBM i and converts it into usable models for my .NET code. There is already 12 methods in this class and ...
4
votes
1answer
146 views
Simplifying a Resizing Method
I'm making a simple container class for fun and education, but my rebuilding/resizing method seems rather inefficient. Is there an easier way to do this?
// If FromFront is true, cells should be ...
4
votes
1answer
93 views
Attempt at an implementation of a TextFile class
How can I improve this class that should represent a text file?
Im trying to write a simple class to represent a text file - which one would think should be quite easy.. I don't intend to add all ...
4
votes
2answers
272 views
Validation Class - Feedback Welcome!
I have written a Validation and Form class in PHP.
Validation class allow you to define the rules of each field and a error message.
Form class allow you to get a error message and also allow you ...
4
votes
2answers
688 views
Returning Groovy class fields as a map
I want to get a map of all the fields in a class (aka value object) in a generic way. The following works fine for me:
class Baz {
String foo = "foo2"
int bar = 2
public Map asMap() {
def ...
4
votes
1answer
226 views
Python, WeakBoundMethod
I've written this small class in Pyhon that wraps bound methods but does not prevent the deletion of self. Do you have any though on my code? Do you think I handle errors appropriately? Is it missing ...
4
votes
1answer
201 views
PHP Extending PDO Class
I am trying to convert myself from using mysql extension to using PDO, with that being said I was curious if I am going about this the right way.
I have a custom logging system that I built I am ...
4
votes
1answer
396 views
C# Class of client methods for interacting with web servers
I'm in QA Automation, and C# isn't my first language. I've written a small class of methods for GETting and POSTing to web URLs. I use these when I want to test certain things that really fall outside ...
3
votes
2answers
233 views
School project critique
This is a long one, I'll edit as instructed.
I humbly submit the following for critique. This was my final project for an Intro To Java Programming class ("handed-in" already, I can't make changes).
...
3
votes
2answers
402 views
STL-like graph implementation
I have implemented an stl-like graph class. Could someone review it and tell me things that I could add to it? Thanks in advance.
File graph.hpp
#include <vector>
#include <list>
using ...
3
votes
1answer
276 views
How to convert my classes to Dependency injection?
I am still learning to develop my skills in OOP.
It uses a combination of the factory and its real singletons?
As I did more research, I have realized this design pattern is bad because of global ...
3
votes
1answer
95 views
Fun with probability theory. Suggestions?
I want to play around with the Powerball lotto drawing history. What other probability theories could I try or what other probability class libraries exist. The code parses the file very quickly but ...
3
votes
1answer
513 views
How to improve Try…Catch Block for PDO?
I have written a PDO wrapper and a class file like a model. So far, it's looking so good! I am just confuse where I should put Try...Catch block - Would it be better to place in PDO wrapper ...
3
votes
1answer
116 views
Avoid explicitly writing base class state in a derived class. Suggestions for my method
I have two classes one base Foo class and one derived Bar class.
Each class has its own associated settings class that can create a new instance from the Load method. This way all derived class ...
3
votes
2answers
190 views
JavaScript (multiple) inheritance / mixins
I'm quite new to JavaScript, and I'm trying to understand the idea behind inheritance in JavaScript. I've read a bit about it, and I don't want to mess with prototypes (which I don't yet fully ...
3
votes
2answers
720 views
Authentication Class
I've wrote this class in PHP for my future projects:
<?php
/**
* Auth
* This class is used to securely authenticate and register users on a given website.
* This class uses the ...
3
votes
2answers
86 views
improve the design of class “accuracy” in Python
I am learning about the class and methods in Python.
The class Accuracy is a class of several (13 in total) statistic values between a reference polygon and one or more segmented polygons based on ...
3
votes
1answer
176 views
PHP, would this class pass the single responsibility principle?
I have a user class comprised of the code below. It has functions to insert a user, update a user, delete a user, look up a user, and search for users. What I'm wondering is if I this class would pass ...
3
votes
1answer
245 views
“Class” design in javascript
I'm a systems programmer teaching myself javascript. Prototypal inheritance is completely new to me, so I could use some best practices advice here.
I made a simple game (breakout) for my first ...
3
votes
1answer
31 views
Wanting to convert current code, to code that matchs coding practises
I've dabbled with PHP for a couple of years, I can generally get what I need done and I've been teaching myself PDO. The problem is I want to set it up with classes but i'm not really sure how to.
...
3
votes
1answer
179 views
Is my base class constructed correctly?
I have tables that use BulkManager to save data to database.
I moved common functionality to BulkTableBase. Because creation of BulkManager depends on params of each Table I create the BulkManager in ...
3
votes
2answers
117 views
Style comments please on my timer class, which I hope will be a pattern for other classes
I'm a relative noob to Python. On a range of 0 to 10, where 0 is a complete noob and 9 is Guido, I'd put myself as 1 aspiring to 2.
So I wanted a timer, rather like the Visual Basic object, and I ...
3
votes
1answer
789 views
C#: Simplfy code using Interfaces + business rules / validation
I have a workflow; within the workflow I can have many stages. I want to open and close a stage based on some business rules. E.g., stage 7 cannot be opened, because stage 5 + 6 need to be closed ...
3
votes
1answer
141 views
How do my improvements look? Any suggestions for improving the class?
I recently posted a thread looking for feedback on a script I wrote (see: How can I make the following code better, more efficient, shorter, elegant, etc? )
Since then I have re-written it into a ...
2
votes
3answers
196 views
Am I utilizing classes and OOP efficiently?
In my last question on Stack Overflow I was a very confused newcomer about classes and OOP and how to correctly implement everything to make things easier. So I started a different example to ...
2
votes
3answers
403 views
Is there a better way to do what I've done?
I've created the following class to persist data by serializing/deserializing objects that are sent to it. I would like to know if there is a better way of writing this class, or if my class is fine ...
2
votes
3answers
106 views
Python: How much logic is enough logic, and how much is too much logic in an __init__ method?
I am writing an email parser and cannot decide how much logic should be included in the __init__ function. I know, a constructor should make the object ready for use, but are there best practices to ...
2
votes
1answer
244 views
Help improve my first PHP class
I recently started to learn more about OOP in PHP and I created a website for testing. I have 4 classes: database, user, posts, comments.
This is a simple database.class.php:
class DB {
...
2
votes
2answers
115 views
Python class review - wiki api getter
First, I know there are other Python wiki API classes out there. I'm writing this one because I don't need all the bells and whistles, no edits, no talks, etc. I just need to be able to search for ...
2
votes
2answers
335 views
beginner's class inheritance question C# VB Visual Studio 2010
I understand the typical example of fruit as a base class and banana, orange, and pear as derived classes.
But what about when there is only one property in common?
Do you still use class ...
2
votes
2answers
2k views
How to improve performance in this database connection class?
This is my general database connection class. I am using this class to execute my queries through website. What would your suggestions about this to improve performance. Thank you.
MSSQL 2008 R2 SP1 ...
2
votes
1answer
386 views
Improve OOP code
I am learning OOP and have written a class for Likes. There is a load, add, delete method and I think this code can be improved since there is a lot of duplication. Please let me know how I can ...
2
votes
2answers
3k views
How do I make a generic class in VB.NET
I am been using a code pattern for recursive database actions in my applications.
I create two class objects of a database table, singular one (e.g Agent) for holding single record with all fields ...

