A design pattern is a general reusable solution to a commonly occurring problem in software design.
5
votes
1answer
64 views
Please review following code
Please review the following code. Methods getFirsts and getSeconds return a list of objects which implement CommonInterface and both of them are private. Is it a good or bad design.
@Override
public ...
3
votes
4answers
92 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 ...
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
1answer
49 views
Is my DSL good idea to replace builder pattern?
I want to build a set of builders for generating test data. On one side I want my builders API to be natural to use for my teammates. On the other side I'm great fun of creating DSLs, because it ...
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 ...
6
votes
3answers
167 views
Best Ruby one-liner to generate a random alphanumeric string
This is a little arbitrary, but I'm curious what people might come up with. I want to generate a random alphanumeric string in ruby, as succinctly and efficiently as possible.
([nil]*8).map { ...
5
votes
2answers
96 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 ...
3
votes
1answer
50 views
Some issue within enabling/disabling logic [closed]
I wanted to enable/disable an Ok button on my form if some text boxes are not empty, so I tried to use Observer pattern in the following way but something sneaky is wrong with the way I am using it so ...
3
votes
1answer
122 views
A base class to handle mapping between entities and view models
I'm working on a fairly mundane ASP.NET MVC app that allows users to do basic CRUD operations on a number of different domain objects. I'm trying to minimize duplicate code and boring, monkey code as ...
4
votes
1answer
112 views
How to improve this design?
I have some design doubts regarding my controllers and I would like some advice...
Everything works. However, I'd like to improve it.
Basically I have one controller per screen(Swing).
I have created ...
4
votes
1answer
107 views
OOP: Need tips of my approach in .Net
I am looking for some different approaches to this following OOP scenario.
Dim pb As Object = Nothing
If radCars.Checked = True Then
Dim productBase As ProductsBase(Of CarColumns)
...
2
votes
5answers
52 views
Need a better pattern to solve an unwieldy function
I have a simple inheritance framework
class BaseValidator
{
protected virtual void Validate()
{
// Base validator code .....
}
}
class PhoneValidator:BaseValidator
{
public ...
3
votes
1answer
142 views
Tips for Making this Code Testable
So I'm writing an abstraction layer that wraps a telephony RESTful service for sending text messages and making phone calls. I should build this in such a way that the low-level provider, in this case ...
1
vote
2answers
101 views
Correct GenericDAO implementation?
I implemented a MVC Framework with Generic DAO and I would like know if is correct. I did not have developed yet the MySQLDAO.
My controller class
class ClienteController {
public function ...
4
votes
1answer
237 views
Unit Of Work/Repository usage
In a project I'm working on, the data access layer has evolved to something that somewhat resembles the Unit Of Work and Repository patterns, at least they started with those names, I'm not entirely ...