Tagged Questions
10
votes
2answers
566 views
UI repetitive code - what pattern to use?
I have two different windows forms project which contain forms with similar UI/code. For example, I have several forms that have 98% code tha same, the only difference is that one they call different ...
8
votes
2answers
585 views
Improve a OOP design
I'm having a hard time creating a design (due to my lack of experience). I need a little of help to create the Model.
It's a mathematics system. I've created an IProblem interface with a function ...
5
votes
2answers
118 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 ...
5
votes
1answer
104 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 ...
5
votes
1answer
164 views
Design issues, tendency to write custom methods
I seem to have this tendency to write custom methods, i.e. code that isn't reusable. The following seems to be one example of trying to do too much in a single method.
But the point I'm not sure ...
5
votes
2answers
238 views
Does this code fall into a design pattern?
CustomDialog is the parent abstract class for OkExclamationDialog and ExclamationDialog with abstract method displayDialog() being overriden.
Does this fall into a design pattern? Can this design be ...
5
votes
1answer
665 views
How to improve my factory design?
I'm creating a factory design for math problems. The purpose of the factory is:
When the factory initializes, creates in a list some problems (20 initially)
If the program wants more than 20, the ...
5
votes
1answer
1k views
Generic C++ Factory
For my project I needed a way to instantiate different object types during runtime using "string names", for this I designed a generic factory that is created for each object hierarchy type (currently ...
4
votes
1answer
305 views
Is this a good design for a Factory Pattern?
I'm creating a system to generate math problems. As you know in mathematics, there are milles of kinds of problems: Binary problems, fractions, decimals, comparating two numbers, etc.
I'm creating an ...
4
votes
1answer
339 views
Providing factory method to Lazy<T> when factory exists on another lazy instance?
The Problem
I found myself needing an instance of an IObjectContext interface that should never be null, but wanting to delay instantiation until after some required resources have been loaded.
I ...
4
votes
2answers
965 views
Review request - sales tax problem
Please review the sales tax problem which has been designed using strategy pattern...
The Problem:
Basic sales tax is applicable at a rate of 10% on all goods, except books, food, and medical ...
3
votes
4answers
134 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 ...
3
votes
3answers
289 views
Class design and Liskov Substitution Principle
I'd like to decouple these two classes and still maintain substitution. I find that when dealing with pointers to Sprites I always use GetFrameWidth and GetFrameHeight instead of GetWidth and ...
3
votes
1answer
160 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 ...
3
votes
1answer
113 views
How to model this design: BinaryProblem
I'm creating a model for Math Problems. This contains always two properties, and has a CorrectResult method which returns the addition of the two numbers. The propeties data types can be decimal, int, ...