Is the example below dependency injection with regard to the Worker class? From my reading about the topic over the last few hours becaue the Worker class isn't obtaining the ITool instance from a property setter or constructor it isn't an example of DI?
public MainClass {
static void Main(string[] args) {
ITool someTool = ...
I have a component that I wish to write and it's the kind of thing that feels like a common pattern. I was hoping to find the common name for the pattern if there is one, and examples of how to go about implementing it.
I have a service that queues requests and processes them one at a time. I have a number of client threads which make t...
<xml>
<Office prop1="prop1" prop2="prop2">
<Version major="1" minor="0"/>
<Label>MyObjectA</Label>
<Active>No</Active>
</Office>
<Vehicle prop="prop">
<Wheels>4</Wheels>
<Brand>Honda</Brand>
<Bought>No</Bought>
</Vehicle>
</xml>
My XML is in this format. I am using a SAX parser to parse this file as the size of ...
Hi,
I habe been studying Seam framework for a long time. Altough i do not use it at work, i like its approach. It is very interesting. But i have some doubts. After reading Seam in Action book, i think it is not possible you bind more than one parameter to a business method. Something like
@Stateless
public class BusinessObjectImpl imp...
I've built a simple iPhone app that parses data from a remote XML feed, converts the information into objects (they're videos), and displays the videos in a standard table view->detail view->"Play Video" UI. There are hundreds of videos, each with about ten attributes. (The videos are never downloaded, only streamed, using MPMoviePlayerC...
In Karl Seguin's Foundations of Programming there is a small section on using the factory pattern. He closes the passage by stating "you can accomplish the same functionality with constructor overloading", but doesn't indicate when or why?
So,when does it make more sense to use the factory pattern rather than an overloaded constructor ...
I'm looking for a data structure pattern for storing recurring events, but everything I came up with would result in a high number of special case handling or user input and data retrieval are overly complex. (I get the distinct feeling, that I haven't understand the problem domain well enough to do this.)
How can I store Outlook-style ...
Hi,
Loose coupling is wonderful of course, but I have often wondered what overhead wiring up dynamically using an IoC container (for example Castle Windsor) has over a tightly coupled system?
I know that a detailed answer would depend on what the IoC was being used for, but I'm really just trying to get a feel for the magnitude of effo...
I often find myself reading books and articles that outline patterns, best practices, and how to write "clean code." However, some of these concepts just seem to be over engineered and at times obscure the essence of the underlying problem, making the code more difficult to relate to the problem domain being modeled.
How often do you fi...
I am going over my design patterns, and one pattern I have yet to seriously use in my coding is the Decorator Pattern.
I understand the pattern, but what I would love to know are some good concrete examples of times in the real world that the decorator pattern is the best/optimal/elegant solution. Specific situations where the need fo...
Hi,
I have the following situation
class RecordA
has_many :recordbs
end
class RecordB
belongs_to :recorda
end
RecordA has many recordbs but only one of them may be an active recordb. I need something like myRecordA.active_recordb
If I add a new column like is_active to RecordB, then I have the potential problem of setting two r...
I'm thinking of writing a class to store away some helpful methods that relate to my Model, sequences of my Model and my Repository. I don't think any of those are responsible for calculating anything. It's not really a service per se either.
I want to do something like this:
IEnumerable<Game> someGames;
...
int score = _something.Calc...
So,
I currently am working on a project, in which two different datasources will be updated.
The business objects have similar structures, but not exactly the same.
What I have currently planned on doing, is using a provider interface, so I have have a handler class to push to both databases.
As the 2nd object is from an external AP...
What is the difference between User Interaction Design Patterns and User Interface Design Patterns. I have heard that one is the subset of the other, but how do thy correlate?
What is the correct term for ui patterns e.g., from http://uipatternfactory.com/?
...
What are some defining characteristics of a Ruby DSL that separate it from just a regular API?
...
Both patterns seem like an implementation of the principle of inversion of control. That is, that an object should not know how to construct its dependencies.
Dependency Injection (DI) seems to use a constructor or setter to "inject" it's dependencies.
Example of using Constructor Injection:
//Foo Needs an IBar
public class Foo
{
...
Hi there,
I want to implement a generic Observer Pattern for user controls. What is the best way to do this?
There are 3 usercontrols: A, B & C.
Each of these usercontrols is a representation of a set of data. Each control has a select for display mode (basic or detailed). The site visitore gets to choose which mode. On changing the ...
I am doing research on a SOA topic and i am trying to understand what gang of four say about aspect orientation. I also need to implement one of these pattern in AOP paradigm.
What would be best pattern to pick for this?
...
I am working on developing a webapp (visual jsf, ejb3, hibernate on glassfish/mysql) that works with an existing legacy system.
I have an 'employee' table (with fields such as name (String), location (String), etc.) which is separate from an employee table on the legacy db2 side. I do all of the webapp processing with my employee table....
I am doing an in depth study on design patterns, and I came across prototype, which I didn't really study before. I have searched the web and several books, and there isn't a really good example of prototype that could find that isn't just clone. Is the design pattern of prototype basically a language feature of java and C# as clone?
...