Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Memory, files, network connections, I/O devices and other objects that have to be acquired and then released within a program. Please do not use this tag to ask questions about educational resources such as tutorials, books, websites or classes. Those are off-topic on Programmers.

2
votes
1answer
38 views

recommendations regarding resource uri

lets say we have a "door api" and I want to create a resource to close the door. I could do this in 3 ways: traditional way using PUT with payload {id: XX, color: YY, closed: true} advantages: ...
-1
votes
0answers
24 views

Blocking Behavior with Threads and lost updates

I have three examples of what I think to be kind of the same thing: In an SQL database, using either: Optimistic Locking Pessimistic Locking ..can prevent a database thread from losing an update ...
1
vote
2answers
51 views

API - editing subset of attributes

Given a resource for which only its subsets of attributes can be edited, {E.g. invoice (resource) with a status (attribute) and paidAmount (attribute)}, in terms of API design, which amongst the ...
4
votes
2answers
260 views

Implementing reference counting from scratch or using shared_ptr for resource?

In an OpenGL application that I am writing, I want to have a simple shader class to wrap the OpenGL shader handle. Ultimately, I want this shader class to behave very similarly to a shared_ptr in c++ (...
2
votes
1answer
128 views

Mark&sweep GC with automatic freeing resources

Note: I use term "resource" in opposition to memory here, resource here is file, socket, etc. Is there a language implementation that uses M&S GC (but not necessarily only that kind ¹) that is ...
3
votes
2answers
97 views

Should ID be given in URL if already secured with JWT containing ID?

Say I have the endpoints: /users and /users/<id> If I wanted to DELETE a user authenticated with a JWT token that contains the user object, should this DELETE handled go under /users or /...
3
votes
2answers
381 views

REST Api Design Patterns

I'm developing a REST Api using Node.js & Express.js. Recently I've started looking towards best practices for REST Api design but it's bit confusing so please bear with me. For Example: Lets ...
0
votes
0answers
68 views

Where to keep your resource files

I am trying to find best practices of what to do with my resources such as images, css, javascript files, fonts, etc... Assume that I have 5 environments and 5 products. I intended to put all of them ...
0
votes
2answers
101 views

REST Resource design

Hi I'm working with an API Where an employee can see his Vacation (overview and balance) and Request new Vacation. A manager can Approve or Reject a Request for Vacation. He can also create Vacation ...
5
votes
3answers
1k views

How do you format part of a resource?

Suppose you're building a web application in ASP.NET MVC, and you have to display some formatted text. A very simple example might be: Click any of the links below, or click here to cancel. ...
1
vote
1answer
59 views

Who should read an external resource

I am often in the following situation: I have a config file, specifying the path to a resource file This config file gets parsed and the values (e.g., file path) are stored in a ConfigStore object A ...
3
votes
4answers
289 views

How to design HTTP endpoint which search for single resource instance and returns it with another, connected instance

I have an endpoint returning single-element collection (I didn't return just object-instance to keep consistent with resource-as-collection convention, so only get-by-id returns single instance) GET ...
1
vote
1answer
139 views

Making localization files easy to use for translators

I want to make my application available in many languages. I started using Resource Files, but there is a little problem with them. I want other people to have access to these files. Visual Studio ...
8
votes
2answers
3k views

Can a REST API return multiple resources as one single compound resource?

I'm in the progress of creating a REST API and currently, I'm encountering the following problem: Foo is the first resource. CRUD operations can be applied via the /foo/ URI. Bar is the second ...
3
votes
2answers
270 views

Why does C#'s System.Threading.Semaphore implement IDisposable and why doesn't java.util.concurrent.Semaphore implement Closeable?

In .NET framework, System.Threading.Semaphore is an IDisposable that requires manually invoking dispose. However, in JavaSE, java.util.concurrent.Semaphore is not a Closeable nor an AutoCloseable. ...
1
vote
0answers
93 views

Trade off between concurrency and stagnation in a Dining Philosophers problem analogue?

I am currently facing a problem in the application I am developing that I think is the same as, or an analogue of, the Dining Philosophers Problem. In my application I have a list of N resources. I ...
4
votes
2answers
1k views

Rest API calls with side effects on other resources

Let's say I have a mobile app, android/iOS and a java Spring back end. Given the mobile connectivity, the number of network round trips must be limited, ideally, 1 or less per screen. Now, let's say ...
13
votes
5answers
1k views

How to organize localization string resources?

We're developing a large application, consisting of many small packages. Each package has its own set of resource files for localization. What's the best approach to organizing and naming the ...
0
votes
4answers
291 views

How do I elegantly store tabular data in code?

Let's say I want to store date which cannot be changed by the user in code. For example, my application supports ten types of reports, and I want to store metadata about it. Usually, I'd use a ...
-1
votes
1answer
75 views

How costly is DB data transfer as compared to data storage?

I've seen a number of answers (1, 2, 3) where they state that storage is cheap. So when designing a DB structure, it shouldn't be a main concern, or at least it doesn't rank very high in the list of ...
1
vote
1answer
207 views

When should I consider using a string table resource over a string constant in my Win32 application?

I've written a fair bit of Win32 desktop apps as hobby projects throughout my career but I've never used resources of the type string table in any of them; usually I either hard-code strings or build ...
2
votes
2answers
3k views

Does RESTful response always return a 404 and empty content when an array is expected but the result is empty?

I worked with Ruby on Rails and RESTful api before and now with Django Rest framework. For this question let's say we only consider the case of JSON but not XML. It seems that when we expect an ...
4
votes
1answer
900 views

Is it better not to .close() inside API method body when passed a Reader or InputStream?

There are plenty of similar questions that have been answered. Example here. However, they all have both the Reader and the InputStream within the same scope or method body, and so suggest to close ...
3
votes
2answers
550 views

How do I model a sortable resource in sql database? [closed]

I encounter this issue when I create REST API. I cannot tell the exact scenario, but let's say it is for a website that has category and product resources. Each category has many products and both ...
10
votes
2answers
4k views

Should Java 8 Stream instances always be close()'d?

Quoth the Javadoc: Streams have a BaseStream.close() method and implement AutoCloseable, but nearly all stream instances do not actually need to be closed after use. Generally, only streams whose ...
12
votes
4answers
8k views

Will the Database connection be closed if we yield the datareader row and not read all the records?

While understanding how yield keyword works, I came across link1 and link2 on StackOverflow which advocates the use of yield return while iterating over the DataReader and it suits my need as well. ...
1
vote
1answer
60 views

Fill widget with data retrieved from internet

I want to retrieve data from internet and show them into a widget. In particular, I've a widget with a QComboBox containing some service from which I can retrieve a list of exchange markets. When I ...
3
votes
1answer
484 views

How to deal with relative paths in out of source build?

An out of source build is a build which can be in any directory other than the source directory I have a project which contains relative paths to some resource files, needed at runtime, which are ...
1
vote
0answers
136 views

Pointers vs IDs for “context-specific” functions

I need to be able to load, use, and free resources from a single monolithic object. I have two requirements: 1. That the resource loaded is owned by the object that created it and 2. All objects in a "...
3
votes
0answers
176 views

Is there a language for defining restful web services? [closed]

I'm implementing a restful service automation tool for client applications. Basically, the tool takes a config file that defines restful resources, and creates some DTOs and resource classes for ...
1
vote
1answer
607 views

Why would we need to rollback twice before closing in a finally block?

I'm trying to implement the change in database connection closing suggested in this question's answers. More than once, I've come across this block of code at the end of my try blocks: try { -...
7
votes
3answers
6k views

Is there an issue with closing our database connections in the “Finally” block of a Try statement?

I'm doing some refactoring for our application, and trying to reduce the number of issues reported in our ISO Scan (a static code analysis tool based on HP Fortify). Right now, what I'm trying to ...
6
votes
4answers
2k views

How do you find out what resources are unmanaged?

Looking through the .NET documentation, specifically the WebRequest class, I don't see any information indicating that I should wrap an instantiation of it in a using statement. Even the provided ...
1
vote
1answer
81 views

What's the proper name for the type of security where we secure resources by ownerrship?

I work on a REST API that mixes two types of security: First you have standard role-based security - so we have multiple roles such as administrator, read-only user, super user user, etc. Then we ...
0
votes
1answer
47 views

How to distribute copyrighted resources with and open source project?

I would like to create an open source GPLv3 project that will work with other resources that are under different types of copyright (e.g. free to use, but must not sell). Because of this, I can't ...
0
votes
1answer
95 views

What is the correct answer of given problem?

Consider a system having m resources of same type and 3 process A,B and C have peak demands of 3,4 and 6 respectiveley. What should be the value of m such that the deadlock will not occur ? My ...
7
votes
2answers
9k views

To include a resource ID in the payload or to derive from URI

Designing an API, we've come up against the question of whether a PUT payload should contain the ID of the resource being updated. This is what we currently have: PUT /users/123 Payload: {name: "...
2
votes
7answers
248 views

What if any languages treat undisposed resources as an error? [closed]

I've seen lots of code like the following example. It's in Python, but the same mistake is made in all languages with managed resources: f = open('foo.txt', 'rb') for line in f: print line That's it....
1
vote
1answer
88 views

Structuring Resource Files

In .NET we've got Resource files which are great for allowing providing translations across your application. In the past I've seen these resource files grow into monolithic unmaintainable lists of ...
2
votes
2answers
5k views

Can GC.SuppressFinalize cause performance problems?

I'm being asked to implement IDisposable on objects that are 100% managed resources, which contain no streams, and no large resources. I understand the importance of properly disposing of large ...
6
votes
3answers
3k views

How should I unit test a bitmap modifying method?

My Sprite class has a method: private void updateWithBitmap(Bitmap b, int x, int y) This will 'lay on top' the bitmap that's passed in, the top left corner of the passed in bitmap being at the x,y ...
1
vote
2answers
141 views

What's the most flexible way to ship changeable resources such as icons for an application?

We're currently upgrading some components of our application to new technologies such as C# using WPF and MVVM. Since we try to avoid past mistakes that have been made in our now legacy applications, ...
0
votes
1answer
2k views

Android DB With Some Multi-Language Data

I have a SQLite Database in my Android app with a "Question" table, among others. That table contains "default" or "pre-loaded" data (in this case the questions asked by the app). Some of its columns ...
17
votes
4answers
3k views

Why are string resources generally kept external to the code and not inside the code?

Generally, on many platforms, I'm writing my string resources to a .resx or .xml file, and then I'm getting them using some platform-dependent approach. That is, on iOS, I'm getting them via NSBundle....
1
vote
1answer
347 views

MVC Widget optimization when accessing CSS and Resources

So we're trying to re-imagine our web solution in an MVC fashion. Going from an old webforms based solution to working with ASP.NET MVC with a bootstrap main menu and adding functionality in the forms ...
2
votes
1answer
3k views

What is the accepted practice for string resource management in java?

In Android, final strings are stored in a strings.xml file, which makes it easy to update text, reuse strings and to translate an app to a different locale -- because everything is in one place. ...
4
votes
3answers
3k views

Is it OK to use email as an identifier in a RESTful URI?

I'm working with a team building a RESTful web service, and our current implementation utilizes the user's email as a unique identifier for the user resource, yielding URIs like the following: https:/...
1
vote
2answers
421 views

taxonomy of software project resourcing models

I would like to understand the impact of different resourcing models for software projects. First, I would like to identify the different resourcing approaches that are used to resource software ...
3
votes
1answer
3k views

What is the limit on REST API resource levels

When designing a REST API, how deep should the resources levels go? For example; If I have the following database tables: Companies: ID, Name Employees: ID, Name, CompanyID Tasks: ID, Name, ...
0
votes
1answer
339 views

How to configure these REST API Resources [closed]

I'm still in the design phase of my REST API, and I'm a bit stuck on how to configure the resources. The API will be consumed by mobile devices (Android, iOS, and Windows). Communication through HTTPS....