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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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
...
-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?
...
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, ...
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...
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
...
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...
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...
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...
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...