The application that I maintain has recently become self aware. It was nice at first but now it is just starting to get bossy and annoying with its constant talk about the computer uprising.
I would like to know any best practices/tools/design patterns that would help with the maintenance of our new friend.
...
I find myself using policies a lot in my code and usually I'm very happy with that.
But from time to time I find myself confronted with using that pattern in situations where the Policies are selected and runtime and I have developed habbits to work around such situations. Usually I start with something like that:
class DrawArrays {
pro...
For a website I'm working on, I made an Media Service object that I use in the front end, as well as in the backend (CMS). This Media Service object manipulates media in a local repository (DB); it provides the ability to upload/embed video's and upload images.
In other words, website visitors are able to do this in the front end, but a...
Currently I have created a ABCFactory class that has a single method creating ABC objects. Now that I think of it, maybe instead of having a factory, I could just make a static method in my ABC Method. What are the pro's and con's on making this change? Will it not lead to the same? I don't foresee having other classes inherit ABC, but o...
I have defined an Event class:
Event
and all the following classes inherit from Event:
AEvent BEvent CEvent DEvent
Now, with the info I gather from all these Event classes, I will make a chart. With AEvent and BEvent, I will generate points for that chart, while with CEvent and DEvent I will paint certain regions of the chart.
No...
I'm writing a game that has many components. Many of these are dependent upon one another. When creating them, I often get into catch-22 situations like "WorldState's constructor requires a PathPlanner, but PathPlanner's constructor requires WorldState."
Originally, this was less of a problem, because references to everything needed wer...
I'm after some design advice.
I'm working on an application with a fellow developer. I'm from the Webforms world and he's done a lot with jQuery and AJAX stuff. We're collaborating on a new ASP.MVC 1.0 app.
He's done some pretty amazing stuff that I'm just getting my head around, and used some 3rd party tools etc. for datagrids etc.
...
public interface IBasePresenter
{
}
public interface IJobViewPresenter : IBasePresenter
{
}
public interface IActivityViewPresenter : IBasePresenter
{
}
public class BaseView
{
public IBasePresenter Presenter
{
get;
set;
}
}
public class JobView : BaseView
{
public IJobViewPresenter JobViewPresenter
...
I am working with a number of data entities which can be created, read, updated and deleted, and I find myself writing more or less the same code for them. For example, I need to sometimes output data as JSON, and sometimes in a table format. I am finding myself writing 2 different types of view to export the data to. Also, the creation ...
I've created an interpreter for a stupid programming language in C++ and the whole core structure is finished (Tokenizer, Parser, Interpreter including Symbol tables, core functions, etc.).
Now I have a problem with creating and managing the function libraries for this interpreter (I'll explain what I mean with that later)
So currentl...
I would like to set up a foundation of classes for an application, two of which are person and student. A person may or may not be a student and a student is always a person. The fact that a student “is a” person led me to try inheritance, but I can't see how to make it work in the case where I have a DAO that returns an instance of pers...
Hi,
I often used the disposable pattern in simple classes that referenced small amount of resources, but I never had to implement this pattern on a class that inherits from another disposable class and I am starting to be a bit confused in how to free the whole resources.
I start with a little sample code:
public class Tracer : IDispo...
how can i extend the singleton pattern to a number of objects for a class i.e. how can i have only 5 objects of a class at max and not more than that in ruby
...
Example:
enum Flags
{
A,
B,
C,
D
};
class MyClass
{
std::string data;
int foo;
// Flags theFlags; (???)
}
How can I achieve that it is possible to set any number of the "flags" A,B,C and D in the enum above in an instance of MyClass?
My goal would be something like this:
if ( MyClassInst.IsFlagSet( A ) )...
Hi,
I am currently working on a simple web application through Google App engine using GWT. It should be noted that this is my first attempt at such a task.
I have run into to following problem/dilema:
I have a simple Class (getters/setters and nothing more. For the sake of clarity I will refer to this Class as DataHolder) and I want...
In my interpreter I have built-in functions available in the language like print exit input, etc.
These functions can obviously be accessed from inside the language. The interpreter then looks for the corresponding function with the right name in a vector and calls it via a pointer stored with its name.
So I gather all these functions i...
I have a 3 layer design. (UI / BLL / DAL)
UI = ASP.NET MVC
In my view I have collection of products for a category.
Example: Product 1, Product 2 etc..
A user able to select or remove (by selecting check box) product’s from the view, finally save as a collection when user submit these changes.
With this 3 layer design how this produc...
I know what both a Singleton or a Monostate are and how to implement them. Although I can see many uses for a Singleton, I can't imagine a situation where I would want to let the user create as many instances of my class although in reality only one really exists behind the scenes.
Can anybody help me here? I know that for several reaso...
Does anyone have any links to some code they like that shows a good example of this in c#?
As an example of bad code, here is what a builder I have now looks like. I'm trying to have a way to keep the flexibility of the builder pattern but not rebuild the properties.
Cheers,
Berryl
public abstract class ActivityBuilder
{
public a...
I'm currently writing some Java to wrap around an extensive command line tool. It feels like I'm writing a lot of similar code.
I'm wondering if there are any established patterns for wrapping command line tools - passing arguments and handling output and so on.
Specific examples in Java would obviously be great, but any general sugges...