design

Do people provide multiple mechanisms for doing the same thing in an API?

Is it confusing to design an API with multiple ways of achieving the same outcome? For example, I have my own Date library (which is a simple wrapper around the Java Date/Calendar classes to distinguish a year-month-day, Date, from an instant-in-time, Instant and provide mechanisms to convert between the two). I started off with one meth...

RFC with implementing a modular architecture

Looking for opinions on the modularization of web applications. Already most applications regardless of language have a backend DB and support tie-ins with their respective web application server (Apache, IIS, Lighttp, etc ) but a lot of developers I've dealt with have problems coming to terms with using Memcached or anything outside of...

When to violate YAGNI?

The YAGNI "principle" states that you shouldn't focus on providing functionality before you needed as "you ain't gonna need it" anyway. I usually tend to use common sense above any rule, no matter what but there are some times when I feel it is useful to over design or future proof something if you have good reasons, even if it's possib...

What for should I mark private variables as private if they already are?

Hello. As far as I know, in C# all fields are private for default, if not marked otherwise. class Foo { private string bar; } class Foo { string bar; } I guess these two declarations are equal. So my question is: what for should I mark private variables as private if they already are private? ...

Different ways to implement 'dirty'-flag functionality

Almost every programmer did it once in his life: setting some flag if a variable's value changed. There's always lots of properties and you want to keep track if something changed in any property in a specific property or in some set of properties I'm interested in different ways to implement the "dirty-flag" functionality for the a...

Top tips for designing GUIs?

A while back I read (before I lost it) a great book called GUI Bloopers which was full of examples of bad GUI design but also full of useful tidbits like Don't call something a Dialog one minute and a Popup the next. What top tips would you give for designing/documenting a GUI? It would be particularly useful to hear about widgets you d...

How to make a search usercontrol generic in .net2.0 winforms

I have a search usercontrol that I'd like to make generic. The control itself will contain a different collection of controls dependent on its context. For example it could be stock items, people, address as the context of the search.. How can I make it generic enough that based upon the search context it knows exactly what user contro...

Shoud I make an IUnityContainer object use a Singleton pattern?

Howdy, I am new to using Unity and IoC/DI concepts. I started with the concept by rolling my own via James Kovacs' show on dnrTV in a test. His example had the Container run as a singleton accessed through a static method in an IoC class so you could register types at a startup and resolve the type throughout your application. ...

OO Design - Separating Instance-specific functions from class-specific functions

Given a class that is semantically supposed to be an object of a certain type, but also has multiple operations for operating on objects of its own type, what is the best way(pattern?) of organizing the class in this type of scenario? I find this to be a common occurrence when a developer creates objects but is thinking with a procedural...

Is this a reasonable user registration process?

I'm working on a registration process for an internal application. My initial design is below. My main question is whether it's really necessary to include a registration_confirmation_code. Does it protect the app from a realistic threat or just add unnecessary complexity? I'm not sure about that. User enters email address. Since th...

CSS Sprites don't work in IE[8/7/6]

I'm trying to CSS use sprites to animate my Risk Matrix ... it works just fine in Firefox and Chrome, but image won't show up in IE ... The code is below, don't want to paste the whole thing in here, but the excerpt shows the pattern: <dl id="rmMap4x4"> <dd id="m4p4s1"> <a onclick="setDropDownListValues(4,1,3,4)" onmouseover="setDropD...

Do you rebuild or enhance enterprise applications ?

When I walk to work (in London) I see loads of redevelopment on commercial buildings. One of the first this I notice is they knock down the old building and build from scratch. They end up building some of the most advanced and stunning to look at buildings. Bearing this in mind, when I look at old legacy code, in existing application...

How to improve method for assigning grid permissions

I've got an ASP.NET (VB.NET) page that has an Infragistics grid on it. One of the columns is called 'status'. When I load the grid, I'm setting permissions to the fields at the column level, granting user roles (ENUM 'UserTypes') read/only or read/write permissions. Next I need to loop through each row and assign permissions based upo...

Where do all "bulk" operations belong in DDD?

In DDD one of the key concepts is Repository, which allows you to retrieve Entities (or Aggregate Roots) and then save them back after they are updated. Let assume that we need to perform some 'bulk' operation with entities, and the number of entities makes it absolutely impossible to retrieve them into memory. I.e. operation can only b...

Multiple Modes for a Form or Control in a .NET Application?

Are there any opinions on whether or not it is bad design to reuse a Form or Control in a WinForms .NET application by giving it multiple modes? I often find myself wanting to do this. I'll have some UI that needs to be used in multiple places and instead of reusing the code, I'll give the form a mode that determines things like what tex...

How to enforce a "has a" relationship and protect the object that "is had"

Given the following code: Class User{ Task m_Task; public function getTask("Do work") { return m_Task; } } Class Project{ Task m_Task; public function getTask("Do work") { return m_Task; } } Class Task { private m_Name; public Task(name) { m_Name = name; } } Class Evil { new Task = Error } In a language that does ...

Difference between events and delegates and its respective applications

I don't see advantages of using events over delegates, other than being syntactical sugar . Perhaps I am misunderstanding, but it seems that events is just a placeholder for delegate. Would you guys explain to me the differences and when to use which? what are the advantages and disadvantages? Our code is heavily rooted with events, a...

How can I use "float: left" in a div without breaking the containing element's height?

It seems that floated HTML elements don't expand the heights of their containers. For example, consider the following code: <div class="portfoliosite" style="background: #777777; padding: 10px; width: 550px;"> <div class="portfoliothumbnail" style="background: red; margin: 0 10px 10px 0; float: left; height: 150px; width: 150px;"><!...

Ab-using languages

Some time ago I had to address a certain C# design problem when I was implementing a JavaScript code-generation framework. One of the solutions I came with was using the “using” keyword in a totally different (hackish, if you please) way. I used it as a syntax sugar (well, originally it is one anyway) for building hierarchical code struc...

DAL desing using DAAB 3.5/4.0

I'm working on a .Net 3.5 web application.It has various modules say for example Customers,Orders,etc.... I need to a design Data Access Layer (DAL) for the same using Enterprise Library 4.0 (using Data Access Application block or DAAB) to connect to SQL Server 2005. Here is how i plan to go about it: • Have an interface called "IData...