Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.
3
votes
2answers
48 views
Can this class be improved?
I have this class whose code I pasted in full. The CredentialsManager class is not shown here as all it does is return the DB connection variables. My question is if this class can be improved or if ...
3
votes
4answers
93 views
Refactoring a class hierarchy to remove subclasses
I have the following class inheritances hierarchy:
First the abstract parent class:
<?php
abstract class SegmentParserAbstract{
/** @var ParserResult */
protected $_result;
protected ...
2
votes
2answers
82 views
Basic Database Class with PDO functionality
Is my following (very basic) class considered good use for PDO integration?
Or is there a better, more efficient way?
class Page {
public $title;
public $db;
public function ...
2
votes
0answers
22 views
Validation and Error Generation when using the Data Mapper Pattern [migrated]
I am working on saving state of an object to a database using the data mapper pattern, but I am looking for suggestions/guidance on the validation and error message generation step (step 4 below). ...
0
votes
0answers
10 views
How far should an entity take care of its properties values by itself? [migrated]
Let's consider the following example of a class, which is an entity that I'm using through Entity Framework.
- InvoiceHeader
- BilledAmount (property, decimal)
- PaidAmount (property, ...
3
votes
3answers
94 views
PHP Simple OOP Class
I am still learning OOP and I need a little help, I don't really know how to properly make this not look so terrible.
Any thoughts?
<?php
class Noti {
public static $app;
public static ...
1
vote
1answer
63 views
Is this a good JavaScript class?
I'm trying to get my head around object oriented programming, and I'm starting in JavaScript. I have put a working demo of my code on JSFiddle (here), but the class is below.
My main concerns are ...
5
votes
1answer
95 views
Basic OOP & Solution Design
I had an exercise as below for an interview. I used two design patterns: factory and decorator. I put my code at the end of it.
How could I improve the solution?
Basic OOD & Solution Design ...
2
votes
0answers
49 views
Needs code review for class implementation
could you please review the code for the implementation of the class (link: Ruby. Code review. Working alone on the code)
require_relative 'robot'
class Game
def initialize
# initialize values
...
0
votes
1answer
54 views
Ruby. Code review. Working alone on the code
I'm working alone on my code, trying to learn Ruby as I go.
Class Robot is supposed to be instantiated with the position on a map, and whether it is facing toward a side of the map. It has a couple ...
4
votes
2answers
118 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 ...
3
votes
1answer
124 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 ...
5
votes
2answers
97 views
When an object has different representations… what's the OO pattern?
I've an AbstractMessage object (a hierarchy, actually). It represents a small text message and can be sent using different transport methods: HTTP, REST and a "mailer" transport. Each transport relies ...
4
votes
1answer
50 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 ...
3
votes
1answer
56 views
Javascript PriorityQueue based on object property
I am pretty new to javascript development and its temperaments. I wrote this class which is a priority queue based on a numeric property of any object. As far as I can tell, the following code is ...