design-patterns

What are the differences between Active Record and Repository pattern?

It seems to me that the only difference is that Active Record has CRUD methods in data container class, and the Repository pattern uses separate class for data container and CRUD methods, but surely I'm wrong. What are the differences between Active Record and Repository pattern? When should I use which pattern? ...

Best way to implement performing actions on tree nodes, preferably without using visitors.

Hi, I have a user interface with a tree view on the left, and a viewer on the right (a bit like an email client). The viewer on the right displays the detail of whatever I have selected in the tree on the left. The user interface has "add", "edit" and "delete" buttons. These buttons act differently depending on what "node" in the tree...

refactoring similar code targeted at all view controllers's navigation bar

Hello I'm trying to find the best way to refactor this. Right now, each of the view controllers (about 20 of them) have a function that initializes the content of the toolbar / navigation bar like so ie, -(void)toolbarInit and on each of the controller's viewDidLoad, you will see that the function is being called ie, [self toolbarIni...

variable scope and closure inside a module pattern javascript instance

I'm writing a jQuery plugin, and I'm writing it in a non-jquery-community-standard way, mainly to maintain portability and extendability. I'm having some trouble accessing variables that were declared in the function when accessing from the prototype. Perhaps I have this model very wrong but I hope someone can point out the correct...

Designing an application

I'm currently worried that my application design is somehow awkward, so I wanted to ask you how you design your applications. I'm using C# and WinForms (Don't have the time to get into WPF right now unfortunately) So I use a ProgramContext so I can have multiple Forms in the same Application and manage them. But the question is, where ...

Need to create a "choose your own adventure" type guide - best approach to use

Basically need to ask user a set of questions and gather information along the way. Each question could have impacts on different questions down the road. Another example would be turbo tax's web interface, answering yes on some ?s may trigger future questions. Seems like this would be a fairly common problem in software so I guess ...

Java Abstract Class or Static Utility Class Design Choice

I am implementing a few strategies (Strategy Pattern) which have some common behavior and am undecided where the common operations should live. Assuming I 1 context and 3 strategies, some of the operations used in the strategies are shared, some are needed only by 2 others just be 1 of the strategies. There is no member level state s...

Utility classes are evil?

I saw this thread http://stackoverflow.com/questions/3339929/if-a-utilities-class-is-evil-where-do-i-put-my-generic-code and thought why are utility classes evil? edit -- here is a specific example that might be instructive. Lets say I have a domain model that is dozens of classes deep. I need to be able to xml-ify instances. Do...

UML/RUP and non OO applications

At my current job, we are currently implementing UML and RUP for the day by day coding and designing... The current structure have 2% of all code (100000+ lines) object oriented... So they have this issue, when a developer have this new "case" (ir, requirement, etc) they must complete all the documentation and analysis to that old thing...

Rewriting a conditional statement in Java

Say if I have the code below, it's bascially determining some condition is matched and then assign the boolean value, then run some codes. Then throw an exception if the booleanValue is false. What if I want it to throw an exception immediately if the booleanValue is false without running the rest of the codes? If I just put the second c...

Use of abstract class in shopping portal

Hi Experts, I know that my this question may sound pathetic to you but as a beginner in .NET, it means a lot to me. I just want to know that how can I utilize the concept of Abstract class, virtual class etc. in my shopping cart website. I have read the tutorial out there on internet and I saw some examples too, but those examples are ...

Do you separate SQL from the BL?

Many years ago, when I started (C) we wrote the business logic in one place, and all the SQL statements for that business logic in a different place. (The reason was probably due to the fact each file passed a different build process, sql files with the Oracle builder). But this prevailed in other places, where there is no need for phys...

Communication between client class library and web service / web service and server class library

Wondering what others do / best practice for communicating between layers. This question relates to communication between layers 2-3 and 3-4. Our Basic Architecture (in order) as follows: UI Front End Business Classes Web Services Back End Business Classes DAL The web services are just a façade that include logging and authenticatio...

JavaScript Code Organization Suggestions/Code Review

I am working on a large site that has a lot of custom (page specific js). There is one main.js and page-specific.js files. Is there a better approach that can use the following pattern? How can I re-factor multiple methods that use ajax? I currently assign all onclick events inline such as onclick="MYSITE.message.send... - it there a be...

How much Entity Framework is good for database that contains tables with large records ?

Hi guys, I am working with VS 2010, Entity framework, SQl-Server 2005, ASP.Net web forms. Currently, I am working on the Data access layer library which soon will be a web service, using Entity Framework collaboration with different design patterns like repository pattern and some best practices that posts in different blogs. I am also ...

Why should one use factory method to create objects

Possible Duplicates: Factory Pattern. When to use factory methods? Why do static Create methods exist? Though I know what is Factory Design Pattern. But I am unable to comprehend what are the benefits of using it. Why should we create objects using Factory Design Pattern. ...

Getting started with Pylons and MVC - Need some guidance on design.

I've been getting more and more interested in using Pylons as my Python web framework and I like the idea of MVC but, coming from a background of never using 'frameworks/design patterns/ what ever it\'s called', I don't really know how to approach it. From what I've read in the Pylons Book, so far, it seems I do the following: Create ...

Pattern for forcing adding to collection through method in C#

I have a class with a collection member. I would like to prevent external code from modifying this collection directly, instead using methods (which can perform the appropriate validation etc). This is harder than I thought. Here is the solution I am using. Can you please tell me if there are better ways to do this common thing? It all ...

Alternative to "char" enum

I have a database which needs a status column updating to a single char status code ('E' or 'U'). I'd like to use an enum for updating this field through my API to ensure the possible values are restricted correctly. Obviously enums can't be of char type. What might be be a good alternative method? And no, I can't change the database s...

Accessing methods of nested widgets

Im working on optimizing my design in terms of mvc, intent on simplifying the api of the view which is quite nested even though Iv built composite widgets(with there own events and/ pubsub messages) in an attempt to simpify things. For example I have a main top level gui class a wxFrame which has a number of widgets including a notebook...