design

C# Design Questions

How to approach unit testing of private methods? I have a class that loads Employee data into a database. Here is a sample: > public class EmployeeFacade { public Employees EmployeeRepository = new Employees(); public TaxDatas TaxRepository = new TaxDatas(); public Accounts AccountRepository = new Accounts(); ...

Interview question: Develop an application that can display trail period expires after 30 days without external storage

Hi, I saw this question in a forum about how an application can be developed that can keep track of the installation date and show trail period expired after 30 days of usage. The only constraint is not to use the external storage of any kind. Question: How to achieve this? Thanks Bala --Edit I think its easy to figure out the place ...

Should I use custom exceptions to control the flow of application?

Is it a good practise to use custom business exceptions (e.g. BusinessRuleViolationException) to control the flow of user-errors/user-incorrect-inputs??? The classic approach: I have a web service, where I have 2 methods, one is the 'checker' (UsernameAlreadyExists()) and the other one is 'creator' (CreateUsername())... So if I want to...

What is your custom exception hierrarchy?

My question is: how would you create exception hierarchy in your application? Designing the architecture of an application, from my perspective, we could have three types of exceptions: the built-in (e.g.: InvalidOperationException) custom internal system faults (DB transaction failed on commit, DbTransactionFailedException) custom...

Top-down or bottom-up design?

There are basically those two approaches to designing a system. What are the advantages and disadvantages? When should I use which? Should I combine those approaches? How? ...

building an XML service parsing library

This is more of a design question I suppose. My company offers a web service to our client that spits data out in a custom xml format. I'd like to build a java library we can offer so our customers can just feed it the url and we will turn it into a set of POJOs built from the response. I can obviously just create a library that will d...

Question About Classic MVC

Hello, In classic MVC the model notifies the view about changes made on it. In C# this means I have to subclass the View I'm interested in and in the subclassed class register to the model's event. For example, if I were to implement MVC using C# and Winforms, I had to subclass TextBox class and then register inside the MyTextBox's cons...

What division operator symbol would you pick?

I am currently designing and implementing a small programming language as an extra-credit project in a class I'm taking. My problem is that the language has three numeric types: Long, Double, and Fraction. Fractions can be written in the language as proper or improper fractions (e.g. "2 1/3" or "1/2"). This fact leads to problems such as...

Choosing a design pattern for a class that might change it's internal attributes

I have a class that holds arbitrary state and it's defined like this: class AbstractFoo { }; template <class StatePolicy> class Foo : public StatePolicy, public AbstractFoo { }; The state policy contains only protected attributes that represent the state. The state might be the same for multiple behaviors and they can be replaced at ...

Would this constructor be acceptable practice?

Let's assume I have a c++ class that have properly implemented a copy constructor and an overloaded = operator. By properly implemented I mean they are working and perform a deep copy: Class1::Class1(const Class1 &class1) { // Perform copy } Class1& Class1::operator=(const Class1 *class1) { // perform copy return *this; } Now l...

How to extend a large website to an iPhone app?

I am trying to create an iPhone app for a large website (as big as amazon.com) and it involves using cookies and what not to get authenticated via the Apache intercepter and access the web services exposed by the main website. For that I am looking for strategies to go about developing it. I am new to iPhone development and I am mostly l...

Advantage of using a static member function instead of an equivalent non-static member function?

I was wondering whether there's any advantages to using a static member function when there is a non-static equivalent. Will it result in faster execution (because of not having to care about all of the member variables), or maybe less use of memory (because of not being included in all instances)? Basically, the function I'm looking a...

Web Applications Development: Security practices for Application design

Hi, As I am creating more web applications that are targeted for multiple users, I figured out that I have to start thinking about user management and security. At a glance and in my ideal world, all users belong to a group. Permissions and access is thus defined per group (and inherited by the users of that group). Logically, I have m...

Algorithm to find best 8 minute window in a 1 hour run

An activity runs for a bit more than an hour. I need to get the best 8 minute window, where some parameters are maximum. For example, a value x is measured every second. If my activity runs for one hour, I get 3600 values for x. I need to find the best continuous 8 minute time interval where the x value was the highest among all the...

database design - empty fields

Hey, I am currently debating an issue with a guy on my dev team. He believes that empty fields are bad news. For instance, if we have a customer details table that stores data for customers from different countries, and each country has a slightly different address configuration - plus 1-2 extra fields, e.g. French customer details may...

Who architected / designed C++'s IOStreams, and would it still be considered well-designed by today's standards?

First off, it may seem that I'm asking for subjective opinions, but that's not what I'm after. I'd love to hear some well-grounded arguments on this topic. In the hope of getting some insight into how a modern streams / serialization framework ought to be designed, I recently got myself a copy of the book Standard C++ IOStreams and Lo...

Java: Friendlier way to get an instance of FontMetrics

Hi people, Is there a friendlier way to get an instance of FontMetrics than FontMetrics fm = Graphics.getFontMetrics(Font); I hate this way because of the following example: If you want to create in a game a menu and you want all the menuitems in the center of the screen you need fontmetrics. But, mostly, menuitems are clickable. So...

C++ socket protocol design issue (ring inclusion)

So I have these two classes, mpqs_client and client_protocol. The mpqs_client class handles a Boost socket connection to a server (sending and receiving messages with some specific format. Upon receiving a message, it calls a static method, parse_message(..), in the class client_protocol, and this method should analyse the message receiv...

Web-design / UI advice

I'm working on a website on a Fmylife style. Now the homepage is the page showing the list of the latest posts. But I think there is a problem with that: The most "interesting" page is the one showing the top posts of the last days, but that page has very few visits compared to the main page. I suppose that's only because the main page i...

How do I dynamically instantiate a class in javascript?

I'm starting out with classes in Javascript and have hit a wall. I've looked all over for a tutorial that goes a little further than simply how to construct a class (usually Animal) then extend the class and have a Method do something (Dog alert('Bark');). I have created a class that I want a user to be able to instantiate (is that the ...