Questions tagged [design]

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

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

5099 questions
291
votes
17 answers

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 expensive" to create. I wrote a quick test and…
Craig Day
  • 563
  • 3
  • 5
  • 5
246
votes
16 answers

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

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 recruited me to avoid theft of his idea, the high cost…
245
votes
15 answers

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 boolean as one of its parameters, and that method calls…
Ray
  • 2,460
  • 3
  • 15
  • 10
235
votes
17 answers

Is it good practice to always have an autoincrement integer primary key?

In my databases, I tend to get into the habit of having an auto-incrementing integer primary key with the name id for every table I make so that I have a unique lookup for any particular row. Is this considered a bad idea? Are there any drawbacks to…
AJJ
  • 2,938
  • 4
  • 14
  • 14
218
votes
18 answers

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 any landscape. They are affected by things like…
214
votes
5 answers

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 came to my mind was argument:value. I thought it is…
Filip Hazubski
  • 2,013
  • 3
  • 11
  • 11
200
votes
7 answers

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 collection or element DELETE - Well, erm, delete…
Rob Baillie
  • 2,416
  • 2
  • 13
  • 12
183
votes
5 answers

When do you use a struct instead of a class?

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 tend to use classes for almost everything, and use…
RationalGeek
  • 10,077
  • 7
  • 38
  • 56
173
votes
21 answers

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 if my new code is correct if it's too dirty. I…
Karl Bielefeldt
  • 146,727
  • 38
  • 279
  • 479
150
votes
8 answers

Are bad programming practices typical within the software industry?

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 Webforms and do almost everything within the Code…
Grim
  • 903
  • 2
  • 7
  • 10
150
votes
12 answers

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 the option to close a started ProjectTask is never…
Paul T Davies
  • 3,144
  • 2
  • 22
  • 22
150
votes
14 answers

What is the ideal length of a method for you?

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 you think. In Clean Code: A Handbook of Agile…
Spring
  • 1,733
  • 2
  • 12
  • 10
144
votes
8 answers

How do I get people to stop bikeshedding (focusing on trivialities)?

I have been tasked with teaching other teams a new codebase, but I keep running into an issue. Whenever I go to actually walk through the code with people, we don't get very far before the entire exercise devolves into a bikeshedding (members of an…
Telastyn
  • 108,850
  • 29
  • 239
  • 365
138
votes
17 answers

How do I know how reusable my methods should be?

I am minding my own business at home and my wife comes to me and says Honey.. Can you print all the Day Light Savings around the world for 2018 in the console? I need to check something. And I am super happy because that was what I had been…
Koray Tugay
  • 1,565
  • 3
  • 12
  • 18
128
votes
11 answers

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 over error codes As far as I'm aware, from working in…
RichK
  • 1,457
  • 2
  • 12
  • 12
1
2 3
99 100