code-separation

C++ Header Files, Code Separation

Hi, I am new to C++ and I had a few general questions about code separation. I have currently built a small application, all in one file. What I want to do now is covert this into separate files such that they contain similar code or whatnot. My real question right now is, how do I know how to separate things? What is the invisible m...

C++ code in header files

My personal style with C++ has always to put class declarations in an include file, and definitions in a .cpp file, very much like stipulated in Martin York's answer to C++ Header Files, Code Separation. Admittedly, part of the reason I like this style probably has to do with all the years I spent coding Modula-2 and Ada, both of which h...

Multiple Singleton Instances

Hi all: I am writing a library of utility classes, many of which are singletons. I have implemented them as such using inheritance: template <class T> class Singleton { public: T& getInstance() { if(m_instance == 0) { m_instance = new T; } return m_instance; } ...

Code Separation Paradox: Create HTML Tree from Multi-Dimensional Array AND Keep the HTML Outside of the Recursive Function

This working code seems to be the typical solution to this problem. It takes a multi-dimensional array that holds categories and their subcategories (with no implied limitation on how many levels deep it goes) and creates an HTML unordered list from it, echoing it out onto the page from inside a recursive function. Sub-levels are trave...

.net mvc single admin section multiple sites

Hi, Desired outcome: 4 customer facing sites as separated projects 1 set of admin code used by all four sites My current setup is 4 Projects: Core for models/entities Data for repositories Controllers for, well, controllers Web for views Now, the Web project contains views for admin and customer facing sides. I'm wanting to split ...

PHP: Where should I store the text for info & warning messages

Hello, I have a question concerning the design of my project's Code. In most cases, it is important to separate content from code (HTML mixed with PHP in bigger apps=No good idea, etc.) but how should I handle things like the text of error messages? Assuming this one message will be only used in one case/PHP file: MessageBox( 'Somethi...

Implementation of achievement systems in modern, complex games

Many games that are created these days come with their own achievement system that rewards players/users for accomplishing certain tasks. The badges system here on stackoverflow is exactly the same. There are some problems though for which I couldn't figure out good solutions. Achievement systems have to watch out for certain events al...

ASP.Net MVC - What replaces events to support loose coupling?

What feature(s) of ASP.Net MVC can replace the way events can be used in Webforms to support loosely coupled components? For example, take a simple pager control in Webforms: A page number is clicked Pager fires off a "PageChange" event with the new page number This subscribing page/control received the event and handles initiating a ...

Separating UI and logic in C#

Does anyone have any advice on keeping logic out of my GUI classes? I try to use good class design and keep as much separated as possible, but my Form classes usually ends up with more non-UI stuff mixed in than I'd like, and it tends to make maintenance a real pain. (Visual Studio 2008 Professional, C#, Windows apps). Many thanks. ...

Determining the representation-class for a data object based on its specialized type?

I tend to have a class to describe a general concept and subclasses to describe variances in that concept. For example, Polygon <|-- {Rectangle, Triangle, etc.}. However, I often find I have various representations of these hierarchies. For example, I want to keep the graphical representation (eg, a QPolygon), or the physical represen...

Debug class, c++, linker error

Hello all, I am trying to write a debug class for a project I am working on, and I do not want to have to pass a debug object around so I was trying to do it this way. However, I do not know why my compiler or linker seems to be skipping the implementation I am writing for it. If I add #include "Debug.cpp" to main.cpp this code works j...