Questions tagged [design]
Questions about problem solving and planning for a solution through software design.
452
questions
45
votes
12
answers
15k
views
Dealing with bad/incomplete/unclear specifications? [duplicate]
I'm working on a project where our dev team gets the specifications from the business part of the company. Both the business management and the IT management require estimates and deadline projections,...
57
votes
12
answers
7k
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?
Which is ...
292
votes
17
answers
101k
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 ...
123
votes
9
answers
28k
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 ...
151
votes
12
answers
27k
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 ...
99
votes
7
answers
34k
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 ...
27
votes
4
answers
9k
views
Legitimate "real work" in a constructor?
I am working on a design, but keep hitting a roadblock. I have a particular class (ModelDef) that is essentially the owner of a complex node tree built by parsing an XML schema (think DOM). I want to ...
37
votes
9
answers
4k
views
Design for future changes or solve the problem at hand [closed]
While writing the code or during design do you try to generalize the problem at the first instance itself or try to solve that very specific problem.
I am asking this because trying to generalize the ...
5
votes
1
answer
2k
views
Derive from a base class but not include a condition in the base class's method
The current code looks like this:
public class Details
{
Public void Populate()
{
WriteChapterDetails();
}
public void WriteChapterDetails()
{
if ( ...
69
votes
12
answers
44k
views
Is catching general exceptions really a bad thing?
I typically agree with most code analysis warnings, and I try to adhere to them. However, I'm having a harder time with this one:
CA1031: Do not catch general exception types
I understand the ...
77
votes
14
answers
10k
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 ...
245
votes
15
answers
163k
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 ...
72
votes
7
answers
80k
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 ...
41
votes
6
answers
38k
views
Understanding "programming to an interface"
I have come across the term "programming to an interface instead of an implementation" a lot, and I think I kind of understand what it means. But I want to make sure I understand it's benefits and it'...
12
votes
6
answers
4k
views
What are the practical ways to implement the SRP?
Simply what are the practical techniques people use to check if a class violates the single responsibility principle?
I know that a class should have only one reason to change, but that sentence is ...
150
votes
14
answers
118k
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 ...
15
votes
2
answers
1k
views
If there are two ways of approaching a task, how should one choose between them?
I have a specific use case, and have found 3 ways of doing it across the internet, which are defined for vague usage cases. I am staring at these three wondering which to apply.
I tend to sit there ...
16
votes
5
answers
16k
views
What to plan before starting development on a project? [closed]
Say I've received the specifications for a project from a client, and now its time to start developing it. Normally, I just start with the first module (usually user registration) and then go from one ...
58
votes
9
answers
23k
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 ...
28
votes
6
answers
19k
views
Best-practice to manage concurrency into a basket in a e-commerce website
What is the best practice to manage the case where two customers add in the same time a product whose the stock was only 1 ?
Must there be a check in the code of the basket to avoid one of these 2 ...
78
votes
6
answers
14k
views
What should I consider when the DRY and KISS principles are incompatible?
The DRY principle sometimes forces the programmers to write complex, hard-to-maintain functions/classes. Code like this has a tendency to become more complex and harder to maintain over time. ...
53
votes
6
answers
88k
views
Pros and Cons of holding all the business logic in stored procedures in web application [duplicate]
In some organization I worked for web applications are developed basing all the business logic in Database stored procedures. For example, use html for view and servlet as controllers to divert the ...
28
votes
8
answers
8k
views
When do you rebuild an application or keep on fixing the existing one [duplicate]
Possible Duplicates:
When is a BIG Rewrite the answer?
Have you ever been involved in a BIG Rewrite?
I am at a customer where I have been tasked to fix a number of issues they have in their ...
24
votes
8
answers
1k
views
How does one decide if a data object type should be designed to be immutable?
I love the immutable "pattern" because of its strengths, and in the past I have found it beneficial to design systems with immutable data types (some, most or even all). Often when I do so, I find ...
13
votes
1
answer
4k
views
Is wrapping a third party code the only solution to unit test its consumers?
I'm doing unit testing and in one of my classes I need to send a mail from one of the methods, so using constructor injection I inject an instance of Zend_Mail class which is in Zend framework.
Now ...
8
votes
1
answer
4k
views
Where should I place configuration classes in Onion Architecture
We are redesigning one of our API projects from an n-layered architecture into onion architecture. In the previous design, we had configuration classes in a common library project being referenced ...
2
votes
2
answers
1k
views
Law of Demeter and its applicability
Let's say I'd like to perform the following command:
house.getFloor(0).getWall(WEST).getDoor().getDoorknob();
To avoid a NullPointerException, I'd have to do the following if:
if (house != ...
80
votes
4
answers
23k
views
Why do many software developers violate the open/closed principle?
Why do many software developers violate the open/closed principle by modifying many things like renaming functions which will break the application after upgrading?
This question jumps to my head ...
72
votes
9
answers
29k
views
Can manager classes be a sign of bad architecture?
Lately I've begun to think that having lots of manager classes in your design is a bad thing. The idea hasn't matured enough for me to make a compelling argument, but here's a few general points:
I ...
72
votes
9
answers
26k
views
Are classes with only a single (public) method a problem?
I am currently working on a software project that performs compression and indexing on video surveillance footage. The compression works by splitting background and foreground objects, then saving the ...
39
votes
4
answers
13k
views
What is the principle of least astonishment?
In programming what is called Principle of Least Astonishment? How is this concept related to designing good APIs? Is this something applicable to only object oriented programming or does it permeate ...
9
votes
2
answers
3k
views
How is it possible to write the compiler of a programming language with that language itself [duplicate]
Possible Duplicate:
How could the first C++ compiler be written in C++?
You probably heard that Microsoft released a new language called TypeScript which is a the typed superset of JavaScript.
...
8
votes
6
answers
1k
views
Significant amount of the time, I can't think of a reason to have an object instead of a static class. Do objects have more benefits than I think? [closed]
I understand the concept of an object, and as a Java programmer I feel the OO paradigm comes rather naturally to me in practice.
However recently I found myself thinking:
Wait a second, what are ...
0
votes
4
answers
791
views
Write some code and plague it with anti-patterns or not write it at all, any escape from this dilemma for a beginner? [duplicate]
I am now working on a project that started as university homework and actually, still is a university homework (not turned in yet...) and, if I'm successfull (that doesn't mean turning it in and ...
55
votes
3
answers
69k
views
Which is a better practice - helper methods as instance or static?
This question is subjective but I was just curious how most programmers approach this. The sample below is in pseudo-C# but this should apply to Java, C++, and other OOP languages as well.
Anyway, ...
52
votes
3
answers
112k
views
How to solve circular dependency?
I have three classes that are circular dependant to each other:
TestExecuter execute requests of TestScenario and save a report file using ReportGenerator class.
So:
TestExecuter depends on ...
35
votes
3
answers
5k
views
Does TDD lead to good design? [duplicate]
I'm in transition from "writing unit tests" state to TDD.
I saw as Johannes Brodwall creates quite acceptable design from avoiding any of architecture phase before. I'll ask him soon if it was real ...
22
votes
8
answers
5k
views
Is perfectionism a newbie's friend or enemy? [duplicate]
Possible Duplicate:
Where do you draw the line for your perfectionism?
I see that the development community is very focused on doing things the right way and personally I would like to do the ...
22
votes
4
answers
4k
views
Architectural differences between dynamic and static languages
Are there any major architectural differences when designing applications that will be built on static languages (such as C# or Java) and dynamic languages (such as Ruby or Python)?
Which are the ...
21
votes
5
answers
8k
views
Is a common library a good idea?
I've always thought that a "common library" was a good idea. By that I mean a library that contains the common functionality that is often needed by a few different applications. It results in less ...
16
votes
6
answers
14k
views
Are Get-Set methods a violation of Encapsulation? [duplicate]
Possible Duplicate:
When are Getters and Setters Justified
In an Object oriented framework, one believes there must be strict encapsulation. Hence, internal variables are not to be exposed to ...
8
votes
9
answers
1k
views
Internationalization : What things to think about?
I was listening to Jon Skeet's talk at the last StackOverflow Dev Days and he piqued my curiousity regarding internationalization.
Suppose I have a waffle-making program, either complete, or still in ...
3
votes
2
answers
282
views
What is the best algorithm for implementing a system with a complex execution path?
I am currently working on an implementation that based on a set of user configurations should output a final decision. The multiple configurations are evaluated several times at different stages of ...
214
votes
5
answers
49k
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 ...
150
votes
8
answers
24k
views
Are bad programming practices typical within the software industry? [closed]
I just started my first job as a software developer over a month ago. Everything I have learned about OOP, SOLID, DRY, YAGNI, design patterns, SRP, etc. can be thrown out the window.
They use C# .NET ...
85
votes
7
answers
207k
views
Designing a REST api by URI vs query string
Let's say I have three resources that are related like so:
Grandparent (collection) -> Parent (collection) -> and Child (collection)
The above depicts the relationship among these resources ...
69
votes
4
answers
8k
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 ...
31
votes
6
answers
11k
views
When is a circular reference to a parent pointer acceptable?
This Stack Overflow question is about a child having reference to its parent, through a pointer.
Comments were pretty critical initially of the design being a horrible idea.
I understand this is ...
14
votes
0
answers
5k
views
Design and Development Methodologies for the single developer
At my work, typically the developers here all work separately, we may share projects but often only do so when another isn't working on it (for reference, we're a consulting company. So someone may ...
14
votes
9
answers
5k
views
Should a surrogate key ever be exposed to a user?
Often in a table that has no natural key, it is still useful for users to be able to have a uniquely generated identifier. If the table has a surrogate primary key (and in such a case you would ...