design-patterns

Data Mapper and Relationships: Implementation strategies?

I've almost finished my Data Mapper, but now I'm at the point where it comes to relationships. I will try to illustrate my ideas here. I wasn't able to find good articles / informations on this topic, so maybe I'm re-inventing the wheel (for sure I am, I could just use a big framework - but I want to learn by doing it). 1:1 Relationshi...

Designing Libraries in CodeIgniter

I am about to start writing my first big CodeIgniter application, but before I get started I was wondering what the role of libraries should be. I'm a newbie to MVC, but from what I gather the model should be where the data structures are stored (business logic). So is the library a place to write application logic, in addition to contro...

How to implement apply pattern in Javascript

What is apply invocation pattern in Javascript in reference to function invocation patterns and how can I use it? What are the benefits of using this invocation pattern. ...

How to decide the right design pattern for a .NET client app that will eventually share code with a web app?

I am new to design patterns, but I have been trying hard to implement some in the last year. I started at a new organization, and all the code was contained in the form. Since I got here, I've been trying to use an MVC approach for our .NET 2.0 application. Other developers have started to see the need for this approach, and we are ...

How to implement options with multiple return types

I have an application where a multiple shops will share the data. There is an Options table that defines various program options. I have a varchar column that defines the value type, int, bool, Guid, string, etc. There are two tables that define the option values, one for system wide options and one for local options. The base Options ta...

where to put entity related methods ?

Asp.net-mvc, using nhibernate. my vs.net layout is like: /dao (1 class per entity for database work, using repository) /model /mappings /factory (db factory that provides access to each entities Dao) Now I need utility methods, not sure where to put them. example: CartItems.cs CartIemsDao.cs Now say I have a method like: ILi...

python state design pattern

hello . i have 2 questions : 1- im trying to implement an ( Observer ) design pattern in python. what is the easiest implementation for that ? i need it to observe machines status in a render farm that im building currently . 2- is there any good (python) design patterns book out there ? ...

How long should a DataContext live?

Hi, I was just wondering how long should a DataContext really live. All the patterns and practices books like Dino Esposito's Microsoft .NET: Architecting Applications for the Enterprise tell you, datacontext must not live long, nor should it be cached. But how long is the right time? A whole web request, a unit of work, a transaction, ...

how to allow for a flexible UI in ASP.NET MVC

We are starting a new ASP.NET MVC project and we would like to establish a pattern of development that will allow flexibility in the UI. The general idea is that we would like to develop a set of related controls as a unit (i.e. a set of inputs and a submit button) and maintain the flexibility to decide later 1 of 3 UI options Have t...

MVP - Supervising Controller

Can someone tell me what component in MVP - Supervising Controller variation has the responsibility for implementing logic related to the enablement/disablement of UI elements? For example, I have a view that has a checkbox and a number of textboxes. Now 2 of the text boxes should only be enabled if the checkbox is checked. Should the...

Method chaining with value objects

is it acceptable/good-practice to use the method chaining pattern on value objects (like, returning a new object instead of this)? are there cases out there where this solution is implemented ? I cannot think of any drawbacks, but I'd like to hear your point. ...

When I make a Multiselect Form Input Field, should I create a View Controller for this, or is a View just fine?

I'm struggling since a few hours with this design question. In Cocoa for example, a complicated Date Picker is just a View. But it HAS a lot of complicated logic and algorithms to enable picking dates. In this case, I want to create a form element component for multi-selection of objects (i.e. when defining a relationship Users 1:n Pho...

How to save in Transaction?

Consider this scenario; suppose I have WPF window which have four objects bonded to its controls (Schedule, Customer, Contract, ScheduleDetails and Signer specifically ) which represent four database tables in the backend database. I want when the user request save for the information he/she entered to be joined in atom operation in anot...

What's the proper name for an "add-on" table?

I have a table a with primary key id and a table b that represents a specialized version of a (it has all the same characteristics to track as a does, plus some specific to its b-ness--the latter are all that are stored in b). If I decide to represent this by having b's primary key be also a foreign key to a.id, what's the proper termin...

What's considered to be better design here?

I hope this isn't too subjective. I can't decide between these two design opportunities. I have a Front Controller pattern. When the user surfs to a specific URL, my framework loads a specified View Controller for this URL. The View Controller then calculates some things and loads a View Template, to show the results. Now imagine you ...

How should classes be structured internally as regards methods and their use of instance variables?

I keep having problems deciding how I should create my classes internally. Initially I would have an external class handle all the variable management: String destination = car.setDestination("San Fransisco"); int totalGas = car.getAmountOfGas(); int requiredGas = car.gasRequiredForDestination(destination); boolean enough = car.hasEnou...

Design issues - observer,factory, composition and more

Hey, So i need to design something like that : I have a spreadsheet which can contain numerous sheets (maybe of different kinds). each sheet has let's say 1A-9Z cells. in each cell i can have one the above : String, Number, Formula - which means the cell gets an operation like +,-,/,* etc... and cells numbers, and in the cell i have ...

Adding Properties to Abstract Factory

I am relatively new to design patterns and am playing around with the GangOfFour Abstract Factory pattern in a project I am working on. I wanted to know the best way to introduce a property of type string called FileName which is needed for all of the Abstract Products produced by a Concrete Factory. Would I Add it to the Abstract Fact...

Extend from Generic Supertype?

In Java, am I able to extend from a generic supertype? According to this article, it looks like I should be able: http://www.ibm.com/developerworks/java/library/j-djc05133.html. However, when I do something similar in my application, I get the following error: "Cannot refer to the type parameter T as a supertype." Does anyone know if I...

Who should establish the relationship? The Entity or the Data Mapper?

There are four classes: StudentBase, CourseBase and StudentDataMapper, CourseDataMapper An Student object can have a relationship with an Course object. One Student can have many courses. One course can be visited by many students. In the ER diagram, a Student entity has an attribute called "courses", but a course does not know anyth...