243 votes

Why should 'boneheaded' exceptions not be caught, especially in server code?

Silent But Deadly When writing enterprise software, you will eventually learn an essential truth: the worst bug in the world is not one that causes your program to crash. The worst bug in the world ...
user avatar
106 votes

When would you use a long, string ID instead of a simple integer?

Youtube can't use sequentional IDs for two reasons: Its databases are almost certainly distributed, making sequential numbering complicated. It has a privacy option "Unlisted videos": those that don'...
user avatar
  • 769
103 votes
Accepted

Should you guard against unexpected values from external APIs?

You should never trust the inputs to your software, regardless of source. Not only validating the types is important, but also ranges of input and the business logic as well. Per a comment, this is ...
user avatar
  • 3,237
81 votes

When would you use a long, string ID instead of a simple integer?

On the form of the IDs: They're using Base64 (using the characters a-z, A-Z, 0-9, -, and _). This allows them to have 6 bits of information per character. YouTube uses 11-character video IDs, which ...
user avatar
76 votes
Accepted

Why is it so bad to read data from a database "owned" by a different microservice

Databases are not very good at information hiding, which is quite plausible, because their job is to actually expose information. But this makes them a lousy tool when it comes to encapsulation. Why ...
user avatar
  • 29.7k
70 votes
Accepted

What is the present-day significance of SOAP

REST is indeed an architectural style. SOAP is a data protocol. The distinction is important; you cannot compare them directly. The primary purpose of REST is to represent resources on the Internet,...
user avatar
59 votes

Why is it so bad to read data from a database "owned" by a different microservice

What is more important and significant about a microservice: its API or its database schema? The API, because that is its contract with the rest of the world. The database schema is simply a ...
user avatar
  • 3,165
59 votes

Why should 'boneheaded' exceptions not be caught, especially in server code?

Exceptions should be allowed to crash the system if the system has been left in an unrecoverable undefined state. If you can't put the system back in a defined state that ensures data integrity and ...
user avatar
43 votes

Why should 'boneheaded' exceptions not be caught, especially in server code?

It doesn't really matter if it's a "boneheaded" exception (e.g. a Java unchecked exception) or not. The only question to ask yourself is: "Can the program sensibly continue?" A &...
user avatar
  • 5,862
41 votes

Why not use SQL instead of GraphQL?

Basically, abstraction. SQL requires your clients to know your exact database structure, which is not good. On top of that, analysing the SQL in order to perform special operations based on the value ...
user avatar
  • 9,885
39 votes
Accepted

Should I return a 204 or a 404 response when a resource is not found?

HTTP 204 means that something was found, but it's empty. For instance, imagine that you're serving log files through HTTP, with the requests such as http://example.com/logs/[date-goes-here]. On May ...
user avatar
35 votes

What is the present-day significance of SOAP

REST is much more limited than SOAP, which is its strength and the reason for its popularity. In SOAP, the set of operations allowed and the set of data types allowed is essentially limitless. SOAP ...
user avatar
34 votes

Should you guard against unexpected values from external APIs?

Yes, of course. But what makes you think the answer could be different? You surely don't want to let your program behave in some unpredictable manner in case the API does not return what the ...
user avatar
  • 184k
33 votes

I'm not seeing 'tightly coupled code' as one of the drawbacks of a monolithic application architecture

Why X when you can do Y? The problem with questions like these is that no one has ever claimed that you can't take the more difficult route if you really want to. People aren't pointing out that the ...
user avatar
  • 37.2k
30 votes
Accepted

Are mutliple database calls really significant with a network call for a web API?

But is that really important? Consider that the UI has to make a network call to the API; that's pretty big (order of magnitude of milliseconds). Databases are optimized to keep things in memory and ...
user avatar
  • 4,529
28 votes

Why not use SQL instead of GraphQL?

In theory there is no reason you can't expose an SQL interface like this. In practice SQL is far too powerful to be effectively limited to the security scope you want to expose. Even if you allow ...
user avatar
  • 63.9k
25 votes

Should you guard against unexpected values from external APIs?

The Robustness Principle--specifically, the "be liberal in what you accept" half of it--is a very bad idea in software. It was originally developed in the context of hardware, where ...
user avatar
23 votes

If a microservice architecture needs a separate database per microservice then it's too costly & unmanageable. Why do we even need it?

Why do we even need it? You don't. Creating a separate database for each service helps to enforce domain boundaries, but it's only one approach. There's nothing stopping you from having all your ...
user avatar
  • 2,851
23 votes

Why should 'boneheaded' exceptions not be caught, especially in server code?

You are absolutely correct. An exception in server-side application code ("boneheaded" or not) should not crash a web server. The confusion is because the articles are not clear about what it ...
user avatar
  • 54.6k
22 votes
Accepted

Handling token renewal / session expiration in a RESTful API

This sounds like a case of authentication versus authorization. JWTs are cryptographically signed claims about the originator of a request. A JWT might contain claims like "This request is for user X"...
user avatar
  • 4,389
19 votes
Accepted

What should be the scope of a health check for a system which deploys a webapp?

This is hard to implement because of the definition of what is healthy You answered your own question here. The definition of a health check is going to vary, because what is healthy varies. It also ...
user avatar
  • 12k
17 votes

Handling token renewal / session expiration in a RESTful API

Your API session is a thing which should not exist in a RESTful world at all. RESTful operations are supposed to be stateless, session contains state and thus has no place in a RESTful world. The JWT ...
user avatar
  • 9,885
17 votes

Why should 'boneheaded' exceptions not be caught, especially in server code?

You learned an important thing: Whenever you read a rule on the internet that must absolutely be followed, you must start thinking about it and decide for yourself whether you should follow the rule ...
user avatar
  • 37.4k
16 votes

Why is it so bad to read data from a database "owned" by a different microservice

Microservice Architecture is hard to describe but the best way to think about it is a marriage between Component Oriented Architecture and Service Oriented Architecture. Software as a suite is ...
user avatar
  • 26.3k
15 votes
Accepted

What HTTP status using for REST search query which returns nos results

I think in the most cases the most useful reaction would be to return a regular answer (HTTP 200) and send empty data. For example if you are returning JSON you could send {} Another good option may ...
user avatar
14 votes

When would you use a long, string ID instead of a simple integer?

Integers do not scale that well, a "normal" 32-bit unsigned integer will max out just over 4 billion. They may not want you to know how many items they have on line or keep track of the ...
user avatar
  • 15.3k
14 votes

Should you guard against unexpected values from external APIs?

In general, code should be constructed to uphold the at least the following constraints whenever practical: When given correct input, produce correct output. When given valid input (that may or may ...
user avatar
  • 8,095
13 votes

Microservices REST or AMQP, which case

By discarding REST, you lose much more than just HATEOAS. If your microservices are public (and it's a good idea for them to be public or at least tend towards being public one day¹), using anything ...
user avatar
13 votes
Accepted

Understanding the difference between Webservices and Service Layer

A service layer is a layer in an application that hides away specific implementation details for a system and provides a uniform and consistent interface to the operations in that system. A ...
user avatar
  • 6,232
12 votes

What's the best RESTful URL structure for a recursive resource?

What comes to my mind is: do not let you RESTful API reflect the recursivity in the URL itself. Come to think of it, your resource is only the documents. If you have your documents stored physically ...
user avatar
  • 240

Only top scored, non community-wiki answers of a minimum length are eligible