design

Which form controls to use for a chatbox (.net)

Hi, as I am doing a small chat application in vb.net (windows form), I'm having problem for the design of my chatbox. I would like text messages to be selectable so user can copy(ctrl+v) it but not usernames which displays who sent the message. What form controls should I use in order to accomplish this and what properties to change from...

protected inheritance vs. public inheritance and OO design

When do you use each inheritance? class Base{}; class Derived: protected Base{}; class Derived2: public Base{}; My case: I have class called Snapshot which only contains GetXXX methods. It is a light-weight classed used to store current state of the Value class. I also use it for recovery, keeping instances of this class long after ...

Virtual behavior by storing pointers to member functions

Why is virtual behavior being prevented? class MyClass { //........ virtual double GetX(); virtual double GetSomethingElse(); virtual double GetT(); virtual double GetRR(); //........ }; class Processor { private: typedef double (MyClass::*MemFuncGetter)(); ...

Suggestions for Data Access Interface Name

I am looking for suggestions for an interface name. The interface is for the primitive CRUD methods that will be defined later in the DAL, however I need to use it in a lower-level API. The interface itself will just have the four members, Create(), Read(), Update(), and Delete(). I am currently thinking something along the lines of ID...

Which comes first - The Interface or the Class

During the process of designing new features in your software, which process is the best practice Design the Interface that the Class will implement. Writing the Class and extracting the Interface later. If going the route of number 2, when do you decide that an Interface is needed? ...

Abstract storage of data for class based on environment(web/windows).....

I have a class and the storage of its information is going to depend on if it is getting consumed by a web or windows application. I was going to use the factory pattern to pass out the correct object. I guess the caller would then store that object appropriately if I did not want to have recreate the object. Anybody have other sugges...

C# multiple class library with common base class/namespace problem

I'm new to c# and I'm trying to figure out if I can create multiple derived class libraries that each represent a specific item. I'll call the two class libraries ClassA & ClassB. Each class will share a BaseClass (namespace BaseNS). I then created a c# app that refrences both ClassA and ClassB. This generated an error because they b...

base enum class inheritance

Is there a pattern where I can inherit enum from another enum in C++?? something like that: enum eBase { one=1, two, three }; enum eDerived: public Base { four=4, five, six }; ...

Implementing a node-based graphical interface?

I would like to implement a nodal-interface, basically a DAG where each node performs an operation on it's input connections, and outputs something (which you can connect to another node) Some example applications: Apples "Shake" - screenshot The Foundrys "Nuke" - screenshot MindNode - screenshot vvvv - screenshots Quartz Composer - ...

Microsoft Best Practice Tutorials

Are there video tutorials for Microsoft Best Practices with the same caliber as asp.net and windowsclient.net Learn section? What I meant by Best Practices are practices wherein you develop just any kind of application. Take a look at the site for more info: http://msdn.microsoft.com/en-us/practices/default.aspx ...

Should destructors be threadsafe?

I was going through a legacy code and found the following snippet: MyClass::~MyClass() { EnterCriticalSection(&cs); //Access Data Members, **NO Global** members are being accessed here LeaveCriticalSection(&cs); } I am wondering will it help by any chance to guard the destructor ? Consider a scenario : 1. Thread1 - About to...

Premature Refactoring?

We have all heard of Premature Optimization, but what do you thing about Premature Refactoring? Is there any such thing in your opinion? Here is what I am getting at. First off, reading Martin Fowler's seminal work "Refactoring" quite literally changed my life in regards to programing. One thing that I have noticed, however, is that i...

Python: Abstract Base Class and ZopeInterface

What's the point of both? When do you think it's appropriate to use either? ...

When must you use poor design to finish a project?

There are many different bad practices, such as memory leaks, that are easy to slip into a program on accident. Sometimes, they might even be able to jury-rig your program together. I'm working on a project right now and it works if I deliberately put a memory leak in my code. If I take the leak out, the code crashes. Obviously this is...

Class design

I have 2 classes for the game i am making, gui class and the logic class, for a game of noughts and crosses. The GUI class has a method that uses an array of JButtons and returns them all with the same anonymous inner class action listener The problem is this, when i click the button i want the text to change to an x or a o dependant ...

What are some tricks I can use with macros?

In our legacy code, as well as our modern code, we use macros to perform nifty solutions like code generations, etc. And we make use of both the # and ## operators. I am curious how other developers use macros to do cool things, if they use them at all. ...

SQL queries not in one place but assembled dynamically while passing through several system layers. Is this a good practice?

I personally find that makes the life of a developer who has recently joined the project a very sad one. Without almost perfect understanding of the framework mechanisms it makes developing and debugging like a torture, since whenever I get an error or an unexpected behavior I have not a slightest idea where to look. In some rare cases C...

returning a set of keys in the map matching the criteria

First I will give a specific case, and the I would like to see if it can be applied to a general problem. Say I have map. And I want to get all the keys meeting a certain criteria. For example all keys that contain "COL". My naive implementation will be template<typename T> void Filter (map<string, T> & m, std:set<string> & result, ...

Moose or Meta?

I've been trying to do this a number of ways, but none of them seem graceful enough. (I'm also wondering if CPAN or Moose already has this. The dozens of searches I've done over time have shown nothing that quite matches.) I want to create a type of class that is a Base + Facade + Factory for other classes which load themselves as d...

How do you define a method in a class in its instance?

This is probably very easy, but I'm stumped. I would like to create a general purpose class which will be used multiple times in my program. I want this to be very lightweight and super fast. For a very simple example in C#: public class SystemTest { public TestMethod(string testString) { if(testString == "blue") ...