A design pattern is a general reusable solution to a commonly occurring problem in software design.
2
votes
3answers
75 views
Design Strategy of CSV Parser
I wanted to review my design strategy for CSV parser.
I have 4 CSV files, which have different layouts as shown below.
Each row of a CSV file will be mapped to a class. For example, if CSV_FILE_A has ...
3
votes
2answers
74 views
Design Pattern Question/Violating OCP
Is there a design pattern I can use for a situation like below. This is an example I made up to try and explain the situation I'm dealing with currently. I keep having to add new DeviceScript ...
1
vote
1answer
94 views
Code review for an abstract repository implementation
I have a repository abstract class that encapsulates pretty much all of the CRUD functionality:
public abstract class DataRepository<T> : IRepository<T>
where T : class
{
public ...
2
votes
1answer
71 views
Review of simple Java Actor library
Please help me find something wrong with this!
Actor.java
package com.benbria.actor;
public interface Actor<T> extends Runnable {
public abstract void send(T msg) throws ...
6
votes
2answers
116 views
Handle static objects using custom adapter
I have read some articles discussing about why static is bad, some of them refering static as not-testable, non-mockable, has state (non-stateless) and everything else.
However I have encountered ...
-1
votes
1answer
109 views
please review my switch case code
Now I hava a enum param and wants to do something which is acording to the enum param value.
While the enum param is too much and my method will become too long.How can I refactor my code?
I know ...
0
votes
1answer
64 views
Q&A system model design [closed]
Now I am trying to build a Q&A website by myself.The models below is my model design.I have some questions about this.
1、class Category:
public class Category {
private String name;
}
...
4
votes
1answer
130 views
How do I make this code unit-testable?
I have a functionality that imports data into a database, based on an Excel workbook and some meta data (both user-supplied). The functionality implements interface IFunctionality which essentially ...
1
vote
2answers
60 views
Null Object pattern with simple class hierarchy
I have a simple two-class hierarchy to represent U.S. ZIP (12345) and ZIP+4 (12345-1234) codes. To allow clients to allow both types for a field/parameter or restrict it to one type or the other, the ...
2
votes
1answer
51 views
Design with Context, Table and Functions
Each class of my project has several inputs and outputs. Each input, the same as output, depends on it's own set of value-datatype.
I need to provide a mechanism to forward data streams from one ...
0
votes
0answers
11 views
Is it acceptable for child classes to “break” parent class functionality? [migrated]
One of the devs that works with me is following the Open/Closed Principle to add functionality to a Model by extending from our framework ORM.
class BaseModel extends ORM {
...
}
All our models ...
2
votes
2answers
60 views
Objects and instance variables in loops
Is there anything wrong with doing this:
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For value As Integer = 0 To 1000000
...
-1
votes
1answer
74 views
Single Responsiblity Principle with polymorphism question [closed]
So I'm somewhat new to the Model View Presenter design for testing my GUI. So far I really like it because now I can actually test my GUI's behavior instead of just having the "test" open up a ...
3
votes
1answer
68 views
Encapsulated double for type safety
Link to a full functional solution.
I'm working on a physics based algorithm, and I find myself working a lot with functions of style
double GetSpeed(double acceleration, double angle, double ...
0
votes
1answer
59 views
how do I encapsulate this List<Message> properly?
I know that Swing isn't true MVC:
Using this modified MVC helps to more completely decouple the model
from the view.
Leaving aside the veracity of the above claim, the problem I run into is ...