Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.
3
votes
2answers
102 views
Making my program OOP
I have created a program that allows the user to view/add/delete employees and also view employee payslip either weekly employee or monthly employee and this is all done in the console. My programme ...
4
votes
3answers
191 views
Win Forms design pattern
I am writing a dice roller win forms application using C# 2012 VS. Dice roller is set up for playing Shadowrun table top. I feel that there might be too much code going into the GUI, but I am unsure ...
2
votes
3answers
105 views
How object oriented is my Crazy Eights game?
I have this Crazy Eights game (which at the moment does not include crazy cards):
class Card(object):
RANKS = ("2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A")
SUITS = ("c", ...
2
votes
0answers
34 views
Double click to edit and add new value to li
$(document).on('dblclick', '#li', function () {
oriVal = $(this).text();
$(this).text("");
input = $("<input type='text'>");
input.appendTo('#li').focus();
});
...
0
votes
1answer
54 views
Cleaning up PHP object constructors
I have this annoying problem in PHP with faking overloading constructors. I understand the concept, but the code I produce feels kind of ugly. It isn't a lot of code, just bad code. Any ideas on how ...
0
votes
2answers
92 views
Q&A minigame structure
I've decided to improve / test my knowledge so far, as I haven't coded in Java for a while now. Is there anything I can improve in my code? The OOP structure? The code itself? Useless code?
...
3
votes
3answers
110 views
Critique of Code Regarding OOP Principles
I was wondering if anyone could give a critique of my code. We are supposed to be using inheritance and OOP principles. All the functions but the PlayerSet class were given, so really I just need ...
2
votes
1answer
45 views
Kings Drinking Game Review Request 2.0 JForm GUI
This Request is a new version of this Request
This version has a custom JForm GUI and almost all new methods.
GUI:
I wrote a program to simulate the drinking card game Kings, now with a JFrom ...
1
vote
3answers
29 views
Refactoring based on OPEN CLOSE PRINCIPLE- C#
I have some code to write Error Logs to different places like Console/SignalR Messages/Text File.
The code is as follows:-
public class Logger
{
public void WriteToLog(string message, ...
4
votes
1answer
99 views
Object Oriented JavaScript optimization
This is a simple script that I use for wrapping a selected word in a textarea field. I'm looking to:
make sure my logic is valid/see what others have done in a relative context.
request ...
1
vote
2answers
73 views
OOP Challenge in Python
I was trying to solve the final puzzle at the end of the classes chapter (Chapter 8) in "Python Programming for the Absolute Beginner" which is stated as:
Create a Critter Farm program by ...
1
vote
1answer
55 views
Call all methods in the interface [closed]
I have an interface and I need to call all methods in this interface:
My interface design:
public interface ICar
{
MoveLeft();
MoveRight();
MoveLeftRight();
}
This code is injured the SRP ...
1
vote
0answers
52 views
Basic structure of a simple php REST api
I've read plenty about php OOP design principles and patterns. I can work with classes and inheritance. My issue is with actually using classes for some purpose. In this case, I want to create a ...
3
votes
2answers
80 views
Game Of Life OOP Python
This is pretty much an OOP version of this question, with the improvements:
import copy
import shelve
class GameOfLife(object):
def __init__(self, board, generations = 10):
self.__board ...
4
votes
2answers
149 views
Random password generator
I just wrote my first Java class, and I wanted to share it with you and maybe get some quick check from more experiences coders than I am.
I want to learn OOP, Java is just the tool I thought was the ...
4
votes
4answers
137 views
Tic-tac-toe Design
Kindly look at this code and point out design flaws or areas for improvement. I think I've done the last part right the enum. I think the rest of the design is flawed but I am very new to object ...
3
votes
2answers
59 views
Help me improve my Hangman app
I just created a Hangman app (same game mechanics mostly) using Java. I did this mainly to test my knowledge in OOP design/coding. I'd like to know your thoughts on my code
The whole project is on ...
5
votes
1answer
87 views
Writing an effective method that reflects good OO design and fixes this broke method
I'm working on my personal project and have recently had a bit of trouble with a method I wrote during the week.
This method compares user input from the same JComboBox. A before and after, if you ...
1
vote
1answer
23 views
Throwing error if settings / arguments are undefined is this a good breakout function?
var _ = require("underscore");
var checkSettingsUndefined = function(settings){
if(_.isEmpty(settings)){
throw new Error("settings are empty");
}
}
var Class = function(settings){
...
1
vote
2answers
102 views
Proper usage of OOP PHP
I am new to the OOP world I have been reading as much as I can about it and have never been more confused. I understand that its great for organizing code and making it more maintainable, etc. I have ...
0
votes
1answer
162 views
Java Fraction Class - Adding Together Two Objects [closed]
I'm currently working on a fraction class. I've successfully figured out how to create a fraction object as well as check for errors but I've blanked and cannot figure out how to add together the two ...
2
votes
3answers
66 views
OOP Class properties automatically
One of my friend made a framework.
He made an abstract class, called NullObject (see below).
For his convenience, hid does this, so when he want to build an object from database, just inherit this ...
3
votes
1answer
103 views
How can I improve my game project design?
I'm just getting started with XNA and game development in general. I followed these instructions to create a basic game, then this article to get sprite animations working.
Now, I'm trying to ...
2
votes
1answer
69 views
How to put XML results in the MVC pattern?
I have been writing PHP programs in the MVC pattern for quite some time. But I am not sure if I am doing it right.
For instance, I have this PHP file that prints a result in XML, and I put this file ...
6
votes
4answers
162 views
Object's responsibility - how to determine what functions should be implemented in the class?
Long story short, I would like to use OOP for my new PHP project. It has a "login" requirement, ie. user will first need to enter the username and password (login.php), if it's correct, it will be ...
2
votes
2answers
90 views
Object-oriented command processor
I really need a review on the structure, and how things are done. I want to improve.
Command.class:
<?php
/**
* Command
* Processing commands to the server, acting, receiving ...
1
vote
1answer
117 views
Critique my PHP Cookie class?
I wrote this class to make cookie management easier.
I know it makes use of serialize(), but I have no intention of storing very much data in the cookie, and it seemed a cleaner solution than, say, ...
5
votes
4answers
414 views
Simple class - returns true if even number of items, false if odd number of items
This is my first C++ program with classes, and I don't want to develop bad skills. It's very simple. It consist of 3 files.
Please tell me if it's proper or not!
parity.cpp file:
#include ...
1
vote
0answers
99 views
Object-oriented Linux networking library
I needed to perform network communications in my Linux C++ project. I thought that it was a good idea to operate on a higher level of abstraction than raw system calls. Also I love OO design. So I'm ...
0
votes
1answer
51 views
Why isn't it giving me a color for my apple? [closed]
This is not homework; just an exercise I'm doing on my own.
In my main:
apple j = new apple();
j.Flavor = "sweet";
j.Color = "green";
Console.ReadKey(true);
In a class:
using System;
using ...
3
votes
3answers
189 views
How to start with OOP JavaScript
I've been learning JavaScript for about 8 months now. 5 months ago, I found job as a Front End developer and I've been getting more deeply involved with JavaScript (which I love).
Recently, I've ...
1
vote
1answer
116 views
Scrapy — Very Procedural — Better Alternatives?
class PropFinal(CrawlSpider):
name = "propfinal"
allowed_domains = [over 200 allowed domains here]
start_urls = ...
1
vote
1answer
73 views
File Downloading, Unzipping and extracting Content - PHP script and tests
EDIT. Here is the new version after bumperbox's very helpful suggestions.
I was thinking or renaming into Downloader or something but the problem is, I see downloading is performed at lower level of ...
0
votes
1answer
40 views
Android get multiple inputs from single EditText
userInputs.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) ...
-1
votes
1answer
2k views
Small PHP Framework. Almost one year later
The following is a new question based on answers from here: Small MVC for PHP
I have written a small template library that I would like some critiques on.
The library is located here
If you are ...
3
votes
4answers
114 views
Is this a qualified OOP script in PHP?
class Youtube
{
private $url = null;
private $id;
public function __construct($url)
{
$this->url = $url;
$this->parseUrl($url);
}
protected function ...
2
votes
2answers
83 views
designing application using polymorphism
I have created a polymorphic system, but I don't know whether this is the correct way of doing it. Am I abusing Polymorphism here? Here is the code:
class WriteObj
{
public string Obj1 { get; ...
1
vote
2answers
191 views
Designing classes and methods for hospital management system
I am working on hospital management system project. I have implemented it using the following design. Is it a good design?
I have created four classes: Patient, Doctor, Hospital, and Demo. Inside the ...
2
votes
1answer
41 views
More simplified way of creating page links dynamically?
A little birdie suggested I bring this question here, so here it goes.
Well I have a working script (see below) but it seems quite clunky and redundant; in my defense I wrote this code many moons ...
3
votes
2answers
221 views
I am applying for Object Oriented PHP jobs. Can I please get a general review of my OO skills?
I am new here, so hopefully it is ok to post a link to my github account where I am storing my code samples.
https://github.com/arthaeus/war
This particular sample is the card game 'war'. The ...
2
votes
0answers
42 views
Is this a good WP Post Type template script?
I have created this class for my WP theme, it allows you to create templates for a meta box which relates directly to a custom frontend template to have better control of the content displayed on the ...
7
votes
1answer
87 views
Is this code good to implement encapsulation with jQuery?
First of all: I know there are already other questions about oop/jquery, but this one is about the following specific code.
2ND: I'm and advanced mootools and AS3 programmer, so I'm used to 'regular' ...
2
votes
1answer
142 views
How to separate code into smaller classes using SOLID principles
I have a console application that basically retrieves xml content, writes to the xml file and sends the file to sftp site. This may seem long post but I believe it is simple stuff that need advise on ...
0
votes
0answers
95 views
Is my Javascript Object Oriented?
This was my first attempt at writing object oriented Javascript. It's a minesweeper clone in JQuery. I thought I had done an ok job, but I just received some feedback that it wasn't written in an ...
1
vote
1answer
37 views
__constructor mysqli variable options
I like the fact that I can create a class and have the connection details in one file if I need to update them and then pass them to the method I create in the class that defines my specific use of ...
2
votes
2answers
91 views
How to get two JavaScript classes to talk to each other?
I'm a budding JavaScript programmer, working on an exercise where I'm trying to create two classes (Books and Shelf) and need to have a shelf know what books are on it. I'm pretty new to OOP so I know ...
2
votes
3answers
108 views
Did I Needlessly Complicate This Function?
Background:
We're using a class called Places (inspired by Allen Holub's great article on DrDobbs) that resolved our program paths based on the existence of a configuration file, environment variable ...
4
votes
3answers
306 views
How to refactor C# class to meet SOLID priniciple
I need to refactor following class:
public class Message
{
public Guid ID { get; set; }
public string MessageIn { get; set; }
public string MessageOut { get; set; }
public int ...
5
votes
2answers
180 views
Minimalistic mysql db class
I am really just looking to make sure I am not making any weird mistakes that could hurt me in the long run or if something seems odd in the way I imagine it to work. This code does work for the way I ...
0
votes
0answers
92 views
Understanding OO JavaScript with a simple scenario
Coming from a Java kind of OOP, I miss a lot of things in JavaScript. I am working on a Node.Js project, and I would like to use an OO approach.
Looking around and asking in StackOverflow I came up ...