I have a few classes in my current project where validation of Email/Website addresses is necessary. The methods to do that are all the same.
I wondered what's the best way to implement this, so I don't need to have these methods copy pasted everywhere?
The classes themselves are not necessarily related, they only have those validat...
Hi,
When using Persistence frameworks like Hibernate, JPA etc. on the server side, what are the general practices of passing on the data between client and server ? Are there any existing design patterns for the same ?
Thanks.
...
Well i need some help here i don't know how to solve this problem.
the function of the attribute is to determine if the function can be run...
So what i need is the following:
The consumer of the attribute should
be able to determine if it can be
executed.
The owner of the attribute should be
able to tell the consumer that now it
can...
I am trying to use a factory pattern to create a QuestionTypeFactory where the instantiated classes will be like MultipleChoice, TrueFalseQuestion etc.
The factory code looks something like this
class QuestionFactory {
public enum QuestionType {
TrueFalse,
MultipleChoice,
Essay
}
public static Question ...
Hello,
How do we model these objects ?
Scenario 1: Price changes in a time period
EffectiveDate ExpiryDate Price
2009-01-01 2009-01-31 800$
2009-02-01 Null 900$
So, if the price changes to 910$ on 2009-02-15, then the system should automatically update the expiry date on the previous effective price to 2009-0...
I have defined an Event class:
Event
and all the following classes inherit from Event:
SportEventType1 SportEventType2 SportEventType3 SportEventType4
Right now I will only have SportEvents but I don't know if in the future I'll want some other kind of events that doesn't even have anything to do with Sports.
Later, I will want to...
What is the difference between Activator.CreateInstance and factory? Can they be used interchangeably? Or stil do we need a factory pattern?
...
hi,
I am developing a class library (C#) that i will use it for my different projects (later). My class library dll will use the connection string /data context of the project which will reference my new dll. How can i do it?
Lets say i have a class Library Project named "CLP", and a website project "WP". I can add reference to CLP.dll f...
I've got a common task that I do with some Activities - downloading data then displaying it. I've got the downloading part down pat; it is, of course, a little tricky due to the possibility of the user changing the orientation or cancelling the Activity before the download is complete, but the code is there. There is enough code handli...
Hi all.
Let's look at this code:
IList<IHouseAnnouncement> list = new List<IHouseAnnouncement>();
var table = adapter.GetData(); //get data from repository object -> DataTable
if (table.Rows.Count >= 1)
{
for (int i = 0; i < table.Rows.Count; i++)
{
var anno = new HouseAnnouncement();
anno.Area = float.Parse(tab...
Consider the following code
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
public static Singleton Instance { get { return instance; } }
static Singleton() {}
private Singleton() {}
}
Question
1) Here what is the purpose of static constructor ? (I know static cons...
How would I be able to accomplish the following:
public class testClass implements Interface {
public testClass(Interface[] args) {
}
}
So that I could declare
Interface testObject = new testClass(new class1(4), new class2(5));
Where class1 and class2 are also classes that implement Interface.
Also, once I accomplish th...
I will use (again) the following class hierarchy:
Event
and all the following classes inherit from Event:
SportEventType1 SportEventType2 SportEventType3 SportEventType4
I have originally designed the Event class like this:
public abstract class Event
{
public abstract EventType EventType { get; }
public DateTime Time { ge...
Suppose you had code like this:
_READERS = None
_WRITERS = None
def Init(num_readers, reader_params, num_writers, writer_params, ...args...):
...logic...
_READERS = new ReaderPool(num_readers, reader_params)
_WRITERS = new WriterPool(num_writers, writer_params)
...more logic...
class Doer:
def __init__(...args...):
...
...
I'm designing an application that will allow me to draw some functions on a graphic. Each function will be drawn from a set of points that I will pass to this graphic class.
There are different kinds of points, all inheriting from a MyPoint class. For some kind of points it will be just printing them on the screen as they are, others ca...
I have been trying to write my first big web app (more than one cgi file) and as I kept moving forward with the rough prototype, paralelly trying to predict more tasks, this is the todo that got accumulated (In no particular order).
* Validations and input sanitizations
* Object versioning (to avoid edit conflicts. I dont want hard lock...
I have a 3rd party control which among other things performs loading of some data. I want my viewmodel to keep track of this load operation and adjust its own state accordingly.
If it were up to me, I'd do the data loading far away from the view, but it is not. So, I seem to be in the situation where my viewmodel depends on my view. How...
I am interested in applying dependency injection to my current project, which makes use of the MVC pattern.
My controllers will call the models and therefore will need to inject the dependencies into the models. To do this, the controller must have the dependencies (such as a database object) in the first place. The controller doesn't ...
There is a pattern that I use from time to time, but I'm not quite sure what it is called. I was hoping that the SO community could help me out.
The pattern is pretty simple, and consists of two parts:
A factory method that creates objects based on the arguments passed in.
Objects created by the factory.
So far this is just a stand...
So let's assume I have a class named ABC that will have a list of Point objects.
I need to make some drawing logic with them. Each one of those Point objects will have a Draw() method that will be called by the ABC class.
The Draw() method code will need info from ABC class.
I can only see two ways to make them have this info:
Havi...