design

Is type checking ever OK?

Is type checking considered bad practice even if you are checking against an interface? I understand that you should always program to an interface and not an implementation - is this what it means? For example, in PHP, is the following OK? if($class instanceof AnInterface) { // Do some code } Or is there a better way of altering ...

Libraries for Choosing Color?

Do any open source libraries exist for programatically selecting and rating the compatibility of sets of colors using color theory? It would be very useful to be able to select color palettes based on simple color harmony rules like complimentary, analogous, triadic, and tetradic colors. ...

Singleton instance declared as static variable of GetInstance method

I've seen implementations of Singleton patterns where instance variable was declared as static variable in GetInstance method. Like this: SomeBaseClass &SomeClass::GetInstance() { static SomeClass instance; return instance; } I see following positive sides of this approach: The code is simpler, because it's compiler who respon...

How to implement "class versioning" (using different version of the same class)

Here is the problem : our main class (say : Contract) change every year. Some properties are added, other are removed. We don't know how it will look next year. It may change a lot or not at all. On the other hand, we now (new requirement...) have to keep an historic of every contracts. Each time the user update a contract, the whole ob...

C++ Custom GUI Button Question

Hello! I am designing a graphical application for which I've decided to write my own menu. I would like this menu to be platform independent. For the time being, my menu will mostly consist of a number of buttons. My issue involves the handling of events when a button is clicked. My dilemma is with a button "knowing" about the conte...

How important for programming skills is to have nice gadgets?

This question was asked by Ed Burns in his book 'Riding the Crest'. I remember that almost all of the rock star programmers found helpful if one had new and kool gadget. Programmer stays in touch with the latest design, hardware and software implementation which may affect also his work. What is your opinion on this question? ...

Programming Multi-Language PHP applications

Hello, I'm developing a PHP application and I'm wondering about the best way to include multi-language support for users in other countries. I'm proficient with PHP but have never developed anything with support for other languages. I was thinking of putting the language into a PHP file with constants, example: en.php could contain: ...

Designing a generic interface, require the type parameter on the type or method?

I have a very thin interface that's going to define one method. Should I require the type parameter on the class definition? public interface ISomethingFun<T> { void Do(T item); } or method definition? public interface ISomethingFun { void Do<T>(T item); } What rationale? Is one easier to implement, inherit, or generate dyn...

Best way to organize a class hierarchy including an overridable "Update" function

I have a base class "Foo" that has an Update() function, which I want to be called once per frame for every instance of that class. Given an object instance of this class called "foo", then once per frame I will call foo->Update(). I have a class "Bar" derived from my base class, that also needs to update every frame. I could give the...

Resources for building public information displays using HTML/CSS?

I would like to displays schedules, maps and other informations on displays in a building for visitors. These displays would provide at most mouse input but no keyboard. Ten years ago this was the domain of Macromedia Director but today I believe that browsers and content management systems provide a better architecture. However, I coul...

How do you design a class for inheritance?

I've heard it said that it is "difficult" to "design for inheritance", but I've never found that to be the case. Can anyone (and by anyone, I mean Jon Skeet) explain why this is allegedly difficult, what the pitfalls/obstacles/issues are, and why mere mortal programmers should not attempt it and just make their classes sealed to protect ...

What is the workflow you follow to design the software you're about to write?

Hi, I've started working on a fairly complicated software. It is for a personal project, but nonetheless I'm putting a lot of effort into it. Now, I'm used to work on other people's solutions / designs or on projects that grow in a very controllable way. This time, I started twice to code the basics and I rapidly found myself stuck. So ...

API design: Flexibility Vs. Ease-of-use

When writing a library or the public API of a module that will be used by a lot of other code in a variety of use cases, what is the best way to balance flexibility with ease of use? I believe that the two often conflict in that, the more flexible you make something, the harder it is to get it to do any one particular thing well. For...

Class Design Help Needed

Hi everyone, I am new to programming so i figured i'd get help from those that know it. I am currently writing a Registration Application which will basically take a users input, validates the data entered, displays a review screen (which the user must print out and mail in a copy), and then save the info entered to a database. Here ...

does anyone knows which Slideshow script is using Tumblr.com right now?

This is the URL. http://www.tumblr.com/ I think that its based on prototype, and is using an XML as a configuration file. Any idea? I'm needing and script like this, with a caption bar at the bottom. Thanks! PD: This is de code on at the source: <div id="featured_tumblelogs" style="margin-bottom:25px;"> <a href="http://hrrrth...

How lean do my C++ exception classes really need to be?

There are lots of places where guidelines for designing exception classes can be found. Almost everywhere I look, there's this list of things exception objects should never do, which impacts the design of those classes. For instance, the Boost people recommend that the class contain no std::string members, because their constructor coul...

Blog Architecture Design, using MVC and DDD

I'm designing a blog architecture on asp.net mvc. Lets say i only have 2 entities: post and comment. do i need a controller and a repository for each one? how goes the mechanism for displaying a post with it's comments? do the post controller looks in the posts repository for the post, then asks the comment controller to retrieve all the...

Separate field for Initial in name

A question (mostly) directed at US developers: what is the common way for entering and storing the initial in a name? Two fields: LastName = "Doe" FirstName = "John, T." or Three fields: LastName = "Doe" Initial = "T" FirstName = "John" Also, will users expect to see the initial when the name is displayed or printed? ...

What architecture? Distribute content building across a cluster.

Hi All, I am building an content serving application composing of a cluster of two types of node, ContentServers and ContentBuilders. The idea is to always serve fresh content. Content is fresh if it was built recently, i.e. Content.buildTime < MAX_AGE. Requirements: *ContentServers will only have to lookup content and serve it up (...

Where to put the GetObjectColletion Methods?

An app has a Foo class that is a concrete class with all business logic and behaviour properly defined. That said, one need to get the collection of all the Foos that are persisted at this app. Where should this "IEnumerable GetFoos()" method be placed? Not at the Foo class itself, right? ...