design

Structuring Win32 GUI code

I wish to improve my code and file structure in larger Win32 projects with plenty of windows and controls. Currently, I tend to have one header and one source file for the entire implementation of a window or dialog. This works fine for small projects, but now it has come to the point where these implementations are starting to reach 100...

c++ - what is faster ?

If we have the following 2 snippets of code in c++ that do the same task: int a, b=somenumber; while(b > 0) { a = b % 3; b /= 3; } or int b=somenumber; while(b > 0) { int a=b%3; b /= 3; } I don't know much about computer architecture/c++ design, but i think that the first code is faster because it declares the integer a at the begi...

How to run this Qt script? (newbie question)

I have a Qt script (barchart.qs) that creates a graph for me. I don't know how I can incorporate (i.e. show the graph) in my Qt mainwindow. Can someone please help me look at the code and what its outputs are? I tried engine.evaluate, but I don't know what is the QScriptValue I'm getting in return. Thanks sooo much. This is the script: ...

Proper abstraction of the database tier in a 3 tier system?

Hello, I am creating a 3 tier application. Basically it goes Client -> (through optional server to be a thin-client) -> Business Logic -> Database Layer And basically making it so that there is never any skipping around. As such, I want for all of the SQL queries and such to be in the Database Layer. Well, now I'm a bit confu...

Just wondering what is the reason of InvalidOperationException in Enumerable.Aggregate<TSource>?

Why only one overload throws this exception? Little update: I understand that there was a design decision made by framework developers. The question is really why that decision has been made, is there a related design pattern or whatever? Because if I was designing that I'd return default(TSource). What is wrong with such approach? ...

Constructors + Dependency Injection

If I am writing up a class with more than 1 constructor parameter like: class A{ public A(Dependency1 d1, Dependency2 d2, ...){} } I usually create a "argument holder"-type of class like: class AArgs{ public Dependency1 d1 { get; private set; } public Dependency2 d2 { get; private set; } ... } and then: class ...

Database access through collections

Hi All, I have an 3 tiered application where I need to get database results and populated the UI. I have a MessagesCollection class that deals with messages. I load my user from the database. On the instantiation of a user (ie. new User()), a MessageCollection Messages = new MessageCollection(this) is performed. Message collection accep...

Exception design: Custom exceptions reading data from file?

I have a method that reads data from a comma separated text file and constructs a list of entity objects, let's say customers. So it reads for example, Name Age Weight Then I take these data objects and pass them to a business layer that saves them to a database. Now the data in this file might be invalid, so I'm trying to figure ou...

What makes an effective UI for displaying versioning of structured hierarchical data

Traditional version control system are displaying versioning information by grouping Projects->Folders->Files with Tree view on the left and details view on the right, then you will click on each item to look at revision history for that configuration history. Assuming that I have all the historical versioning information available for ...

Wrappers/law of demeter seems to be an anti-pattern...

I've been reading up on this "Law of Demeter" thing, and it (and pure "wrapper" classes in general) seem to generally be anti patterns. Consider an implementation class: class FluidSimulator { void reset() { /* ... */ } } Now consider two different implementations of another class: class ScreenSpaceEffects1 { private FluidSim...

Delphi memory management design strategies : Object or Interface ?

Regarding Delphi memory management, what are your design strategies ? What are the use cases where you prefer to create and release Objects manually ? What are the uses cases where Interfaces, InterfacedObjects, and their reference counting mechanism will be preferred ? Do you have identified some traps or difficulties with reference...

How to best integrate HTML/design with C# code in ASP.Net or ASP.Net MVC?

We're working on a new ASP.Net site. The last major site we did was in classic ASP--the procedure we used there was to have the HTML completed first, then "bring it to life" with the ASP code. In the ASP.Net world, how does this work? I.e. how do the designers do their work if much of the mark-up is actually being generated by the ser...

How do you keep your business rules DRY?

I periodically ponder how to best design an application whose every business rule exists in just a single location. (While I know there is no proverbial “best way” and that designs are situational, people must have a leaning toward one practice or another.) I work for a shop where they prefer to house as much of the business rules as p...

Programming tips for writing document editors?

I'm asking this because I'm in the process of writing two such editors for my Mega Man engine, one a tileset editor, and another a level editor. When I say document editor, I mean the superset application type for things like image editors and text editors. All of these share things like toolbars, menu options, and in the case of image ...

C# Running several tasks at different intervals

A design question: I'd like to build a Windows service that executes different commands at different intervals. For simplicity's sake, let's say I want to run some batch files. The input it gets is a list of files and the intervals at which to execute. For example: a.bat - 4 minutes b.bat - 1 minute c.bat - 1 minute d.bat - 2 minutes I...

Are there old versions of Windows UX guidelines somewhere?

Since I've read Windows User Experience Interaction Guidelines (there's a PDF download avaliable) I've found it to be admirably self-deprecating, humbly pointing out their own horrible UI practices long scolded by Joel Spolsky. I'd like to know, however, what they had in mind while they made those mistakes. Is this (terrific) UX Guid...

user interface pattern for associating single or many objects to an entity

Need suggestions on implementing associating single or many objects to an entity. All soccer team players are registered individually (e.g. they are part of 'players' table) A soccer team has many players. The click sequence is like this:- a] Soccer team owner provides a name and brief description of the soccer team. b] Now it wants to...

Inheritance: when implementing an interface which define a base class property why cant the class implementing interface return a derived class type object

Lets create some interfaces public interface ITimeEventHandler { string Open(); } public interface IJobTimeEventHandler : ITimeEventHandler { string DeleteJob(); } public interface IActivityTimeEventHandler : ITimeEventHandler { string DeleteActivity(); } public interface...

Where do you start your design - code, UI, workflow or whatever?

Hi I was discussing this at work, and was wondering where people start their designs? We tend to start with designing code to solve the problem presented to us, but that is probably all of us are (or were) programmers. I was wondering where other people and organisations start their design. Do they start with solving the problem as a ...

What should I do if i have a factory method which requires different parameters for different implementations?

I have an interface, IMessage and a class which have several methods for creating different types of message like so: class MessageService { IMessage TypeAMessage(param 1, param 2) IMessage TypeBMessage(param 1, param 2, param 3, param 4) IMessage TypeCMessage(param 1, param 2, param 3) IMessage TypeDMessage(param 1) ...