design-patterns

I have to generate PL/SQL using Java. Most of the procedures are common. Only a few keeps changing. How to do that?

I have to generate PL-SQL code, with some common code(invariable) and a variable code. I don't want to use any external tools. Some ways that I can think: Can I go and maintain the common code in a template and with markers, where my java code will generate code in the markers and generate a new file. Maintain the common code in stati...

Patterns for functional, dynamic and aspect-oriented programming

We have a very nice GoF book (Design Patterns: Elements of Reusable Object-Oriented Software) about patterns in Object Oriented Programming, and plenty of articles and resources in the web on this subject. Are there any books (articles, resources) on patterns(best practices) for functional programming? For dynamic programming in langua...

Salary Calculations Patterns

Hi all I want to develop a system that is similar to calculation of salary. A salary has a basic value. On top of it, an employee can get some Bonus (es) or Penalties. Decorator Pattern seems to fit this scenario Salary finalSalary = new HardworkBonus(new LateComingPenalty(new BasicSalary())) System.out.println("Your total salary is : ...

Is this the best use of the Adapter pattern?

Would using the adapter pattern be the best design to use when all you're trying to adapt to is a class that is holding fields and not methods or functions? For example, would the following be the best way to approach this? I'm using C# if that makes any difference in your answers. NewClass private Guid _guidId; AdpaterC...

Choosing the right subclass to instantiate programatically

Ok, the context is some serialization / deserialization code that will parse a byte stream into an 'object' representation that's easier to work with (and vice-versa). Here's a simplified example with a base message class and then depending on a 'type' header, some more data/function are present and we must choose the right subclass to ...

Is change-tracking in ORMs a necessity or a luxury, in the context of web apps?

Since web applications are mostly stateless, and linear (request comes in, response goes out), is change-tracking really necessary? E.g. if I have an action that updates a Product instance I know at code-time what state I'm changing, I can just tell the repository "please update this instance". To clarify, my question is about the chan...

When is it appropriate to create a Decorator for an object, and when is it appropriate to rewrite your object to allow Strategies to be applied?

For example, suppose I have a Product class that I can add to a shopping cart. I may want to be able to package it together with another item when it is also in the cart and add a 15% discount. Should the product class be decorated with a new subclass allowing deals, or should product class be redesigned to allow the cart attach a price...

Non-GOF patterns

How many design-patterns can you name that are not GOF patterns? Do you have any web-link that lists those names? ...

What are the common patterns for validation in model in PHP?

Currently, I create an object and use its setters to set the get/post data received from client. And call the validate() before calling the save() function like this: //member registration $m=new Member(); $m->setName($_POST['name']); $m->setBirthDate($_POST['birthdate']); $m->setAddress($_POST['address']); $arrOfErrMsgs=$m->validate()...

Sample J2EE projects using J2EE design patterns

For .Net there are lots of projects that Microsoft/others provide via which one can learn how patterns etc. are implemented in real life projects. I am looking for ones for J2EE (apart from the samples that Sun provides on:http://java.sun.com/javaee/reference/code/). Am looking for more complex ones. May be using JSF/Spring/Struts ...

Strategy Pattern - multiple return types/values

We are working on an image processing project using C# and EmguCV. Our team is composed of 3 people. To make faster progress, the 3 of us work on different sub-problems or experiment with different algorithms at the same time. Currently each of us creates a function that contains the major code we are working at and all of us make chang...

MVC in PHP without the "magic"

Let's say I have a PHP Model-View-Controller framework that maps an address like http://site.com/admin/posts/edit/5 to an action that looks like Posts_Controller::editAction($id) in file /admin/controllers/posts.php Now, many existing PHP frameworks that I've looked at would accomplish this by something similar to $module = Router::...

model-view-presenter book

have been searching the web and have not found any recommended MVP books. in particular we are interested in: MVP, .NET C# and Winform (possibly migrating to WPF) thanks for the help! ...

Applying one test to two separate classes

I have two different classes that share a common interface. Although the functionality is the same they work very differently internally. So naturally I want to test them both. The best example I can come up with; I serialize something to a file, one class serialize it to plaintext, the other to xml. The data (should) look th...

Why is the strategy pattern called the strategy pattern?

Of course you can regard it as a kind of strategy, but that applies to almost all the design patterns. So : why? ...

Proper way to Create/Update/Delete hierarchical data

So I have a structure like this: Widget: Component 1: Component 2: Component 3: ... Component n: I'm building an ASP.NET MVC web app that as part of its functionality will allow a user to create a Widget object and assign Component objects (which have a number of properties) as "children" of the Widget object. Users might ha...

Accessing member variable directly vs through property

Friends, I am asking this question with performance as main concern. But I would like to know other possible advantages / disadvantages for both approaches. The question is: Since properties are converted to methods in IL, could there be significant performance penalty if properties are called instead of accessing fields directly (from...

Is it confusing to call this class a "factory"?

My understanding of a factory is that it encapsulates instantiation of concrete classes that all inherit a common abstract class or interface. This allows the client to be decoupled from the process of determining which concrete class to create, which in turn means you can add or remove concrete classes from your program without having t...

Dividing file to be processed partly, then batching results

Please, We have the following situation: Component X that divides a request file into parts, sending each part to an independent processing component Y -through a network- that will reply with a result to component Z , component Z collects all the results of the file parts into a batch result file. Note:- Request file: file contains ...

Advanced Search Design for Large Objects

I’m looking for some advice. I recently wrapped up a project where I inherited some terrible code. I got the application running but it’s safe to say there are a number of performance and design issues, specifically with the advanced search functionality. I have now been asked to do a very similar project but much larger in scale. I have...