It seems that ViewModels that I make look suspiciously like other classes and they seem to require a lot of code repetition, e.g. in a current project I have:
SmartForm: Model that represents a data form to fill in, has properties:
IdCode
Title
Description
collection of SmartFormFields
etc.
SmartFormControlView View
SmartFormControlV...
In the Wikipedia entry for the Strategy Pattern:
http://en.wikipedia.org/wiki/Strategy_pattern
Most other code sample is doing something like:
a = Context.new(StrategyA.new)
a.execute #=> Doing the task the normal way
b = Context.new(StrategyB.new)
b.execute #=> Doing the task alternatively
c = Context.new(StrategyC.new)
c.execute #...
In the usual Strategy Pattern, we make each strategy as a class. Can't we make it a function, and just assign the reference to the function when we instantiate an object, and let the object call that function?
...
Hello,
I've implemented a Model-View-Controller pattern in my application. It's not a web application but MVC is suitable for it.
all updates to the Model are now routed through controller. Even the updates from the view is also send to controller and it will be routed to model. (I've state classes in between model and controller for ...
Quickly going through the GoF and the Head First Design Patterns book, it seems like there is no mentioning of infinite loop detection and handling for the Observer pattern?
I think if it is between 2 classes, we can be more careful about the infinite loop problem, but what if there are 5 classes or 12 classes, and the observers go mult...
So for my current project, there are basically three main Java classes:
GUI
Instant Messaging
Computation
Essentially, there needs to be full communication, so we've decided to use the mediator approach rather than than allow the GUI to run the entire project.
Basically, the mediator is going to encapsulate the communication. The pr...
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...
Hi
I got an exam in two days and one of the questions is how JDBC uses the abstract factory. I myself is not so skilled with design patterns, so maybe somebody here had the answer.
I was thinking that maybe, DriverManager.getConnection(url) is an example of abstract factory, but am not sure. Or is it a factory method?
...
After going through some tutorials on asp.net mvc the repository pattern came up and the example was with one table, the dinners table. Basically the set up was to create an interface and then a concrete class which implemented the interface and program off the interface in the controller class. The Interface has your typical crud method...
The Observer Pattern seems very much like a Notifier Pattern, since it is based on the subject notifying objects that are interested. The "notify" part seems the most important, because without it, nothing gets notified.
(was there ever some thoughts to rename this pattern to the Notifier Pattern?)
Are there any Observer Patterns out ...
Hi!
Say, I am building a business process management application. It has the following entities: issues and tasks, related to each other as 1 issue to many tasks. Both, task and issue, have their own states and the state of one may influence the state of another.
For example, both of them have "Cancelled" and "Completed" states. When I...
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...
Is the Decorator Pattern mainly to get an object with dynamically chosen extra functionalities?
Can we do something like
window = Window.new(widht, height, x, y, [UseScrollBar.new, DrawBorder.new])
so that when we call draw(), we also loop through the additional functionalities?
For example, if our purpose is to write_line to a file...
Hi
I can see how Swing uses Decorator and Observer pattern.
Observer: Every component(fx JButton) is a subject which can add observers(ActionListeners). When someone pushes a button it notifies all its ActionListeners by calling their actionPerformed(ActionEvent e).
But how about Command Pattern?
When I am making classes that implemen...
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...
I'm looking to move a Windows C++ application to C# so that some major enhancements are a bit easier. The C++ application is single-threaded and uses a home-grown reactor pattern for all event handling of accepting, reading and writing sockets, and timers. All socket handling is done async.
What is the accepted way to implement a C# rea...
When my application starts up it needs to get an instance of the correct DAL class (currently there are 4) based on what user is logged in. Certain users are pulling down from certain databases.
Is it still considered a "factory" pattern if instead of instantiating instances of those DAL classes, I simply return the correct static inst...
I have a system which needs to send requests to an external system, whenever a user does search on my system.
If the external system is down or is taking an unusually long time to answer, I would like my system to "back off" for a while. Instead of trying to make more requests to the external system, I want to just let the user of my s...