instruction stringlengths 34 36.1k |
|---|
A textbook I am teaching from about ASP.Net using ADO.Net in C# says:
Note that concurrency checking isn't necessary here, because a
concurrency error can't occur for an insert operation.
The textbook emphasizes using Optimistic Concurrency (as extensively described in the Microsoft online documentation): Update an... |
I'm building a GUI for a CL program and I have the following question
Is it better to
Have the GUI invoke the program behind the scenes using a shell with some options eg: If I were I were writing a git frontend, I would just have every button click correspond to a git foo bar command that runs in its own shell
Or by-... |
The company with which we are integrating is a door security company that makes RFID cards and door scanners. You scan your card, the door opens and lets you in. They allow 3rd party integration via their websocket server. They post "Events" to their server. "Bob Foobar scanned his card at door reader #14 at 8:12am on ... |
I'm in the process of implementing a counting Bloom filter. This data structure is defined as a bit-array and a "width" parameter, W.
The bit array stores unsigned integers, whose size is determined by W, into an array of uint64s. Thus, it is expected that the integers' size will not be multiple of 8. For instance, ... |
According to Is it wrong to use a boolean parameter to determine behavior?, I should not use a boolean parameter to switch behavior inside a function. How about other types of parameters?
For example, if I try to use a string instead of boolean:
void f(str){
if(str==='a'){
a();
}else if(str==='b'){
... |
Can a UWP App access data outside its own app data, publisher data, or what the user picks with the FilePicker?
As far as I can tell, a shared publisher area and a user prompt with the FilePicker are the only ways to access files outside a UWP app's own personal app data stores. Registry settings are sandbox'd, as are ... |
I am test driving a method which is parameterized by two inputs and depends on a Strategy. Here's what I have:
[TestCase(input_a1, input_b1, strategy1)]
[TestCase(input_a2, input_b1, strategy1)]
[TestCase(input_a3, input_b1, strategy1)]
[TestCase(input_a1, input_b2, strategy1)]
[TestCase(input_a2, input_b2, strategy1)]... |
Let's say I want to write a function to compute factorials of nonnegative integers. I could write something like this:
fact :: Num a => Int -> a
fact n = fromInteger(product [1..n])
(Let's not concern ourselves with negative values of n at the moment, as that isn't what my question is about.) If I write the function... |
I was tasked with implementing a networking stack. The software is self-contained with no external dependencies - it only needs the C++14 standard library, and a POSIX platform.
In my opinion there's nothing preventing it from being successfully implemented in a single repository as the logical separation (layers, clas... |
Sometimes I need for loops which needs a break like this:
for(int i=0;i<array.length;i++){
//some other code
if(condition){
break;
}
}
I feel uncomfortable with writing
if(condition){
break;
}
because it consumes 3 lines of code. And I found the loop can be rewritten as:
... |
I guess this is a problem solving question but I am out of ideas, don't really know where else I can resort for help, and I need to solve this problem.
Essentially we have a set of consumers and a set of resources, and the objective is to assign a resource to each consumer. Not every resource is eligible for every cons... |
Let’s assume there is a function EventHandler that is called on multiple threads at different points in time.
EventHandler has to call SomeOtherFunction, but these calls shall only happen on one thread at a time.
That means: If a call to SomeOtherFunction is currently active on thread A, and EventHandler gets called ag... |
I'm working in a Electronic Funds Transfer (EFT) system and need be very careful with sensitive data like credit card numbers.
We need this information do mount the ISO 8583 data before sending to EFT Gateways.
We use char[] and byte[] to keep sensitive data and use Array.fill when We don't need this information anymor... |
In a competition application I'm designing there are several types of prize draw, each of which needs to act upon an entry object in some way. So the first lines of code I wrote defined an interface.
interface PrizeDrawInterface
{
public void enter(EntryInterface entry);
}
Here's the problem which I'm not sure how... |
Please can you tell me if my Data Access Model makes any sense?
Thank you very much.
|
So probably like many, I often find myself running into headaches with design problems in which, for example, there is some design pattern/approach that seems to intuitively fit the problem and has desired benefits. Very often there is some caveat which makes it difficult to implement the pattern/approach without some ... |
This may be a silly question but if I have good unit test coverage, does that mean I can reduce the amount of, or remove completely, functional and integration testing.
When people talk about having a continuous deployment process in place, does that mean automated unit tests are the only form of testing done and the c... |
I am in the process of refactoring a Django web app. It is written in the usual MVT style, and I would like to change this for a REST + frontend approach. In my first iteration I would like to do as little changes as possible. My plan is:
split backend into REST API and a simple, client facing Django application (the ... |
In my current problem domain, a number of problems seem to lend themselves quite well to the strategy pattern. I have a common, high-level process - let's say it's a sales process - and regardless of the sales channel I use, sellProduct needs to happen... It's just a bit different from channel to channel.
So let's say ... |
i'm new to the whole Microservice architecture so pardon my unstructured questions:
Context: The business needs customers to be able to select commodities, calculate the cost of these commodities based on certain business rules to do with the amount of commodities selected, currency and other rules that affect the calc... |
We're developing an app using React Native and MobX for the state stores, and also using a Web API REST service for the GETs and POSTs. All is going well, so far we're able to use FETCH to get the data, persist it in the relevant store using MobX and populate ListViews etc from that store...
Where I'd like some guidanc... |
So I've been researching and looking into versioning my applications correctly rather than coming up with my own scheme. Semantic versioning is a popular option as many of you probably know, but my applications do not apply to the semantic criteria. By this I mean my product isn't an API. Looking into this, people say ... |
To start off I'm familiar with what microservices are, how they communicate with each other, the general flow etc.
Now, I'm used on working with standard 3 Layer application for my backends( API - BL - DAL ) and was wondering what the architecture of 1 microservice was, as I can't really find something about that, or i... |
my application sends a batch of custom emails every day using mailgun (an email API service). I have a producer worker scheduled to run daily, and all does is query the database for the unique configurations/templates, and adds the jobs to redis. Then my consumer worker sends the requests to mailgun and acks them. It w... |
I have made a textual minesweeper game (here you can find the program).
I want to initialize some data by the help of a file. The file should be readable for humans and easy to modify with a simple text editor.
The file should look for example like this and it should allow comments:
# columns and rows
size:10
# describ... |
Context
I recently got interested into producing better formatted code. And by better I mean "following rules endorsed by enough people to consider it a good practice" (since there will never be one unique "best" way to code, of course).
These days, I mostly code in Ruby so I started to use a linter (Rubocop) to provid... |
I got a REST webservice and it has a simple method like;
public void processItem(Item item);
Problem is processItem method takes too long to complete nearly 1 minute) and there can be multiple calls in a short time.
How can I handle these requests efficiently?
Webservice creates a new thread for every request and it h... |
I'm practicing various C++ exercises. In this particular exercise they are asking me to implement an in memory database. I guess they are not asking me to use something like SQLlite. Could anybody give some general pointers as to how I should tackle this please? Would I use C++ maps. I'm struggling to understand what t... |
I looked at this question. As far as I understand test env is for qa department to conduct their tests, and staging is identical to prod, but hidden from end user.
My questions are:
Should staging be 100% identical to prod, or is it ok for staging to have "messed up" data in it? Just how much is it ok for staging db ... |
For example, given the following class:
public class SomeClass
{
//...
private IEnumerable<SomeType> myEnumerable;
public IEnumerable<SomeType> MyEnumerable
{
get => myEnumerable;
set => myEnumerable = value ?? new List<SomeType>();
}
}
Is it good practice to perform this type of ... |
I came across this issue at my second job interview. The technical interviewer said multiple times that booleans are not ok to be passed as parameters in methods, rather find another constructs (Enums) to get rid of booleans.
What's the general opinion on this topic?
|
I'm confused about applying the "Composition Root" (CR) to create aggregates in DDD. Seemann (2012) defines CR as a "(preferably) unique location ... where modules are composed". He argues for composing object graphs inside CR, near the application's entry point, and warns against the temptation to compose "classes ... |
Situation:
Our Python project is hosted at GitHub. The actual release should only contain handful of files, but or project also contains several non-release files that are required for testing and ironically for packaging, etc.
We roughly follow the GitFlow model, so develop is our mainline that we build on and stabili... |
I have a function that gets the statues of my databases and Redis instances to check that they are online:
internal static bool IsOnline(ConnectionLocator connectionLocator)
{
try
{
connectionLocator.SessionDatabase.Ping(StackExchange.Redis.CommandFlags.None);
usi... |
I currently have a WinForms app that uses XML documents to drive dynamic content that is shown to the user. I call these XML documents template files.
The template file determines the features the user sees, the properties, what type of control to use for the property, the drop items in the combo boxes and how to valid... |
I previously ran into an interesting practice called occlusion culling in game development. I am still researching to gain more understanding of how it works, since this is mostly discussed in game programming/tools/IDEs such as Unity, so I am applying the practice to data management in application development.
Other n... |
We are currently beginning an upgrade to our system and have decided to follow DDD methodology. The system is highly customizable by the users to allow them to tailor the software to their specific needs. This has led to some confusion on the proper way to implement properties on some of our aggregate roots.
Let us sa... |
So we have an application that I am not ready to describe in full before we take it to the market, but I will give the details necessary.
We currently have an application that takes a snapshot of an active window of a particular application based on a region that is selected by the user. This data is simply a number th... |
I have a method that tries to get a ICommand instance and otherwise returns an ICommand with an Action that does nothing
private ICommand GetCommandFor(object o)
{
if(CommandExistsFor(o))
{
return _commands[o];
}
return new Command(() => { });
}
Completely disregarding the fact that we have dif... |
I have a class that handles the state of a response, called StockResponse.
The code has multiple ifs to handle each state of the stock. Most of the cases has a default behaviour, but some conditions need additional if-else inside to handle correctly the response.
The conditions are becoming hard to maintain, and looks ... |
As the open source world is fairly advanced now and you can find an open source implementation of pretty much everything, why are people/developers still using the obscure/proprietary libraries? In what case these are absolutely needed?
|
Short story: We had an issue, where customer reported some feature they wanted developed year ago stopped working. The problem is, the feature was indeed developed, but put into separate branch and then not merged into master, so the feature in fact was never on live enviroment, only on testing.
So now I am tasked with... |
I'm designing an application based on microservices architecture.
In this application I will need Auth microservice.
Also I will need to store some extra User information such as, perhaps, multiple addresses, avatar picture etc.
This leads to idea of having two microservices - one for Auth and another, User, which coul... |
Worse title ever but I don't really know how to describe my scenario in a line...
So I have a method that wraps the calls of a many methods of the same nature. Once any of these methods have finished, a certain update needs to be called.
class SomeClass:
def perform_tasks():
self.task1()
self.task2(... |
(This question might be overly broad, and it certainly doesn't have a "right" answer.)
I am rewriting some small embedded projects for a company. Rather than dive into the pre-existing code, I am restarting from scratch. The original code was written by students for a research project and while it proved the point, it ... |
I have to set the value of a string object "result" depending on the results of different methods and different if/else conditions. In the end, there would be one (last value set) in the string that i need to use. The first way i did it is:
public void MyClass(){
public void validateApples() {
Stri... |
I have a question about MVC pattern, concerning the controller part.
Most of the program I happen to write are basically spreadsheet like. They are written in C/GTK+ and Python3/Qt5/Tkinter but share a common design : I separate the gui from the logic (data struct and heavy lifting methods) that seems to be the MVC pat... |
I don't know if there actually is one design pattern, or several together, or maybe what i'm asking is anti-pattern.
Context (simplified) : my company sells SaaS services (through an API) to several clients, which in turn sells this service to end users. Each client uses the service, but some want custom behaviours in ... |
Thinking about the overall architecture of the application logic:
Current status: The model contains all resources that are used at runtime.
In a factory you register a builder which is used to create a resource via the factory. Every time the factory creates a resource, it adds the resource to the model. That means t... |
My task is to process asynchronously balance deltas for multiple clients and provide aggregated balance amounts.
I have a REST service which accepts requests from N clients C₁…Cₙ, each of them has its own financial balance value which changes throughout time. These clients send their positive/negative balance updates... |
When implementing a DDD driven system (based on event sourcing) using a functional programming language (Clojure), should one separate event handler functions from aggregate functions?
In my naive implementation an aggregate would be a namespace with
functions for handling commands which accept the current state data ... |
I want to do something fairly simply in my Gitlab CI pipeline - I want to build the docker image and push it to an AWS ECR repo.
I've looked at this Gitlab CI guide and one of the suggestions it makes is using the docker:latest image.
However, in order to access the AWS ECR repo - I'm also going to need to AWS comman... |
Right now I am collecting memory information on a node.js server every 100 seconds. I want do display the memory usage info as a graph on the front end.
const mem = {
heapTotals: [],
heapUseds: [],
maxHeapTotal: 0,
maxHeapUsed: 0
};
setInterval(function () {
const m = process.memoryUsage();
mem.heapTotals... |
Does 'open-closed principle' also includes files and data of the app? According to https://softwareengineering.stackexchange.com/a/296955/248528, it says files and data are't included, but it doesn't mentions if they should be included.
Suppose I have 2 ways to define the locale string of my app:
Method 1 : all locale ... |
Need some help in the desing of the Auth/Permissions of a REST API for a SAAS app.
I'd done a prototype of a SAAS app and for permissions of the SAAS client, I'd setup the API to request for a header called CLIENT-ID. This way, the API filters all views by the Logged in Client. This header is Mandatory.
The next thing ... |
Say I have a domain object like this:
public class Customer
{
private Guid _id;
private string _name;
private Address _address;
public Customer (Guid id, string name, Address address)
{
if (id == Guid.Empty)
throw new ArgumentException();
if (name == "")
... |
I'm currently working on a desktop application in Java (using JavaFX).
This application stores some user information, parts of which are sensitive. For example, if the user configures a proxy, it will store it into a file with encryption. Moreover, my application is calling a web API to execute auto-updates (with a bas... |
We have an email plugin which encrypts a mail's attachments when the user sends an email and gives the mail's recipients permissions to decrypt the attachments. The recipient permissions are stored on a server. The logic which executes on click of Send button involves some user prompts too. For example, if some of the ... |
On my first part-time programming gig during college, I dealt with a large-ish web application responsible for handling a periodic event hosted by our client, largely a plain CRUD snoozefest with a number of forms for the users to fill out.
The forms change between events, with most forms having a small amount of chang... |
For two choices there is boolean. In my case, I have positive, negative, and neutral which are three choices and cannot be represented by boolean. I've see there's method Math.signum(x) in Java which returns -1, 0, or 1. So, should I follow this practice (simply use -1, 0, 1 without creating constants) or create consta... |
Context :
We have deployed a cloud solution ERP (Acumatica) for one of our client.
There is only one dedicated Production server on the cloud hosting the app.
We have our own local server to develop and integrate the customizations our client asked us so far in the scope of the project.
Now, Our client would like to ... |
When I read and watch videos on Oath it talks more about being able to access data from other applications. However, a common usage of what I think is OAuth is simply identifying a user without requiring them to have a id/pw for a site. I don't see that explained very often though. What is the concept behind that proce... |
Update: I added some diagrams to help understanding
I had a discussion with a colleague about two different approaches in mapping data objects. I'd like to get your opinion on pros and cons between the two approaches.
Some background information. We have two external services. One is reached over SOAP, the other over R... |
I have a situation whereby I'm using a library that's been generated to provide an XML interface in C# based upon an XSD file run through xsd.exe.
The XML is structured as so.
-Results
-ModelA
-ModelB
-ModelC
-ModelD
When I'm actually working with this XML (which is mapped into internal memory objects ... |
Should a Software project have a Detailed Design phase, in which the detailed specifications (ie, the code) are spelt out?
The reason I ask about this is that finding the right syntax to be used may be difficult, given the myriad language features available. Therefore, it might be best to design the code before actual... |
I've got a production server I'm managing right now, but it's becoming incredibly inefficient to either:
SSH into the remote server, and develop server-side
Develop on my local machine and transfer changes to remote server
A possible remedy that came to mind was keeping a git repo that mirrored the filesystem of the ... |
I'm seeking advice from people using RabbitMQ to connect services written in different languages. Currently my organization is using RabbitMQ exclusively with C# and it's all working quite well. In order to provide some nice additional functionality over and above what RabbitMQ provides, we've implemented MassTransit... |
In Java's documentation, it states:
Don't allow subclasses to override methods. The simplest way to do
this is to declare the class as final. A more sophisticated approach
is to make the constructor private and construct instances in factory
methods.
From Clean Code(Page 25):
When constructors are overloaded, ... |
I'm learning DDD and I'm thinking about throwing exceptions in certain situations. I understand that an object can not enter to a bad state so here the exceptions are fine, but in many examples exceptions are throwing also for example if we are trying add new user with exists email in database.
public function doIt(Us... |
I have a group of 100 clients around the globe, that need to communicate between then self, fast.
Each message that each of the clients sends needs to be broadcasted to everyone. The messages will be between 1 to 16 MB. Each client is expected to send one message every half minute.
I was thinking of a tree structure an... |
I was talking with part of my team about the responsibility for who own the Binding and Queue creation. We are using Spring framework.
In async communication they agree that the responsability to create the Binding and Queue is of the Consumer. Until here, we all agree.
But they understand that this is not true for syn... |
I'm trying to make sense out of a pattern used with a javascript webgl framework.
background
WebGL uses shader programs to draw or compute stuff. These programs have to be compiled at runtime, so at one point they exist in javascript as strings.
The library offers an abstraction layer called "Material". It exposes hi... |
C# has events built in with a keyword. So if you want to declare an event, you write:
public event MyEventHandler SomethingHappened;
It is convenient, as it does allow you to add multiple event handlers, although it also prevents you from customising how events are handled, such as if you want to ensure that certain e... |
Consider a database table for user info like:
id, name, email
now consider I have another table for video something like:
id, name, description, length
Say a many to many relationship exists between them based on subscription. Obviously, to handle the relationship you'd create a third link table user_video_link:
i... |
This is closely related to this question which asks about the complexity of the following:
while (x > level)
x = x – 1;
x = 0
Using the graph method it has a Complexity = 2. Fred Swartz indicates a more faster way of computing complexity for Java/C# based on actual instructions from these languages:
- Start with a... |
Can you all take a look at my package structure to understand how i implemented clean architecture in android:
if we take a look at the clean architecture diagram it looks like frameworks is apart of the UI layer:
so the UI layer is apart of frameworks and drivers. so one of my questions then is it be more appropriat... |
I'm used to write unit tests with assertions which are based on the input, e.g. (hopefully self-explanatory and let's assume that using random test data is fine)
int a = random();
int b = random();
Adder instance = new Adder();
int expResult = a+b;
int result instance.add(a, b);
assertEquals(expResult, result);
Let's ... |
I am trying to incorporate BDD into the teams working practices to make interactions with Business Analysts more effective. I recently asked this question: Should I pass an ID number from the feature file?
Please see the code below:
public class Chestnut
{
private Guid _id;
public Customer (Guid id)
{
... |
I employ a lot of meta-programming to avoid repetitive tasks and build safer-to-use abstractions.
I recently moved to a new job where I am working in a larger team and this worries some of my colleagues, because they do not comprehend it.
I always try to leverage the full potential of the language, but some (not all) o... |
Imagine you have the following scenario. Your organization deploys some app core to its mission. For example if you're Stack Exchange, this might be the customer facing web server. Let's also say you subscribe to something like the 12-Factor App philosophy. Each app mantains its own SCM repo, which acts as the canonica... |
Ok please dont downvote because im serious about this question. I hope im asking this in the right place.
At programming school they are currently teaching us about project management. Instead of teaching us the classic waterfall model, spiral model, smart or other project management models they have their own which ba... |
First example:
countryRepository.getCountriesFromAsiaWhereAreTheMostPlanesAndBoats();
countryRepository.getCountriesFromAfricaWhereAreTheMostCars();
Are these names too big? How else do we call these functions?
I was thinking about parameters, but according to Martin Fowler, it's better not to use parameters in functi... |
I'm creating a popover component for a UI in React. That component contains a button that triggers the popover to display. Because the button needs to be configurable--label, classes, properties--I need to pass down these configuration parameters to the child. There are two main ways I see this happening.
Pass down la... |
When deciding for a new web project I have two design choices.
First, I can go for traditional web application design. In this case, pages are rendered on server side.
Second, I can go for an API server over HTTP. In this case, I have to develop a separate front-end client which will consume the API.
I think the second... |
I have some open source software I'm planning on releasing which invokes grep -nP via the command line. (Yes, this is arguably a terrible decision.)
The problem I'm running into is that while this runs great on Linux, my functions fail on Mac OS, because grep -P doesn't work as expect on Mac. I'll receive the following... |
I'm working on a JavaScript user script to assist my team in making assembling support tickets on a web interface more efficient. In doing so, I'm finding myself making a lot of calls to DOM API to gather data, e.g., with event listeners and user-triggered calls.
In an attempt to make my script more concise, I have mad... |
I am developing a newspaper-like MVC webapp with an article content type which has a visits field. The database is mysql.
Each time a visitor requests an article, the visits field of the article is incremented by 1. So I can easily query article table by their overall visits.
But what I want is to sort out articles ba... |
I work as a Business Analyst in a S/W development firm. At a previous company I was a BA in Asset Management, and the BAs there were more Business oriented (i.e. less technically inclined).
We are currently building a web application and I'm using JIRA to write the user stories, acceptance criteria etc for the function... |
I work as a business analyst in a software development firm. In my previous organisation, the development was done using waterfall and we wrote: "Business Requirement Documents" (BRDs).
In my current role, the team is using Agile Scrum and JIRA to write the user stories to capture the functional requirements etc.
My qu... |
Let's say I have a class SelectableEntity<T extends Entity> which has three methods, select, deselect, isSelected and count.
To take a somewhat contrived example, let's say I'm building an emergency messaging application that allows me to message to residents during fires, floods and other natural disaster.
I can selec... |
I have recently started exploring the field of machine learning (ML). I think I understand the difference between ML and AI at high level, but I wanted to understand more accurately the differences between these commonly used concepts.
After some research, I came out with the following boundaries for these domains.... |
I have a bit of confusion whether a method should create an instance of a class each time it's invoked? It is all possible to move this instance creation part to the constructor and just use the reference to call methods, but what is the best way ??
Code >>
Class B{
void readFromS3(){// this method reads from a S3... |
The facts
This is a very similar question to this one, but here I am talking about a more general case the MISRA-C3 Rule 5.0.2 or the SEI CERT C EXP00-C rule (more permissive).
Within MISRA-C3 I shall use parentheses to avoid implicit operator precedence. So the following code is correct, but to my eyes very boilerpla... |
Let's say I have a function that returns a dataset. First it tries to read it and if that fails it is requested from an API and then written:
def get_dataset():
try:
df = pd.read_csv('dataset.csv')
except FileNotFoundError:
df = pd.DataFrame(api.get_dataset())
df.to_csv('dataset.csv')
... |
I am currently writing an application with the following structure:
input: the equivalent of an excel workbook, i.e. a few tables with different headers and a few scalar values. They represent properties of hardware, workers, production processes,ecc.. in a factory and a few "global" parameters.
processing: compute so... |
I need a way to solve double withdrawal attacks in decentralized databases.
For example, a banking infrastructure has multiple servers with their own databases, the advantage is that it lets citizens have quick withdrawals and low latency, with redundant data.
The disadvantage is that it allows double transaction attac... |
I'm making a online game where I need to preserve some things for the players so each will have an account. However, I don't want to get into the business of storing user created passwords since that's dicey these days.
So I was thinking what's the point of even asking for the user to create a password for most apps t... |
Distributed Blockchain datastores provide inmutability to recorded transactions and only allow to add records accepted by a consensus algorithm in sequence. You could store data on the blockchain or have references to where data might live in other data stores. The blockchain does not seem to me like an ideal data st... |
Today I would like to ask you a question about open-source licensing.
My idea is to build a server community in a multiplayer game where you are can use scripting languages (like PAWN, Lua, Squirrel, etc.), allow people to contribute to the source code, however prevent people from using the source to open their own ser... |
We have a webapp that will rely on large CSVs from external vendors every month. When I say large, we are looking at around 6gb so a few million rows. Probably, 2-5 CSVs. This webapp will also allow users to enter, correct, and flag/delete data. The number of columns and cleanliness of the data is not guaranteed from t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.