design-patterns

How do you apply design patterns?

From a bookish perspective, you might say that x design pattern is applicable in y scenario, but I want to dig a little deeper here. So here are my queries: When do you first decide that you'll use design patterns? Do all of you decide upon design patterns before coding? Are there any DPs that you apply after you're done coding (small ...

How to validate generated Java code's syntax?

I made a little app to generate Java test classes based on certain set of information. Basically, I am generating the boilerplate code needed for a library that we are using. I would like to test the generated code in better way than just comparing the output to an expected string. Is there any facility to test if the Java code conta...

Who's responsible for the next View?

In an archetypical MVC architectur, where does the logic go, that determines which view to show next? The assumption is some kind of app with several views (windows) that may or may not be visible at different times, depending on user actions. For instance, sometimes the application may need the user to fill out a form with additional ...

Ways to handling huge transactions on any database?

I have a data transformation product, which lets one select tables in a database and transform row data in the source database to a destination database. This is handled in the current product (java based workbench and engine) by processing 1000 rows at a time and doing it 10 threads parallely. This approach works fine on smaller data ...

How do I dynamically implement the Proxy Pattern?

I'm revisiting my class tracking (dirty logic), which I wrote last year. Currently I have an uber base class that deals with all the state tracking, but each property whos values I need to track needs to stick to the standard get { return _x; } set { _isDirty = true; _x = value; } way of working. After playing with Entity Framework and ...

java swing vs mvc: is this pattern indeed possible?

Hi, I am new in swing, but managed to create a descend gui. My problem though is that I was not able to apply the patterns suggested in references/tutorials, mainly the MVC pattern. Is it me, or in JTree and using SwingWorker, it is not possible to have a clear separation of controller/view/model? For example I use a Swingworker, but t...

What are the key design choices to make a wicked fast compiler?

I want to know how to design a compiler that compiles very, very quickly. First, let me head off some obvious misunderstandings of my question: I am not talking about the speed of the code produced by the compiler. There are already many resources available for learning how to optimize generated code. What I'm having trouble finding i...

What's the difference between design pattern and enterprise design pattern?

Hi, I want to know the difference between design pattern and enterprise design pattern. For example, some books call ActiveRecord an enterprise design pattern, while, singleton is a design pattern. Thanks ...

Design pattern for validating input?

What is the best way to validate input? For argument's sake, if the input is invalid, the user would like a message explaining why. Here is what I can come up with. Validator method: Pass input to the validator, which returns true if the input is valid. Otherwise, the validator either returns false (or an error code) and lets the call...

CQRS - How do I handle a user viewing a page or query

I'm using CQRS for an application that I'm building (an online discussion system with complex business logic) and I've reached a part in the implementation that worries me. How should I handle pageviews? If a user views a thread, I want to track that. Because I want to track that, it follows that I should create a command and an event, ...

How do I make my Factory's Header not dependent on the templated objects it creates?

I have an abstract base class like so: class AbstractBaseClass {}; a templated concrete class that derives from it: template<class T> class ConcreteClass : public AbstractBaseClass { public: ConcreteClass(T input) : data(input) {} private: T data; }; AndI have a factory class that creates AbstractBaseClasses class MyFactor...

What's the right pattern? An observer between the viewmodel & service

I am building a WP7 client app that talk to a web service (SOAP like) using Mvvm-Light. I have a ViewModel that both implements INotifyPropertyChanged and calls RaisePropertryChanged with the broadcast flag set. Both my view (XAML) and my model (which does HTTP requests to the web service) subscribe to property changes. XAML, obviou...

Best Design Pattern for Generating the UI dynamically

I am planning to generate the UI from database. The platfrom will be ASP.net. Can anyone help in identifying the best design pattern/Architecture that suits for generating the UI and events dynamically. ...

Where to store feedback UI data in ASP.NET MVC 2?

Hey guys I'm really new to both ASP.NET MVC and the MVC pattern generally. For context, I'm currently running .NET 4.0, MVC 2. I know that MCV 2 has a bunch of built in features for: validation (both client and server side, through a variety of ways) error handling (via attributes and other methods) But what should be used to retu...

Using specific patterns to implement interfaces

I have been very intriuged by design patterns lately, and specifically following correct design patterns in my classes that implement one or several interfaces. Let's take an example. When a class implement IDisposable you should follow a specific pattern to make sure that your resources are properly cleaned up, by creating a private Di...

How to implement Exception Handling in Parsing?

I'm creating a parsing application, which parses ~20 sites, ~7-15 values from each. Pseudocode looks like: ParserA : ParserBase { public override SomeEntity Parse(...) { SomeEntity se = new SomeEntity(); //some code, parsing value1; //some code, parsing value1; //some code, parsing value1; //some code, parsing value2; //some co...

What's a good C++ code design for a one Template Object -> multiple Instance Objects architecture?

I have the following design request for a visual editing tool written in C++: be able to define a template object (assign image, edit default rotation/scale, edit default property values) be able to place instances of template object in view be able to make changes to template object (eg different image, change rotation, scale, propert...

Show Off - Beautiful programmed jQuery Plugins

Hi There, besides jQuery, jQuery UI and jQuery Mobile - What are you choices for beautiful programmed jQuery Plugins. I'm currently developing my first plugin and try to learn from the best :-) Thanks a lot ...

Is There any design pattern to make reports in my application?

Hi! I am doing an application and i will show some reports to the users. I would like to know if there is a pattern that helps me doing any report that i want. I also would like to provide the user to choose the fields that he wants in the report. I think it would help many people here, because we usually have reports in our applicatio...

Trouble applying the mediator pattern in ASP.NET C# with generic List datasources

I'm working on a large ASP.NET project with a CMS driving lots of data. We have lots of modular components on our pages defined as ASCX controls. Several of these controls need to know about each other to know what data to get from the CMS (i.e. if there's a list of articles in one control, another similar control on the same page cannot...