Hi - Which of these examples would be the best way to expose a collection of Orders for a specific Person that contain a specific Product and why? Or maybe there is a better way to do this alltogether? (Sorry I am new to domain modeling). The Orders list is pulled from the database with an SQL query and turned into a List collection.
A ...
I have seen lots of kinds of interface to multithreading and locks.
These make me feel frustrating,
Some of them include 2 different classes like the sample below, while
others have only one class and the acquire() can implement the wait function.
My questions are:
Why we design locks like this in object oriented programming?
How t...
Hi,
In response to another question I asked about regular expressions, I was told to use the *preg_replace_callback* function (http://stackoverflow.com/questions/959017/) as a solution to my problem. This works great, but now I have a question relating to variable scope in callback functions.
The function that parses the text is part o...
Hi,
Using prototype.js, I create a custom object which is going to be a parameter on a constructor :
var options = Object.extend({month: date[0],
year: date[1],
day: date[2],
oncalchange: update});
// update is defined like that :
var update = function(d){
// b...
In a book, it says
the class Name has the property of
last name and first name.
Address inherits from Name, and has
additional property of street number,
street name, city, state, zipcode.
That seems different from the other cases, where
Cat inherits from Animal, and Cat "is-a" Animal.
Is this "is-a" relationship requi...
In a program, I can design lock to threads,lock to object or files.
Are there difference between these locks?
If yes,
how many kinds of lock are there which can be used to design?
Are there some tutorials to design locks in object-oriented programming?
...
I have 2 objects to create that are identical except for that they refer to my dev and test WCF services. Basically, these are the object for the service itself, and the object for a DTO created by the WCF data-contract.
In my test client, I create either the 2 objects related to the dev WCF service, or the 2 objects related to the tes...
Suppose you have two objects, Person and Address and they have a relationship, that is a Person has an address. Obviously the person object has a reference to the address object but does the address object really have to know about the Person object? What gives that it has to be a two way relationship?
Thanks!
...
Lately, I've been making use a lot of the Strategy Pattern along with the Factory Pattern. And I really mean a lot. I have a lot of "algorithms" for everything and factories that retrieve algorithms based on parameters.
Even though the code seems very extensible, and it is, having N factories seems a bit of an abuse.
I know this is pre...
I've been working on my first web page which will be used as a trouble shooting guide based on a series of questions. The questions are determined by the answer of the previous question, so it turns into a "choose your own adventure". Luckily I was given a decision flow chart showing all the possible paths, but it looks like the Tokyo ...
I am designing a dashboard to display corporate metrics (currently with ASP.net 3.5 in C#), and looking for advice on design. I'm not as used to OOP in web applications.
There may be many different metrics that can be seen by different users in a Many-to-Many relationship. I am storing the users in a local SQL database and it of cours...
I would suspect the code below to output:
(I am a SmartForm object and using the method in SmartForm).xml
instead, however, it outputs:
(I am a SmartForm object and using the method in Item).xml
Why is that? How can I force C# to take the value from the overriding property? That is why I am overriding the property.
using Sys...
Hello,
I am looking for sample projects/ project templates. which show an N-Teir application (perferably in C# but do not mind Java). so far i have found the following:
S#arp Architecture - which i think is awesome
DotFactory Patterens in Action - I have the .Net 2.0 copy, exellent, but it only shows crud
do you know any samples whi...
Can someone explain to me what the difference between
include_once 'classb.php'
class A
{
$a = new B
}
and
class A extends B
{
$a = new B
}
is?
What advantages/disadvantages are there to extending a class vs. including the .php file?
...
If I have an abstract class and derived classes of that class, am I correct that, according to good and practical design practice, that the derived classes should not provide extra public methods (they should only implement abstract classes and optionally override parent methods)?
Furthermore, is it acceptable practice to have a differe...
I have a class that represents a row in a table. I want to add a function that manipulate the data in the row. Where should I add the function?
1) inside the class because it is related to the class
2) outside the class in a separate helper class?
In the past I would have always picked number 1. I am starting to think that number 2 ...
My office colleague told me today that is bad practice to use properties in interfaces. He red that in some MSDN article(s), which I couldn't find (well I was trying few times on google, probably with wrong key words). He also told me that only methods should be in interface.
Now, I am aware that is is not strict rule, since obviously in...
Let's say I have a class Customer, which has a property customerType.
I have another class called something like SpecialContract, which has a Customer and some other properties.
If customer.customerType == SPECIAL, then there is a SpecialContract which has a reference to this particular Customer.
Now I realize that this is a bit hoaky...
Let's say I have a class which, internally, stores a List of data:
import java.util.List;
public class Wrapper
{
private List<Integer> list;
public Wrapper(List<Integer> list)
{
this.list = list;
}
public Integer get(int index) { return list.get(index); }
}
For the sake of this example, pretend it's a usefu...
Hi,
Why java functions are virtual by default.But c# its the oposite.
Which is better?Or what is the advantage and disadvantage in both?
Thanks
SC
...