Questions tagged [object-oriented]
Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.
3,786
questions
1
vote
1
answer
98
views
php autloader class reviews welcome
is this class ok? any and all advice very welcome. Would it be better to pass the config file path array into the constructor or even through the static register method
...
10
votes
1
answer
1k
views
Object Oriented programming in lua in a functional fashion
I've discovered (and written) a way to object oriented programming in lua in a functional fashion instead of the standard metatable method. It carries much more functionality (no pun intended) but I'm ...
0
votes
2
answers
133
views
Creating and populating a generic list
I would like to know if this is being done correctly.
...
1
vote
2
answers
7k
views
PHP Class that handles all includes / required files
In effort to streamline applicable PHP file include or require functions I thought that making a class to handle this might be a ...
2
votes
1
answer
2k
views
Timer class in PHP OOP
I have done a lot of research on OOP and I keep seeming to read different opinions on several items, especially the scope resolution operator (::) and handling ...
1
vote
1
answer
226
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 ...
21
votes
1
answer
663
views
Thoughts on my brain fart 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
1
answer
139
views
Should I use inheritance in my case? [closed]
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 remote server if it'...
2
votes
1
answer
70
views
Merit of a "Search" class similar to a "Builder" class
I have a class something like the following:
...
2
votes
2
answers
827
views
Suit class for card game
I'm trying to make a card game, using OOP style. I decided to make suit a class rather than an enum as I would first have done. How am I doing so far? Am I over-...
0
votes
2
answers
146
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
2
answers
2k
views
Dynamically create object
I am developing a web-application and I am encountering some trouble :
I have some tabs and each one contains input forms with different values. I need to switch beetween these tabs and see the ...
5
votes
2
answers
812
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
1
answer
3k
views
Properly storing error messages and displaying 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 re-...
2
votes
1
answer
1k
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 ...
4
votes
1
answer
255
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.
User.class....
7
votes
1
answer
7k
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
2
answers
87
views
Determining if a product is taxable or imported
This should tell me whether the product is taxable or imported. Name should indicate if the product is imported or certain keywords should tell that the product is non-taxable (chocolates, book, pills)...
2
votes
1
answer
56
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 ...
0
votes
1
answer
120
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 ...
3
votes
0
answers
136
views
Hooks class for basic plugin functionality
I've built a small hooks class for adding some capabilities of basic plug-in functionality.
Is there room for improvement? I am just beginning to learn OOP. I ...
1
vote
2
answers
1k
views
Using a dependency container to load a parent/child 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.
I used ...
0
votes
1
answer
385
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
1
answer
317
views
Receiving data from a database
I am learning OOP using PHP5 and I wrote two simple classes for receiving data from a database using the dependency injection pattern and rendering a grid with Twig.
Does this code have sense for OOP ...
3
votes
0
answers
922
views
Testing Scala code which depends on objects
I am writing a small oauth2 library for Play! 2.1 scala. As I am still learning I got stuck trying to TDD and ended up writing the code first, then refactoring for testability. By testability I mean ...
1
vote
1
answer
3k
views
Reusable project 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?
...
2
votes
2
answers
3k
views
Consistent implementation of PHP class constants (arrays not allowed)
I'm currently writing a class:
...
2
votes
1
answer
310
views
Small web application
I'm building a small web application and it's starting to get a bit complex. I have reached to a point where I have to run some tests and load some libraries.
I made it so I can use it in this way:
<...
2
votes
1
answer
1k
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 ...
14
votes
7
answers
3k
views
Bread formula object
I designed this object for a "bread formula". They 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 an object (of ...
8
votes
3
answers
900
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:
...
2
votes
1
answer
14k
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
1
answer
449
views
Model for web applications
I'm developing a model for web applications. The database that I use is Redis.
I created special DbField objects like ...
6
votes
3
answers
4k
views
Converting Arabic numerals to Roman numerals
These classes are part of a program I am working on to convert Arabic numerals to Roman numerals and vice-versa. Do these classes look correct for representing objects in Java?
...
6
votes
1
answer
472
views
Circular dependencies between immutable objects; the Freeze Pattern
Generally, I structure small threadsafe immutable objects like this:
...
3
votes
2
answers
453
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 ...
2
votes
1
answer
665
views
Ogg audio format conversion classes
This is my command interface:
public interface IConverter {
void convert();
}
This is my Receiver class:
...
4
votes
3
answers
597
views
A method to insert a database entry for a newly registered account
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.
...
5
votes
2
answers
823
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 ...
4
votes
2
answers
457
views
Rendering articles with breadcrumb navigation
I'm wondering if perhaps I am doing this all wrong:
Questions:
How is my OOP?
Is it running multiple methods on a value {i.e.: is ...
3
votes
1
answer
888
views
Implementing pagination with three modules
I am utilizing CodeIgniter's Pagination class to implement pagination in the project.
In this project, there are 3 modules: Event, Business and Parts. Each Module has the same "view" for pagination. ...
0
votes
1
answer
131
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 ...
8
votes
2
answers
13k
views
How is my BlackJack game design?
This is a command line BlackJack game created in Java as my final project for an advanced programming class.
What do you think about it?
Have I used OOP correctly?
What grade should I get for this? :...
3
votes
2
answers
2k
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
If ...
2
votes
2
answers
2k
views
Nesting multiple objects vs referencing them for a slot machine
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
3
answers
2k
views
Search form sample pattern
I've just started to practice coding in OOP and just wanted to ask if my code's pattern is correct. I need your comments or suggestions so I can improve it.
sample_class.php:
...
2
votes
1
answer
397
views
Inherit SortedDictionary
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.
I have a custom class that holds the ...
1
vote
1
answer
78
views
Using static for class default properties
I have made a class for generating html form elements:
...
3
votes
3
answers
6k
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
2
answers
4k
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 ...