Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.
2
votes
1answer
34 views
Scope Resolution Operators and class variables in PHP OOP
I am new to this site, so I apologize if this question is not welcome. I am also new to OOP in PHP. I have done a lot of research on OOP and I keep seeming to read different opinions on several items, ...
1
vote
1answer
108 views
Getting familiar with OOP - Factories
I have no idea if I'm doing this efficiently, or ideally, but I've written what I think is a factory. Please help me understand if this is good practice, or if there is another direction I should take ...
6
votes
0answers
116 views
Thoughts on my brainfuck interpreter?
Had some free time this weekend and I hacked together a small Brainfuck interpreter, with the sole intention of explaining PHP's flavour of OO to a friend. This is a bit over-engineered on purpose, ...
-1
votes
1answer
81 views
Should I use inheritance in my case? [closed]
UPDATE - I write in C#. The code is added below.
I have 2 classes that should run a service when calling their Start method, but before it they should:
Copy items to F folder
Open S service in ...
2
votes
1answer
49 views
Merit of a “Search” class similar to a “Builder” class
I have a class something like the following:
class ItemManager {
List<Item> items;
public ItemManager() {
items = Database.retrieveItems();
}
}
An item has several ...
1
vote
2answers
95 views
Oriented-object approach on how to control different classes cleanly
I'm currently creating a client/server application (using Java) and I want to make it fully controllable by an input stream (currently the console). At the moment only one class have to be controlled, ...
1
vote
2answers
75 views
Which of these OOP examples demonstrate proper OOP concepts? [closed]
I'm still trying to wrap my head around OOP. All of the following examples work, of course, but is there one (or possibly another) that best exemplifies OOP concepts?
/**
* For the following ...
4
votes
2answers
102 views
Strategy Design Pattern in Python
I'm reading the awesome Head First Design Patterns book. As an exercise I converted first example (or rather a subset of it) to Python. The code I got is rather too simple, i.e. there is no abstract ...
2
votes
1answer
83 views
How to properly store error messages and display them with OOP?
I have a class that I am using to initialize a form for editing. Once the form is submitted, data validation is done through the setters of my class. Good or bad input will be set in order to ...
2
votes
0answers
61 views
Instantiating objects in a MVC in PHP
I am working on converting a PHP application to MVC, and have a couple questions!
1) I have a main Model object, that I require a database connection for, as well as a User object that uses a ...
3
votes
1answer
51 views
How to properly make a user class with a session
So I am working on a LMS project and I have a User class that will handle everything about the user such as registration, login, showing list of courses that they are subscribed to, etc.
...
4
votes
1answer
87 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 ...
3
votes
2answers
60 views
Review of OOP in Ruby class
Could you please review the following class products?
It should tell me whether the product is taxable or imported. Name should indicate if the product is imported or certain keywords should tell ...
0
votes
0answers
26 views
Making one object the property of another whilst avoiding scope issues
After being inspired by some MVC style design patterns, I have been trying to separate data from views in my code and move toward a more sensibly organized object based approach. (please, don't bother ...
3
votes
1answer
62 views
Design review for single master-multiple slaves component
EDIT:
I conclude I've failed to describe the problem.
Intro: Master-Slave Architecture
Master-Slave is a common hardware setting, in which multiple peripheral, passive components, are wired to a ...
0
votes
1answer
48 views
Instance of one class to contain arbitrary number of instances of another class in Python
I'm trying to see if there is a better way to design this. I have a class Animal that is inherited by Male and Female classes (Female class has an additional attribute). I also have a class called ...
1
vote
2answers
85 views
PHP Class Inheritance / Object Instantiation / Object / Property Scope w/ Child / Parent Classes & Dependency Container Class
In PHP, I have a parent/child class and am using dependency container to load them. I am trying to use the same database connection on all of them without duplicating the object.
CLARIFICATION: MY ...
0
votes
1answer
129 views
Object Orientated PHP, what's wrong with this implementation of OOPHP and how might it be improved?
I need some advice off the back of a question I posted on StackOverflow. I'm a procedural PHP programmer and I'm looking to make the move into object oriented PHP. I have started a small project that ...
2
votes
1answer
69 views
First steps with PHP OOP
I am learning OOP using PHP5 and I wrote two simple classes for receive data of database using dependency injection pattern and render a grid with Twig.
Please, if is possible, take a look and give ...
-1
votes
1answer
69 views
design classes for a JAVA swing application [closed]
I am very new in making JAVA swing applications..
My problem statement is to make a library management application,for which i designed classes as below.
Please tell me whether my design of classes ...
1
vote
1answer
207 views
Is this PHP class good enough for CRUD
I wrote this class to make it reusable in any project.
It uses PDO as the MySQL connection.
Beside not using Setters and Getters, is this code secure and good practice for CRUD ?
Thanks for further ...
0
votes
2answers
45 views
Consistent implementation of PHP class constants (arrays not allowed)
I'm currently writing a class:
final class MyTestClass {
const URL = 'http://www.example.org';
private static $MY_ARRAY = array('...');
// since this is not allowed
// const MY_ARRAY = ...
0
votes
2answers
107 views
Constructor with too many arguments [closed]
We have a Transaction class that's very loaded; so loaded that I originally ended up passing almost 20 argument to the ctor. After extracting a few value objects, there are still 12 arguments left, ...
0
votes
0answers
152 views
Good, flexible and secure MVC router PHP
I have developed a new router after having learnt a lot from my previous attempts and I will be using this in sites I make from now on.
In a previous question, the issue of REQUEST_URI being too ...
12
votes
7answers
1k views
How can I improve this OOP design? Is it even valid?
I designed this object for a "bread formula".
[Bread formulas use a concept known as baker's percentages, but you don't need to understand the math to help with the object design.]
I designed it as ...
7
votes
3answers
328 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 ...
0
votes
1answer
186 views
How to properly use OOP in PHP with forms
I am trying to wrap my head around how to properly use OOP in PHP when dealing with form submissions.
The example below is a form for editing course information. I have a class called Course which ...
3
votes
0answers
354 views
How can I do this the most pythonic way
I'm developing model for web application. The database that I use is Redis.
I created special DbField objects like HashDbField, SortedSetDbField, ScalarDbField and so on, for each data type in Redis. ...
3
votes
3answers
150 views
Beginner to OOP: Do these classes properly represent the objects in Java?
These classes are part of a program I am working on to convert Arabic numerals to Roman numerals and also the reverse. Do these classes look correct for representing objects in Java?
public class ...
1
vote
0answers
57 views
Circular Dependencies between Immutable Objects; the Freeze Pattern
Generally, I structure small threadsafe immutable objects like this:
public class SmallObject {
private final String state;
public SmallObject(final String state) {
this.state = ...
3
votes
2answers
83 views
Nice design of my hash service class
I would like to know, if my design of this class is good OOP.
Should I implement for every hash algorithm a separate class?
I'm asking this, because the HashService can be used with a ...
2
votes
1answer
118 views
Have I implemented the command pattern correctly?
This is my command interface
public interface IConverter {
void convert();
}
This is my Receiver class
public class Ogg extends Audio{
private File src;
private File trgt;
...
5
votes
2answers
179 views
Typesafe Tic-Tac-Toe API
So I've been working on Tony Morris' Tic-Tac-Toe challenge. The rules are as follows:
Write an API for playing tic-tac-toe. There should be no side-effects
(or variables), at all, for real. The ...
2
votes
1answer
147 views
How to make this PHP code more object oriented and less scripted
I am utilizing CodeIgniter's Pagination Class to implement pagination in the project.
In this project, there are 3 modules: Event,Business & Parts.
Each Module has same "view" for pagination. I ...
0
votes
1answer
38 views
Actionscript 3.0, good OOP?
I have been coding for some time (3 years I think), and have recently been wondering if my coding pattern is any good. Any kind of feedback is welcome:
EDIT: The thing that concerns me most is that I ...
4
votes
2answers
252 views
How is my BlackJack game design?
This is command line BlackJack game created in Java as my final project for advanced programming class...
What do you think about it?
Have I used OOP correctly?
What grade should I get for this? :D
...
3
votes
2answers
1k views
Small MVC for PHP
The following is a new question based on answers from here: Small PHP MVC Template
I have written a small MVC template library that I would like some critiques on.
The library is located here
...
1
vote
2answers
111 views
Nesting multiple objects vs referencing them
After experimenting with different design approaches for the past two years, I've created a library for managing and processing dynamic content to be displayed on a single HTML view. This library is ...
3
votes
2answers
102 views
php oop sample pattern
i just started to practice coding in oop these days,
just wanted to ask if my code has a correct pattern.
i need your comments or suggestions so i can improve it,
thanks you guys for your patience and ...
1
vote
1answer
58 views
Inherit SortedDictionary - Is this good programming practice?
Also posted on Stack Overflow
As an example, suppose I had a large amount of data about a set of Restaurants for a large set of Dates in a database that I need to analyze / output to the user.
So, ...
1
vote
1answer
40 views
Using static for class default properties
I have made a class for generating html form elements:
class input
{
public $tag = 'input', $type = 'text', $customClass, $name;
public function __construct(array $cfg){
if ( ...
3
votes
3answers
111 views
Python Time Class definition and methods, use of __init__
I've written a Time class that records the time of day and performs simple timing operations (add 2 times, convert a time object to an integer and back again,etc.) following the prompts in How to ...
2
votes
2answers
170 views
Best Practice: Learning PHP OOP
I am learning PHP OOP. I am familiar with PHP, and limited use of OOP, but not writing OOP. I have a small successful website that uses large associative arrays but is now suffering performance ...
1
vote
1answer
188 views
PHP Currency Conversion class with caching
https://github.com/Prashles/PHP-Currency-Convert-Class
<?php
/*
*
* PHP Validation Class
*
* The currency rates are fetched and cached for the whole day
*
* http://prash.me
* ...
0
votes
1answer
69 views
Review: Finished router class for custom mini framework
I have finished my router and would like your thoughts on anything that may be inefficient of could be done better!:
class Router {
public $start_page = 'Dashboard' ; // Change to your home/default ...
1
vote
1answer
68 views
File loop and logic in controller of view header?
I have the following in the header.php file which is included in all of my views:
$dh = opendir(Vs.get_class($this).'/js') ;
while($script = readdir($dh)) {
if(!is_dir($script))
{
...
1
vote
1answer
110 views
OO PHP, requesting a look if good practice
I'm starting with OOP for php, i get the idea, but don't have someone physical near me to fallback on so I'm hoping i can do that here.
The following works but i would like to know if it's good ...
1
vote
1answer
94 views
Factory pattern for getting xml data
i am trying to implement factory pattern for getting XML Document from server
(using javax.xml.parsers.DocumentBuilder)
I have the classes below for now, could you give your opinion ? Does the ...
2
votes
1answer
116 views
Please review my classes - Database, User and Validator
I am very new to OOP and I am sure this code is very, very bad. I will appreciate if you review my classes and give me some advice to improve them. Any recommendations are welcome. I have also put ...
3
votes
1answer
167 views
Optimize PHP Class
I'm looking for a better way to provide configuration options and improvements in general. I'm using the constructor injection pattern to get access to the Cache and Twitter class. $callback and ...