design-patterns

Overuse of mixin is evil and what are the alternative solutions?

Sometimes using mixin with multiple inheritance can help us improve reusability of our code. For example, the following design class FollowableMixin(object): def get_followers(self): ... ... class User(FollowableMixin): ... may be better reused than simply adding get_followers to User: class User(object): de...

What pattern to use when invoking multiple external apps?

Given a set of external apps (app1.exe, app2.exe, ... ). Invoking one app will change something. Sometimes the result needs to be analyzed, sometimes is just a prerequisite for other apps. If one fails, abort process. All apps need to be invoked, in a specific order, and they must succeed in order to finalize without errors. Is there a...

Scalability issues for a complex process consuming php application?

Hi Consider a somewhat process consuming PHP application that works heavily with complex DB transactions, and doesn't have any choice but to have fairly high memory consuming algorithms. Like up to 4MB memory usage per request. (1 MB on average for those certain requests, less than 200KB of variable data for regular requests) Its obvious...

Best practices for huge volumes of data load/unload?

My question applies to ETL scenarios, where transformation is performed outside of database (completely). If you were to Extract, Transform, and Load huge volumes of data (20+ million records or more) and the databases involved are : Oracle and MSSQL Server, what would be the best way to: Effectively read from the source database : I...

Problem Domain for Design Patterns

I was asked during an interview for an entry level coder position about how much I knew about design patterns. Actually, the interviewer brought out a hard-cover book (Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) and asked me, enthusiastically, if I had...

How to remove repetitive code that differ in using properties/fields for displaying themselves as strings?

I have two extension methods that are very similar. I'd like to remove the code duplicates with «the hole in the middle» pattern or the like, but can't really get it to work. The code looks like so: public static String GetPublicPropertiesAsString( this Object @this ) { return @this.GetType().GetProperties() .Select( proper...

Design pattern to handle settings in subclasses?

Dear friends, I have a small hierarchy of classes that all implement a common interface. Each of the concrete class needs to receive a settings structure containing for instance only public fields. The problem is that the setting structure has a part common to all classes has another part that vary from one concrete class to anoth...

Design pattern for web chat client

Hi, I am developing a desktop client app for web chat. Something that is similar to icq, pidgin, skype, etc. The client app communicates with the server through POST and GET. Client app has these methods: login logout loadFriendList SearchUser AddFriend SendMessage LoadMessages I would like to use a design pattern for this winforms...

Design pattern for handling many parameters and business rules

I am working on a project that is responsible for creating a "job" which is composed of one or more "tasks" which are persisted to a database through a DAL. The job and task columns are composed of values that are set according to business rules. The class, as it exists now, is getting complicated and unwieldy because the business rules...

Pattern for switching between discrete modes of behaviour

Design philosophy question: Suppose I have a user control which draws a graph of the characteristics of a collection of objects. The control is placed on a form with a long-lived controller class that exposes the collection of objects to draw from. The form also contains a control which allows to switch between 'modes' or different p...

Object Factory Question - using database query information to create objects

I have several objects, like products, order, etc. When I get information from my database I take a row and create one of the types of objects. I then work with that object created. I read this is called a factory. Is there some advantage to doing this? Especially in a loosely typed language like PHP? Thanks edit: is this where I g...

In which scenario do we use the Factory Pattern and in which the Singlton Pattern?

Hi Experts, Please help me to understand the Factory pattern and Singleton pattern, when we need to use Factory pattern and when use Singleton pattern. What is the main advantage/disadvantage one over other? Any suggestion(explanation) will help me lot. Thanks Vijendra Singh ...

What is a good design-pattern for a configurable series of steps

-Given a series of x number (unknown) steps, -all of which implement the same interface, -and where the order of the steps is desired to be configurable, can anyone suggest a good design pattern? ...

Design pattern: Which one to choose?

First of all this is all just concept, I have no actual programming done yet. This is the situation: I have a Class A which uses the Filesystemwatcher to watch for changes in a folder. (using events) Then I have a 'Collection Class' B which has a List of A's. Now what I want to happen is as follows, A Change happens with the folder, ...

Bunch of private properties executed one by one

Is this a sign, that some design pattern is needed here? /** * @return string */ public function filter($string) { // underscored means private $this->_prepareSomething($string); $this->_prepareSomething2(); $this->_prepareSomething3(); $this->_prepareSomething4(); $this->_prepareSaveSomethingToFile(); re...

ASP.NET Design Question - Factory vs Dynamically choosing code behind (if this is possible)

I have a generic editor in ASP.NET page for editing lookup values for different database tables. The code behind uses a base class which handles 99% of the work across all the different lookups in the system. A C# class is passed in to the base class from the code behind as below. public class LookupPageBase : System.Web.UI.Page ...

Designing an MVC (web) application from scratch – What Are the basic (necessary and optional) components I should be aware of?

Hi, I’m about to write quite a big web site that will basically be a forum, divided to (many) different subjects and allow users’ score. I’ll be using MVC, so I (“naively”) asked this question about how to partition the Model portion  of MVC, which is likely to be very large. Two things I realized from the answers I got: I really do...

if using an interface should a class always strictly implement an interface

The better way to ask this question would be an example as follows What are the pros and cons of the 2 approaches? Is one always better than the other or under specific circumstances? If using Approach1, using an interface would be moot right? since anyone can access the public methods anyway? public interface IDoSomething { void Meth...

How to build a generic repository

I'm developing a web application in ASP.NET MVC with NHibernate. Based in articles and tutorials I've found at Google, I'm using Repository for my classes. I have 10 classes and 10 repositories. Today I figured out that 90% of mine repositories are exactly equal each other, except for the class. This is one example: public class Promo...

SOA Data Contract Patterns. I am sure the framework I am using introduces redundancy, anyone care to enlighten me?

I'll start in the way most people seem to have taken to, on here.... So I was.... Nah thats gash. I'll start again (might lose a few points for not being straight to the point but wth) Right, I have inherited a framework which utilities WCF to provide some operation and data contracts. This might be irksome to some, but I haven't...