instruction stringlengths 34 36.1k |
|---|
I am working on a USB stack in C. This stack will be open source and used in various different projects.
Various configuration options are available, which enable or disable large chunks of code and constant data structures. As this is an embedded project it is important to minimize the footprint of the stack, and one ... |
I would like to use DRY beans on my client-server application (DRY: Dont Repeat Yourself).
It is not a problem to me if it is highly coupled: I know that my DTO will have the same form as the database beans (Entity class in JPA).
The DTO have the advantage to loose coupling between application, but if they are copied ... |
Background
I designed a social-media application (such as Facebook) where there is this strong concept of audience-based content system.
For example, let's say this user A can create posts (public, private or groups only), based on that configuration, the post will only be available to that audience.
Solution
What I di... |
I'm managing a team in .net.
They are writing unit tests, use them locally on a regular basis, and love it. However, they keep pushing to have the unit tests kept as a separate project and only want to run them on a communal build server once a week or so.
In contrast, our JS teams are running tests on the build server... |
Imagine that you are developing a front end client that will consume an API. You're working on the login page and want to display errors to users below each field, in this case you want password related errors below the password field.
You submit your login information to the endpoint, the password is incorrect, and th... |
I found some java source code under MIT license on Github, but it is not included in any maven repository. I asked in issue to publish it somewhere, but nobody answered and looks like this repo is not supported actively (contrubutors may not answer for few months).
Can I publish this project to maven repo by myself wit... |
In my team, the Business Analysis is also a scrum team member. He will prepare all user stories to the Product backlog, but his tasks also should be managed with timeline/estimation.
Should we put those preparation tasks into the Sprint backlog together with development stories, or should we have a different way of tr... |
I would like to sort a list of people into buckets, as duplicates, by an email comparison, but I can't seem to find an efficient way.
Specifications
A person has 5 email fields, so in order to know if one person is a duplicate of the latter, I must compare each of his emails to each of of the latter's.
A might be dupl... |
Is a microservices architecture a good approach for developing a survey
application with the following features:
survey creation
online or offline data collecting
Reporting
|
I've been reading a few go blogs and and more recently I stubbled upon Peter Bourgon's talk titled "Ways to do things". He shows a few examples of the actor pattern for concurrency in GO. Here is a handler example using such pattern:
func (a *API) handleNext(w http.ResponseWriter, r *http.Request) {
var (
n... |
I am trying to build a derivation tree for the program
x = 42
using the specification for ECMAScript 2017. I see that there there is an AssignmentExpression which has the production rule:
LeftHandExpression = AssignmentExpression
however, I don't see any rule that allows an AssignmentExpression to be a literal.
Maybe I... |
I am currently creating Excel import modules for some complex data. I didn't plan it well and I have met code reuse issues. I have made first modules and I realized that next modules will need some methods from these I have already made. My first option was to solve it by simple inheritance hierarchy. Unfortunately I c... |
I am planning to improve my knowledge of Clojure and algorithms at the same time by implementing some known data structures in Clojure (e.g. linked lists, skip lists, bloom filter, etc.). However, I learned recently that this might not be a good idea.
[... T]he fact that getting an optimized solution is so difficult
... |
I've recently been reading Clean Code and there was a really nice example in java of when it is beneficial to break down a complex if statement condition in to a function rather than use a comment.
// Check to see if the employee is eligible for full benefits
if ((employee.flags && HOURLY_FLAG) && (employee.age > 65))
... |
How can I handle change requests to already finished user-stories?
Let's say there is a user story which describes how the user wants to list entities.
The story describes further:
which information of the entities should be shown (as columns).
under which conditions entities should be highlighted (background color)
... |
I've lately been very interested in reactive microservice design with streaming and event-driven architectures.
When one writes (i.e., manages) services, this paradigm works extremely well by simply responding to published events on topics.
However, we don't always control the implementation of all the services with wh... |
First, I'm still learning to do things in the best possible practices. I would like to know what would be a best practice when dealing with database queries. I've seen codes that query inside the loop to check whether that data exists or not. So let's say I have a set of codes shown below.
// assume that institutions a... |
I'm working on the data model of a service describing houses and flats. This involves storing quantitative physical properties of certain features of the premises, for example:
Speed of the Internet connection in Mbps
Length of a swimming pool in meters
Noise level of kitchen appliances in dB
The quantities will alwa... |
I'm creating an application that is composed using different modules (core, course, grades, news). I'm using clean architecture for the different modules but I'm stuck trying to pass data from one module to another module.
The idea is plug into one application (app1) several modules or use them in another application... |
I'm using Playframework with Java and I'm attempting to choose between a few choices for creating valid User objects (which will then be persisted into the database in my business layer). Play uses Forms as a way to help with validation.
So, inside my User class...
public User {
@FooConstraint
private String f... |
I'm trying to understand how a 2d or 3d map would be saved, and I'm trying to figure out quad trees. So like is each node represented by characters in a file and inside of that is the next one?
What exactly would the file look like, if its just a bunch of characters? Does the order of in which they are in the file sig... |
I have a proprietary application that I want to distribute and sell. The application uses a GPL v3 licensed binary/library.
Since I don't want to distribute the source of my application and also want to provide convenience to my users, instead of supplying the GPL v3 library with my application bundle, can I provide a ... |
I've recently been looking at C++ static analysis tools. One thing that confuses me is the terminology used with these tools:
Some tools are simply called "static analysis tools" (e.g. CppCheck), others are called "sanitizers" (e.g. ASan, TSan, MSan, UBSan) and others are called "linters" (e.g. PC-Lint).
Is there an a... |
I'm implementing a metadata parser of image files from all formats. I want to write tests for it. One trivial way to do so is to have test image files of all formats as a resources for the tests, and actually to read them as input. This approach may work but as far as I understand from unit test methodology, unit-tests... |
I want to generate a test scene for a unit-test (big file parser). What will be faster, to have a test file and to perform I/O on it, or to generate a large memory buffer using some static parameters during the compilation?
|
I.e. something that doesn't employ separation of concerns / use any form of UI architecture such as MVC, MVP etc.
An example would be a Windows form that had a button which, once pressed (user interaction), grabs data from a database (model), checks it against some business logic and then updates the UI, but all of thi... |
I am a beginner to the event-driven data architecture using Kafka / Kinesis as the centrepiece (currently Kinesis) and I have some questions regarding how to build a WebSocket API on such a structure. My specific use case is I have about 4 different data streams coming into Kinesis, I combine them into an 'aggregate st... |
It is often stated that Modbus/TCP isn't a real-time protocol. It is also "known" that Modbus isn't a real-time protocol. This despite the fact that the original Modbus protocol is highly deterministic.
In fact, as far as I can tell, the reason why it has historically and industrially not been considered real-time is b... |
I want to use a software which is licensed under the BSD, in my project.
I come up with two ways.
I create a directory for this component and copypaste the original LICENSE.txt file in this directory, and create a LICENSE.txt file for the whole system in the project directory.
I create only one LICENSE.txt in the main... |
I basically want to know if it is considered a good practice to persist the errors that happen on the client side of a web application (typescript/angular for example) by logging them to files?
Or if i can ask in a different way: What should i do with the errors/exceptions that i catch on the client side? (besides disp... |
Some background to my question: We have a traditionally windows-only C++ code-base which we are in the process of porting to linux. Parts of the system have been running on linux for many years, but some parts have never been built using any compiler other than Visual Studio. Most of the code is in Subversion, and we u... |
I’m finding it hard to avoid data duplication or a shared database for even the simplest microservices design, which makes me think I’m missing something. Here’s a basic example of the problem I’m facing. Assuming someone is using a web application to manage an inventory they would need two services; one for the invent... |
I'm working on a Windows application that is used for tracking document review and audit information for my company. The back end is a SQL server database and most of the user tasks are basic CRUD operations on the data that resides in SQL server. Most of the controls (listboxes, comboboxes, grids, etc.) are populated ... |
By these days I work in a legacy code that uses JAVA.
The project has a code tightly coupled and low cohesion.
All my teammates suffer to make changes in the software, one reason is that we haven't any behaviour test to secure that changes in software won't broken everything.
At the company that I work, the managers d... |
I'm working on javaFX project using Hibernate and H2 database,I'm trying follow the concept of MVC design pattern ,so I have created 3 packages :
models :contains POJO classes
2.1 views.fxml:contains fxml files
2.2. views.controllers :contains the controllers classes of fxml files
3
. dao:contains classes which they ... |
As a beginner I'll try to explain my problem as good as I can:
I'm currently trying to program a "simple" ECS. My basic idea is that I have a base "Entity class" which includes all sorts of functions for adding and removing components. Now I want to create some "templates" for entities, e.g.:
Entity Sprite:
Contains Te... |
Take the following example which loads an interstitial ad every 10 times user does XYZ in the app, under certain conditions. It is called in multiple places in the code base:
public class AdHandler {
public void showInterstitialAd() {
if (Subscription.isSubscriptionActive()) {
Log.i(TAG, "Subs... |
I'm working on an implementation of a webform decoder and am looking to support the nested webform pattern employed by PHP and Ruby/Rails (possibly amongst others).
PHP: parse_str(); Ruby: Rack::Utils.parse_nested_query()
I've noticed some inconsistencies, for example (behaviour is the same in both languages):
foo=One&... |
How can I observe ripple effect using coupling attributes alone?
I first find the common coupling metrics for a set of deprecated classes in a project, like CBO(Coupling Between Objects), RFC(Response For Classes), Import/Export coupling, Afferent coupling(Total no. of incoming edges to a deprecated package), Efferent ... |
After many years, I still unable to determine the correct way to define a class/function to play sound. Suppose my app may need to play some sounds, for example: button click, error popup,... How should I define the function?
** Method 1: one single function for all sounds**
//simulate languages features that enums are... |
I am new in a team working on a grown and complex Spring MVC application. The application context is widely wired using @Autowire annotated constructors. This seems to be the main reason for the issue I see with the application: there is no global structure of the application. If someone implementing a bean A needs a f... |
I started writing some unit tests for my current project. I don't really have experience with it though. I first want to completely "get it", so I am currently using neither my IoC framework nor a mocking library.
I was wondering if there is anything wrong with providing null arguments to objects' constructors in unit... |
Is there a rule/guideline about how to display a C# using() statement in UML sequence diagrams?
I'm right now in the last months of my apprenticeship. And to
prove, that I'm able to develop software from start to beginning, I
have to do a project which has to have a documentation. This
documentation will be shown to a ... |
So i have the following. I read in lines from a text file. Each line needs to be analysed and get the important data extracted (I wont go in the details here).
I worte a Parser class which does this job. Unforunately it can happen quite frequently, that the line data is not usable. I only find this out when read out th... |
I'm looking for a method to solve the following problem:
Assume there is a spool directory with a lot of files that need to be processed. There is a process A that is constantly writing new files to this folder and a process B that processes those files. So a classic producer / consumer pattern.
Unfortunately, at peak ... |
I would like to know what the .sqlite file is for. When I use MySql or MongoDB, the database is on disk, its something I never see. The documentation tells me with SQLite, everything is contained in a single disk file. Does this mean this .sqlite file is the database itself (and that it is, like all my other regular fi... |
I have a developer who wants to use comma-first code style in a PHP codebase to make it easier to comment out variables without having to move the comma around.
PHPStorm, configured to conform to PSR-2 standard, automatically reformats the following code:
<?php
$example = new Triceratops([
'option1' => 'green'
... |
Observer Pattern is defined by the 'Gang of Four' Design Patterns book as a "one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically".
They also say that the Observer pattern should be used in any of the following situations:
When an abs... |
I have a eventsourced project and I want to replay the following two events, in order:
ProductCreatedEvent
PriceChangedEvent
I've been told that projections should be asynchronous, so when replaying, the ProductCreatedEvent is projected at the same time as PriceChangedEvent. The thing is, since the PriceChangedEvent i... |
Currently I have following scenario.
I have two projects: ASP.NET Core Web API and Xamarin.Forms app. General idea is to have consumer (Xamarin.Forms app) which is getting data from server (Web API).
What I want to implement is caching pattern for the mobile app. Let's say, we're getting some products from the server ... |
Let's say you have a tic-tac-toe app.
There's the game state which can be represented by an array of size 9.
There's your "reducer" computes new state from old state and player actions.
Then there's your renderer which updates the UI based on the new state.
Great! Functional programming basics. Unfortunately, this is... |
I've been reading a lot about Type Script lately, and it seems really interesting, but I'm having some trouble understanding how to apply this to my current workflow, so let's start with that.
I develop mainly PHP applications, based on Symfony, Laravel and Zend 2, using MVC.
So most of the times, what I have is an jav... |
What would be the best way to add chat feature to an android, ios, and web app? Is polling really as bad as people say?
The requirements are user to user messaging and chat rooms.
Here is my thought process:
Long polling with in memory cache. The long polling endpoint will continually check the in memory cache. Pretty... |
according to Are there guidelines on how many parameters a function should accept?, a method should not have too many parameters. However, some answers suggest this issue can be solved by builder pattern:
Builder b=new Builder();
b.setParm1("a");
b.setParm2("b");
.
.
.
Obj obj=b.createObj();
or encapsulate parameters ... |
I create an application for a system, which consists of several different devices, each of which should be controlled by a computer via one of standard hardware interfaces and could be accessed via Ethernet (Sockets), Virtual COM Port, ready-to-use 3rd party C++ API, etc.).
My application should have GUI to manage a... |
I'm not sure if my diagram is correct. Is it ok to have this number of <<include>> relationships?
Note: My system scenario: The user goes to the web page and enters any Twitter user account, then my system will collect the desired user's tweets, clean and pre-process them, classify them, calculate the classification re... |
Your package has a bug. Its API in some scenarios doesn’t follow the documentation and the intended behaviour. It has been that way since it was v1.0.0. You fix it to match the documentation. Should the next release be:
Major / 2. Minor / 3. Patch?
|
In my web app, users can input values in a form and send it to the server. The possible input values are stored separately and are imported using AJAX when a user opens the web page. This way, the possible input values can be changed from a central place and dosn't force the developer to change html pages when he has t... |
I am trying to apply BDD and DDD together to a new project The problem I am having at the moment can be summed up by the following quote (taken from here: https://www.infoq.com/news/2015/02/bdd-ddd):
"The approach for most BDD practitioners is to test outside–in by
testing every scenario through the user interface, ... |
I try to write most of my code using standard practices. Those include amongst other and related to this specific question having short-ish functions, well encapsulated objects when OO is used, not too many function arguments or return values (I mostly write in languages where implicitly returning tuples is allowed, bu... |
I am working to on an application which generates XML based on user input.
Currently the application is in Design phase. And I am really confused on how to progress on this.
Well the Idea is that:
The Application will have UI module, developed using Angular.
REST Api module developed using Java JAX-RS. And
Will have a... |
We have a large set of existing key-value pairs (e.g. product specs). A made-up example might be:
Prod 1, LOGO, The standard 1990 Audi logo is located in the center of the grille.
Prod 2, LOGO, The standard 2010 Volkswagen logo is located in the upper right corner of the trunk
Prod 3, LOGO, The standard 2005 Porche log... |
After reading and using different concepts(right or wrong) questions related to modularity have appeared.
I want to implement the microservice architecture in my projects the right way.
As from what I have understood in order to follow this architecture my
project needs to be modular.As an example breaking down a so... |
My web api method should return some structured data about my profile. To do it I created the following POCO classes:
public class ProfileInfo
{
public string FirstName { get; set; }
public string LastName { get; set; }
//....
public ProfileAddress Address { get; set; }
public ProfileDriverLicense ... |
I would like to share common NuGet package values between projects in the same solution, such as Author, Company, Copyright, and Product.
Previously (using the 2015 project format), I would use a combination of AssemblyInfo.cs and a shared (linked) GlobalAssemblyInfo.cs that contained all the common settings. Now that ... |
Sometimes when submitting bug reports for computer programs, I'll see developers say they need to "triage" an issue.
I'm triaging this issue now. It started appearing sometime after version 3.4
Searching triage shows that it is used in the medical field for determining issue priority. However, I'm interested to know ... |
A few years ago I was using Sonar (before it was SonarQube) to analyze some Java code, and I remember seeing a useful metric that would come in handy again today. However it does not appear to be part of the SonarQube implementation that I have access to.
The metric described the way by which a class could easily be b... |
Today my college presented to me an argument about not use some primitives that I never heard before. I would like to see what you guys think about it.
We have a class in our project like:
class Order {
private long id;
private String name;
// more fields
}
We have a builder for this class for all the fie... |
So I’ve got a service I’m trying to clean up. It responds to requests by starting a stopped server on Amazon EC2, waiting for it to come online, then configures a 3rd party piece of software on the server through a rest api, and then sets a task to start on that 3rd party piece of software. The service also does some m... |
There are already many useful answers about MVC. Most of the topics clearly state how controllers and view interact. A controller is aware of model but is the model also aware of Controller?
A concrete example: Suppose i want to move an object in game, A button is pressed, It sends coordinates to the controller along w... |
Please pardon me if this is a duplicate question.
I have two nested for loops which will iteration for around mn times (the complexity is around 3k).
Inside these for loops, I have 3 If conditions based on what I do certain operations. I am trying to see if there are any ways to avoid these if conditions inside the f... |
Our team uses TFS for version control. Our branching strategy is as follows:
We have a main branch that we use as the dev branch
In a four-weekly cycles, we release our software
When this is done, a release branch is created from the main branch,
representing the state of the software as it is released
When changes n... |
I am currenctly trying to create an API for a UI framework, for a new application. This UI framework is internally implemented using an existing framework, let us say JavaFX. I want to hide the implementation details from the user (the developer using the API), so for instance, when the user addresses an image, I want ... |
In my server, I have 1000 threads that are listening to 1000 different UDP sockets. When a thread receives a packet it puts the UDP packets on a thread-safe queue. The code is like this.
while(true)
{
......
socket.receive(packet);
packetQueue.add(packet);
.....
}
In a se... |
Should Database migrations be in included in the same deployment project as the code?
If they are not included in the same deployment, the Database deployment package and the Code deployment package will get different version numbers and this will generate confusion trying to figure out which Database version correspon... |
I've been incorrectly referring to domain entities as DSL, and I want to know what's the correct word for it. Let me give you an example:
In the system I'm working on, we have entities similar to a message delivery system. We have Envelopes and we also have Recipients. I've been using the term "DSL" to refer to these, ... |
There's a common code smell involving long methods with the most common answer being that methods should be really small, less than 50 lines per say (or 20). I understand why this is because it enhances readability, reduces repeated code, etc. However, I was wonder if this is at a statement level or at a file line leve... |
When designing REST API I generally start by identifying the resource of my system, to give an example let's say that we manage multiple blogs, each one with multiple posts, each one with multiple comments.
The standard REST API for a case like this would be to have some endpoints like these ones:
/blogs //all blogs
... |
I have some classes that contains both immutable (primitive & references) and mutable data, but mutability come from external writes (another process).
To avoid using synchronized on every getters/setters (and around the update operation, atomicity is important) or a ReadWriteLock, I came up with this solution that rel... |
In C# (and other languages), we can define a numerical variable as a short, an int, or a long (among other types), mostly depending on how big we expect the numbers to get. Many mathematical operations (e.g., addition +) evaluate to an integer (int), and so require an explicit cast to store the result in a short, even ... |
I am designing a program responsible for a GUI (with the graphics and user input being managed within a typical update loop) which has several states:
The default state is an animation which continuously runs despite any user input.
A notification state can be invoked which displays a notification instead of the anima... |
I heard that static (in the Java sense, basically a static method is called on the class itself and not on an instance) is not True OOP. However, how would the Singleton pattern be implemented in such a language. I thought of having an FooGetter class, and calling a getFoo() method on an instance of it, but how will th... |
After I learned to properly use private protected abstract sealed in a language like C# I found no reason to make a variable public ever again.
An interface to the variable is usually a public method if it is an action/verb (e.g. Car.Move()), or if it is a value/property of the class then I use property with a public g... |
I am trying to understand how E-commerce sites handle huge amount of inventory and the transactions associated with it. With respect to this, i have some basic questions.
Consider a E-commerce website running on multiple servers
and the inventory associated with it is small and can fit inside a single server.
Where sh... |
I have a Windows desktop application build in C# which auto updates itself when an update is available. It uses an MSI installer package for this.
Sometimes while updating app, a PC shutdown due to power loss can happen, and when system reboots my application gets corrupted. The only option then left is to repair it ma... |
Let's say I have a class like this:
public class MyClass
{
public string A { get; }
public string B { get; }
public string C { get; }
public MyClass(string a, string b, string c)
{
this.A = a ?? throw new ArgumentNullException(nameof(a));
this.B = b ?? throw new ArgumentNullExceptio... |
I'm trying to better understand unit tests and integration tests. I understand unit tests should be in isolation and their dependencies should be mocked. But I'm slightly unclear on the best approach to assert that each class unit tested integrates with it's dependencies.
Here is an example:
I have a class called Elas... |
I have a members collection in MongoDB database where each document looks like this:
{
"_id" : "8801",
"name" : "John Doe"
}
I need to store family relationships between members. That relationship is not directed.
Let's say John and Martha and Peter are family. When I query for John's family, I want Martha an... |
We currently have a maintenance role within our team which the developers on our team rotate each 2 week sprint.
This consists of:
Responding to user bug reports & creating stories/issues for them
Responding to negative app store reviews
Troubleshooting user problems
Responding to overall user feedback & feature reque... |
I want to incorporate some open source libraries into my C project. This is the first time I do that, so I don't know what is the right or most common way of doing it.
I see two possible paths I can take:
Download the code of each library I'll use, add them to my project
folder and modify them as I need.
Just list eac... |
So I am junior programmer, and I just started working with .net webforms a little over six months ago. I have been studying SEO, and trying to optimize best practices with a senior level developer. I feel like 302s or in .net webforms response.redirect is misused alot. It could just be our team's logical flow of proces... |
I have a simple query, when executed directly in SQL Developer Studio (It's an Oracle Database) takes around 4 seconds.
But when executed via my Java code it takes around 20 seconds.
I'm using Spring JPA and using the @Query annotation with native=true. I'm measuring the time using a custom annotation and Aspect.
So fa... |
This is a known pitfall for people who are getting their feet wet using LINQ:
public class Program
{
public static void Main()
{
IEnumerable<Record> originalCollection = GenerateRecords(new[] {"Jesse"});
var newCollection = new List<Record>(originalCollection);
Console.WriteLine(Contain... |
When I have a class with multiple constructors where one constructor calls another one (constructor chaining), which constructor should be the one that all the other constructors call eventually?
Here's an example where the "all args" constructor calls the "no args" constructor:
class Goblin {
// always starts at 1... |
Non-developer UI / UX designer here. Looking at ways to show android prototypes on some dev tablets that are locked down. Locked down in a sense that they can't get to android market they only have access to their own suite of apps but new apps can be loaded to their system for testing. So a loadable apk is really the... |
This will of course depend on the algorithm generating the pseudo random numbers, but what I'm wondering is whether practical, usable pseudo-random number generating algorithms exist that never repeat the same number twice until their period is up.
|
I am working with a REST API which resides on a server that handles data for a multitude of IoT devices.
My task is to query the server using the API to collect specific performance information about said devices.
In one instance, I obtain a list of available devices and their corresponding identifiers, then later quer... |
So I have this idea i'm playing with to make my own neural network experiment from the ground up as a fun hobby exercise, so I have something to learn, and to expand upon in doing research for what I want to code. I'm totally aware i'm re-inventing the wheel. But I'm doing it for learning/fun/hobby purposes.
My approac... |
Our company develops and sells a cross-platform C++ library. We distribute binary only versions for Windows, Mac OS X, Linux, iOS, Android, etc. The only source code the customers get is the header files with the class interfaces. Our IDE is Visual Studio; we're very glad it now supports cross-compilation out-of-the-bo... |
An interesting question I've stumbled upon:
Let's assume a java application creates a data model, converts this data to a json object with two fields and uploads it to a server:
{
"FirstName": "Foo",
"LastName": "Bar"
}
Now a different technology, say js, php, etc on the server needs to process the data.
Both ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.