Questions about problem solving and planning for a solution through software design.

learn more… | top users | synonyms (1)

219
votes
16answers
16k views

Project is nearly done, but procedural spaghetti code. Do I rewrite or just keep trying to ship it? [closed]

I'm a beginner web developer (one year of experience). A couple of weeks after graduating, I got offered a job to build a web application for a company whose owner is not much of a tech guy. He ...
191
votes
18answers
77k views

How can one manage thousands of IF…THEN…ELSE rules?

I am considering building an application, which, at its core, would consist of thousands of if...then...else statements. The purpose of the application is to be able to predict how cows move around in ...
146
votes
20answers
12k views

How do quick & dirty programmers know they got it right?

If you ask programmers why they should write clean code, the number one answer you get is maintainability. While that's on my list, my main reason is more immediate and less altruistic: I can't tell ...
121
votes
5answers
8k views

What are good habits for designing command line arguments?

While developing the application I started to wonder - How should I design command line arguments? A lot of programs are using formula like this -argument value or /argument value. Solution which ...
114
votes
17answers
24k views

Is premature optimization really the root of all evil?

A colleague of mine today committed a class called ThreadLocalFormat, which basically moved instances of Java Format classes into a thread local, since they are not thread safe and "relatively ...
98
votes
11answers
18k views

The modern way to perform error handling…

I've been pondering this problem for a while now and find myself continually finding caveats and contradictions, so I'm hoping someone can produce a conclusion to the following: Favour exceptions ...
93
votes
5answers
69k views

When do you use a struct instead of a class? [closed]

What are your rules of thumb for when to use structs vs. classes? I'm thinking of the C# definition of those terms but if your language has similar concepts I'd like to hear your opinion as well. I ...
91
votes
8answers
9k views

Is this a violation of the Liskov Substitution Principle?

Say we have a list of Task entities, and a ProjectTask sub type. Tasks can be closed at any time, except ProjectTasks which cannot be closed once they have a status of Started. The UI should ensure ...
86
votes
17answers
23k views

Is it a good idea to design an architecture thinking that the User Interface classes can be replaced by a command line interface?

In Code Complete page 25, it's said that it's a good idea to be able to easily replace the regular user interface classes by a command line one. Knowing its advantages for testing, what about the ...
85
votes
12answers
11k views

Is testable code better code?

I'm attempting to get into the habit of writing unit tests regularly with my code, but I've read that first it's important to write testable code. This question touches on SOLID principles of writing ...
82
votes
10answers
10k views

Are design patterns really essential nowadays?

I was reading "Coders at Work" and have faced the fact that some of the professionals interviewed in the book are not so enthusiastic about design patterns. I think that there are 2 main reasons for ...
82
votes
16answers
35k views

Is it wrong to use a boolean parameter to determine behavior?

I have seen a practice from time to time that "feels" wrong, but I can't quite articulate what is wrong about it. Or maybe it's just my prejudice. Here goes: A developer defines a method with a ...
81
votes
8answers
13k views

What is “Soft Coding”, really?

In this article by Alex Papadimoulis, you can see this snippet: private void attachSupplementalDocuments() { if (stateCode == "AZ" || stateCode == "TX") { //SR008-04X/I are always required in ...
80
votes
18answers
4k views

Design flaws and dealing with humiliation from it [closed]

Have you always been fundamentally correct in the software designs you proposed? When you give out some design that was fundamentally wrong, you tend to lose the respect of your fellow team members. ...
80
votes
11answers
5k views

Why should main() be short?

I've been programming for over 9 years, and according to the advice of my first programming teacher, I always keep my main() function extremely short. At first I had no idea why. I just obeyed ...
79
votes
9answers
8k views

I can write code… but can't design well. Any suggestions? [closed]

I feel that I am good at writing code in bits and pieces, but my designs really suck. The question is, how do I improve my designs - and in turn become a better designer? I think schools and colleges ...
75
votes
16answers
5k views

Should we design programs to randomly kill themselves? [closed]

In a nutshell, should we design death into our programs, processes, and threads at a low level, for the good of the overall system? Failures happen. Processes die. We plan for disaster and ...
72
votes
7answers
10k views

Should I follow the normal path or fail early?

From the Code Complete book comes the following quote: "Put the normal case after the if rather than after the else" Which means that exceptions/deviations from the standard path should be put ...
71
votes
14answers
29k views

What is the ideal length of a method for you? [closed]

In object-oriented programming, there is of course no exact rule on the maximum length of a method , but I still found these two quotes somewhat contradicting each other, so I would like to hear what ...
69
votes
11answers
5k views

Advice on designing web application with a 40+ year lifetime

Scenario Currently, I am apart of a health care project whose main requirement is to capture data with unknown attributes using user generated forms by health care providers. The second requirement ...
66
votes
9answers
51k views

Why use partial classes?

In my understanding, the partial keyword does nothing but allow a class to be split between several source files. Is there any reason to do this other than for code organization? I've seen it used for ...
66
votes
6answers
7k views

How to manage accidental complexity in software projects

When Murray Gell-Mann was asked how Richard Feynman managed to solve so many hard problems Gell-Mann responded that Feynman had an algorithm: Write down the problem. Think real hard. Write down the ...
63
votes
16answers
13k views

Do I really need oop for my kind of job? After 10 years I think I don't [closed]

After 10 years of writing something like business logic for my company I realized that for 95% of my code I just don't need any special OO techniques. For years I tried to get better with all that OO ...
62
votes
4answers
5k views

Why were Java collections implemented with “optional methods” in the interface?

During my first implementation extending the Java collection framework, I was quite surprised to see that the collection interface contains methods declared as optional. The implementer is expected ...
59
votes
10answers
4k views

My proposed design is usually worse than my colleague's - how do I get better? [closed]

I have been programming for couple of years and am generally good when it comes to fixing problems and creating small-to-medium scripts, however, I'm generally not good at designing large scale ...
59
votes
11answers
6k views

“Everything is a Map”, am I doing this right?

I watched Stuart Sierra's talk "Thinking In Data" and took one of the ideas from it as a design principle in this game I'm making. The difference is he's working in Clojure and I'm working in ...
54
votes
10answers
3k views

What is meant by, “A user shouldn't decide whether it is an Admin or not. The Privileges or Security system should.”

The example used in the question pass bare minimum data to a function touches on the best way to determine whether the user is an administrator or not. One common answer was: user.isAdmin() This ...
54
votes
12answers
5k views

Is it bad practice to pass instances through several layers?

In my program design, I often come to the point where I have to pass object instances through several classes. For example, if I have a controller that loads an audio file, and then passes it to a ...
54
votes
11answers
73k views

SQL: empty string vs NULL value

I know this subject is a bit controversial and there are a lot of various articles/opinions floating around the internet. Unfortunatelly, most of them assume the person doesn't know what the ...
54
votes
7answers
54k views

When to use abstract classes instead of interfaces with extension methods in C#?

"Abstract class" and "interface" are similar concepts, with interface being the more abstract of the two. One differentiating factor is that abstract classes provide method implementations for derived ...
53
votes
15answers
3k views

Is it normal to think about a design problem for days with no code written? [closed]

Sometimes I stare blankly into space or sketch ideas and write some pseudo codes on paper. Then I scratch it out and start again, then when I think I have the correct solution for the problem I begin ...
53
votes
12answers
3k views

How to take a step back and look at code with fresh eyes? [closed]

I've spent the last year as a one-man team developing a rich-client application (35,000+ LoC, for what it's worth). It's currently stable and in production. However, I know that my skills were rusty ...
52
votes
4answers
17k views

What is inversion of control, and when should I use it?

I am designing a new system and I want to know what inversion of control (IOC) is, and more importantly, when to use it. Does it have to be implemented with interfaces or can be done with classes?
51
votes
11answers
5k views

How do I avoid cascading refactorings?

I've got a project. In this project I wished to refactor it to add a feature, and I refactored the project to add the feature. The problem is that when I was done, it turned out that I needed to make ...
49
votes
7answers
5k views

Two structs with the same members but different naming, is it a good idea?

I am writing a program that involves working with both polar and Cartesian coordinates. Does it make sense to create two different structs for each kind of points, one with X and Y members and one is ...
49
votes
5answers
12k views

Should I use Dependency Injection or static factories?

When designing a system I am often faced with the problem of having a bunch of modules (logging, database acces, etc) being used by the other modules. The question is, how do I go about providing ...
49
votes
19answers
9k views

Servicing background tasks on a large site

We're dealing with an interesting problem on StackOverflow. We've got a whole bunch of little "needs to be done soon-ish" tasks. An example is updating "Related Questions" lists. What we've done in ...
47
votes
12answers
4k views

Develop fast and buggy, then correct errors or be slow, careful for each line of code? [duplicate]

Possible Duplicates: Frankly, do you prefer Cowboy coding? Prototyping vs. Clean Code at the early stages Good design: How much hackyness is acceptable? Does craftsmanship pay off? ...
46
votes
14answers
8k views

Are there problems with using Reflection?

I don't know why, but I always feel like I am "cheating" when I use reflection - maybe it is because of the performance hit I know I am taking. Part of me says, if it is part of the language you are ...
46
votes
9answers
7k views

Code Smell: Inheritance Abuse [duplicate]

It's been generally accepted in the OO community that one should "favor composition over inheritance". On the other hand, inheritance does provide both polymorphism and a straightforward, terse way of ...
46
votes
16answers
3k views

How do I deal with analysis paralysis?

Very frequently, I am stuck when choosing the best design decision. Even for small details, such as function definitions, control flow, and variable names, I spend unusually long periods perusing the ...
45
votes
14answers
19k views

Isn't MVC anti OOP?

The main idea behind OOP is to unify data and behavior in a single entity - the object. In procedural programming there is data and separately algorithms modifying the data. In the ...
44
votes
6answers
4k views

How safe are hidden AJAX requests that fake performance?

What is a hidden AJAX request? I've noticed an increase in the usage of hidden AJAX requests designed to make a user's action appear to happen immediately. I'll refer to this type of AJAX request as ...
43
votes
10answers
3k views

Clarify the Single Responsibility Principle

The Single Responsibility Principle states that a class should do one and only one thing. Some cases are pretty clear cut. Others, though, are difficult because what looks like "one thing" when ...
42
votes
6answers
2k views

Business logic: Database vs code [duplicate]

I'm a student of systems engineering, and all my teachers and friends (that actually work in the area) say that it is better to have as much logic as possible implemented in the database (queries, ...
41
votes
5answers
12k views

How do searches fit into a RESTful interface?

When designing a RESTful interface, the semantics of the request types are deemed vital to the design. GET - List collection or retrieve element PUT - Replace collection or element POST - Create ...
39
votes
9answers
4k views

Do we need Logging when doing TDD?

When doing the Red, Green & Refactor cycle we should always write the minimum code to pass the test. This is the way I have been taught about TDD and the way almost all books describe the process. ...
39
votes
6answers
7k views

Hardcoding strings that will never change

So, in my efforts to write a program to conjugate verbs (algorithmically, not through a dataset) for French, I've come across a slight problem. The algorithm to conjugate the verbs is actually fairly ...
39
votes
12answers
2k views

Documentation in OOP should avoid specifying whether or not a “getter” performs any computation?

My school's CS program avoids any mention of object oriented programming, so I've been doing some reading on my own to supplement it -- specifically, Object Oriented Software Construction by Bertrand ...
39
votes
10answers
3k views

Be liberal in what you accept… or not?

[Disclaimer: this question is subjective, but I would prefer getting answers backed by facts and/or reflexions] I think everyone knows about the Robustness Principle, usually summed up by Postel's ...