Situation:
Assembly 1
________________________ ________________________
| Class A | | Class B |
|-----------------------| |-----------------------|
| Method someMethod |---------->| Method otherMethod |
| | | |
|_____...
Given the classes Company, Employee, and Car what is the preferred practice for methods to retrieve Cars associated with Company or Employee?
Employee.GetCars(params...)
Company.GetCars(params...)
Or:
Cars.GetByEmployee(params...)
Cars.GetByCompany(params...)
The first approach is the one I have generally used and always seemed the...
I'm developing a web service using NHibernate, WCF and Oracle 11g R1. The web service is pretty simple: it maps DTOs to POCOs and performs various CRUD operations on them based on the operation called. Each entity has its own set of CRUD methods - this is a temporary, but necessary for the time being.
I'm looking for input on a good R...
I have a method in my service where I create some entities, inside the method I call my repository's Add method so that the entities are persisted when I call my save method, should I call my Save method outside the service class or inside the method where I add the entities to the datacontext?
...
Hi!
suppose I want to create an abstract class in python with some methods to be implemented by subclasses. (in Python)
for example:
class Base():
def f(self):
print "Hello."
self.g()
print "Bye!"
class A(Base):
def g(self):
print "I am A"
class B(Base):
def g(self):
print "I am B...
when do we need to go for Decorator pattern? If possible give me a real world example that suits that pattern...
...
I currently have a cache implementation (using arrays) for the heavy computations performed during the simulation. The structure of the cache is as follows:
The way it works:
CalculationsAbstract calculationsCache = new CalculationsCache();
// Constructor of CalculationsCache
public CalculationsCache()
{
this.Proxy = new Calculat...
When do we need to go for Adapter pattern? If possible give me a real world example that suits that pattern...
...
Hi-
Today, I'm building a little form generator for my firm. It would ask for someone to Add a Field, choose the field type (text field, checkbox, etc), name it and then add another and another if they want. I'd like to achieve this without having to go server side for each element. In other words, I want to take this opportunity to b...
Hi all,
Considering a hypothetical situation where an old, legacy presentation library has been maintained over the years, and has gradually had more and more business logic coded into it through a process of hasty corrections and lack of proper architectural oversight. Alternatively, consider a business class or namespace that is not s...
I'm currently learning how to do multithreading in C++. One of my learning projects is a Tetris game. In this project I have a Game class that contains all game state data. It has methods for moving the block around and a few other things. This object will be accessed by the user (who will use the arrow keys to move the block, from the m...
I have a problem I want to know your opinion.
I am trying to use Repository Pattern. I have a repository object which load data to a POCO. I have also created a Business logic layer which adds a little bit of functionality but basically wraps the POCO. So in the end I have a BLL which loads DAO with usage of repository.
I am not very h...
Hi Guys,
I have a tree structure design problem, and i can't think of a way out.
i want to have one class Tree containing a generic data, and extend the Tree class with ComplexTree that will contain more methods like Iterate, DoSomthingOnComplex, etc.
here is a sample of the code i have:
class Tree<TData>
{
public TData Data { ge...
Hi,
I implemented the domain model from the book Zend Framework: Survive the deep end but nowhere they mentions how to handle collections of objects.
I mean, how to find multiple rows ? Similar to fetchAll() ?
Any advises, best practices to work with such things ?
...
Hi,
I have a base class:
class Message
And two deriving classes:
class SimpleMessage : Message
class ComplexMesssage : Message
These types are used in another part of the code as such:
void ProcessSimpleMessage(SimpleMessage m)
void ProcessComplexMessage(ComplexMessage m)
These methods are not inside the class Message, as the p...
They seems to be similar.
...
Hi guys:
I have four classes, let's call S1, S2, S3 and S4. These class are singletons; each one have a getInstance and a finalize method - and an instance private variable-.
Now, to avoid repeting the finalize and getInstance methods I'm trying to make a SingletonMixin class, something like:
template<class T> class SingletonMixin
{
...
What is the design behind custom dynamically generated forms?
Would like to implement something like drupal's CCK.
In the control panel, the owner of the form designs what fields should be in the form and in what order the form fields should be in, as well as the field's attributes such as "required: yes/no"
Once the form has been de...
I'm trying to understand the observer pattern using C#, first I have an abstract class working as Subject called Stock, then I'm creating a concreteSubject class so I'm going to call it IBM, as the concreteSubject Class is going to inherit from Stock, so I do something like this:
class IBM : Stock
{
// Constructor
public IBM(str...
This is mostly of a design pattern question. I have one type of model that I'm going to get the data to create them from multiple sources. So for example one record my be created from an API where another is created via screen scraping with Nokogiri.
My issue lies in how best to abstract out these different data sources. Right now I...