design-patterns

Advantages of Domain object representing only elements of one type over being able to represent several different types of elements

hi 1) As far as I’m aware, each domain object instance ( at BLL layer ) should completely represent an element of the domain ( an employee, book, car etc ). So what is an advantage of having two types of domain objects, say one type representing a particular forum and other type representing a thread(s) in that forum, over having ...

Design pattern question for maintainability

I'm not sure if there is a pattern that should be used here but here is the situation: I have a number of concrete classes that implement an interface: public interface IPerformAction { bool ShouldPerformAction(); void PerformAction(); } I have another class that checks input to determine if ShouldPerformAction should be execut...

Stuctures of Complex and enterprise level applicaitons

I have a problem about structures of the complex applications .Because my knowledge background does not come from education , i have had always problem about application's layers , design patterns and programing structures.First of all , I can do whatever I want with php , because I know common functions and I have experience with php. B...

Modelling a car object (and its parts such as engine)

I am developing a class library which will include the object Car. The dilemma is, Car itself will be a class with fields such as Registration Number, and other general information on the car. But a car has an engine, chassis, etc. These objects need to be modelled too. Should they be classes embedded within Car? If not, what is the us...

What is the right code pattern for NSNumberFormatter?

What is the right code pattern for NSNumberFormatter? There are many example on the Internet (including this one: http://mac-objective-c.blogspot.com/2009/04/nsnumberformatter-some-examples.html) where the NSNumberFormatter is allocated and initialized each time it is needed. Yet some other examples in the Apple Documentation (includi...

Object Oriented Design issue

Hey, I have been designing a site locally in PHP 5, but have come across a few design issues I'd like advice now. Currently there are three features of the site and each feature has a class . These features are as follows : a blog a friends list a set of images I have a class for each but in each class I basically define a similar...

Testing and mocking with Flex

I am developing a "dumb" front-end, it's an AIR application that interacts with a "smart" LiveCycle server. There are currently about 20 request & response pairs for the application. For many reasons (testing, developing outside the corporate network, etc), we have several XML files of fake data, and if a certain configuration flag is se...

Virtual Methods or Events in C#

I'm currently writing a little C# library to simplify implementing little physical simulations/experiments. The main component is a SimulationForm that runs a timer-loop internally and hides boilerplate-code from the user. The experiment itself will just be defined through three methods: Init() (Initialize everything) Render(Graphics ...

OOP and Dynamic Typing (not Static vs Dynamic)

What OOP principles, if any, don't apply or apply differently in a dynamically typed environment as opposed to a statically-typed environment (for example Ruby vs C#)? This is not a call for a Static vs Dynamic debate, but rather I'd like to see whether there are accepted principles on either side of that divide that apply to one and not...

Why does UITableView make so many calls to its delegate & datasource?

Anyone care to shed some light on why UITableView makes so many repeat calls to its delegate & datasource as it's being setup? Just looking at one I'm working on now I see that numberOfSectionsInTableView is called 3 times and then viewForHeaderInSection cycles through 3 more times for each section (I have 2 sections so total of 6 times ...

Am I overdoing it with my Factory Method?

Hello. Part of our core product is a website CMS which makes use of various page widgets. These widgets are responsible for displaying content, listing products, handling event registration, etc. Each widget is represented by class which derives from the base widget class. When rendering a page the server grabs the page's widget from th...

Advanced javascript guidance

I'm looking to improve the standard of my javascript as I'm moving beyond simple AJAX forms towards much richer interactions and it's quickly getting out of hand. There's lots of resources about how to write proper javascript, many of the best are from Douglas Crockford, but very little about relevant design patterns and how to implemen...

Access control design patterns

I'm working on a PHP application, and I'd like to add access control to some of my objects. I didn't tag this question as PHP, as I feel this question is not language specific. Say I have a 'Service class' abstract class Service { } Many services use this as a baseclass. One pseudo example would be: class Companies extends Servic...

question of design / structure of application and separation of concerns

Hi all, So this question is a sort of follow on from here (http://stackoverflow.com/questions/1914097/how-to-deal-with-multiple-event-args). That question led me onto thinking about this but is different enough to warrant its own thread. I am creating a game (for fun and learning purpose) and would like to know if I am using good sta...

Design pattern question

i am a newbie to the design patterns and here is my question if we have an abstract class with few classes that implement it and each of this classes has different attributes. now i have another (Manager class) that holds an array of the abstract class and i want to put a search method in it ... how can i do that without casting to the...

Triggers/Callbacks in Ruby on Rails

Hello all, We are creating a system in Ruby on Rails and we want to be able to offer our users a bit of control about notifications and actions that can take place when some pre-defined trigger occurs. In addition, we plan on iterating through imported data and allowing our users to configure some actions and triggers based on that data...

Can't combine Factory / DI

Hi everyone: Just assume I have some class Foo, that has two dependencies: an ISerializer and an IFileAccessHandler. Now this class also has other depedencies, functional dependencies. I don't want anyone instantiating this class in an invalid state, so I'd also need to pass a domain object in the constructor. But how can I have tha...

collections and application wide use?

Here's a specific problem that I run into when creating objects, such as collections, that need to be available through the whole scope of the application. I have the following class: class UserDataCollection { List<UserData> Collection = new List<UserData>(); UserData current; public UserData Current ...

class design question

Suppose I have two classes class A { b bInstance; public A ( b newb ) { this.bInstance = newb; } } class B { // some data and methods go here } class List<A> { // list of A objects also holding reference to a B object } For every one object of A, there is a related object B. Now I want to do some op...

What is MVC in Ruby on Rails?

Could someone please explain MVC to me in Ruby on Rails, in layman terms. I am especially interested in understanding the Model in MVC (Can't get my head around the model) Thank you in advance. ...