instruction
stringlengths
34
36.1k
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 ...
Following Hevery's advice to inject collaborators into constructor rather than new'ing things within constructor body, how gracefully do this when a collaborator needs a back reference to its owner, without using an evil 'init' method (another violation of Hevery's best practices for testable code). E.g. export cl...
I recently attended an interview. In that I had to solve the issue for generating an billions of random unique number. For example method signature is as below : public Iterator<Long> generate(final long N, final Random rand){ } The returned iterator should contain N unique random numbers. This method will be teste...
I'm developing a simple online store with simple functionality. Among others, there're 2 tables: Orders and Invoices. What exactly should be included in one and not in the other? For now I can think of what they'll have in common: a reference to a product, quantity. For instance, a reference to a shipping method alo...
I contribute to a couple of open source software, and I've noticed two types of patterns when classes act on data. I am interested in the name of these patterns. The first is something that goes like this: class A{ public: void compute_something(int* var){ *var = 2; } }; int main() { A a; int r...
Many programming language use the syntax a[i] to refer to the i'th element of an array, sequence, or vector a - specifically, C and Pascal (from the late 1960s and early 1970s) do this. On the other hand, some earlier languages, like that Fortran (from the 1950s), don't use this convention. Also, I studied a bit of mat...
I have a question about java main (). java main() does not return anything. Per software engineering, a block of code which does not return anything is called a Procedure.​ So why do we call main() a method? should we call it the main procedure instead? Please refer: Method vs Function vs Procedure
I'm considering moving a monolithic REST API to a microservice architecture, and I'm getting a bit confused about data storage. As I see it, some of the benefits of microservices would be: Horizontally scalable - I can run multiple redundant copies of a microservice to cope with load and/or a server going down. Loosel...
I'm currently designing a 3D game engine in C#. I'm not sure why, but I feel like it's appropriate to mention that the engine will soon support multiple rendering backends (OpenGL 4.6, Direct3D 12, etc). I'm a point where i have 5 different projects within a solution in VS, and one more project that I use as a place to...
I'm building a simple app that represents some matrix, where nodes are added quite often. Currently I have following code for adding a new node: let mut new_edges = Array2::default((position + 1, position + 1)); for i in 0..position { for j in 0..position { new_edges[[i, j]] = self.edges[[i, j]] } } se...
I need to set a mode in one view from a different view. Trying to stay organized with MVC. Looking at answer at Invoke model logic in one UserControl from view-model in another UserControl without violating MVVM, but It seems redundant for a controller to update its view AND fire a signal for anything else to respond ...
Due to a new job opportunity I am switching back from WPF to WinForms. Currently I am playing around a little to get used to it. Here are my main questions that arose: Should I use the designer in a professional environment? It feels somehow wrong to get that auto-generated clumsy event handlers... Otherwise generatin...
If a team already practices Scrum method successfully, how does the Scrum Master participate in further development? Will he/she continue to fulfill the same responsibilities?
Imagine you have a list of Objects - like a list or array of objects representing users - and two processors: one adds/delete/modify some user under certain circumstances the other does the same thing by checking other conditions circumstances/conditions are verified by taking advantage of other classes/services etc,...
I am creating an invoice management system that has a User Class that handles the login system. Currently each User is associated with a Customer and the Customer class handles obtaining Monthly Invoices. My problem is that some Users are Business Owners and would like to be able to see all of their Invoices through on...
Say you are running two server programs on a single raspberry pi. Can they both interact with a SQLite db at the same time? Or seem to be happening at the same time as requests wait for each other to be executed???
I plan on using Scrapy to crawl a local website for a LOT of data and store it in a file. Then I plan to parse that file and put some of the data in a SQL database. Will my computer use less CPU and RAM to read and parse a big CSV file or JSON file? Or maybe it would make more sense to store the data in a bunch of sma...
I am hearing a ton of different info. I just found this in a site The 'paste' operation in the context menu or button press is not possible. It is not possible because of a browser security restriction that Javascript cannot take data from the clipboard without the user explicitly doing a paste command from the browser...
I have a bunch (~20,000) of large (~200 dimensions) vectors in an unsorted list. I can create a new vector of the same size, and I'd like to find the top N (usually 10 or so) closest (defined by cosine similarity) existing vectors from my list. Right now my approach is to generate a list of vector differences and then ...
My company just started a new production management software by using serial communication to scales. My company has already developed the software using VB6 in 2006 and keep using that outdated system until now. The new software will be a centralized management software using local server, and planned to use Node.js (...
Spending some time sifting through documentation, I'm trying to figure out the best software architecture with or without the dispose pattern. I've built the Repository pattern many time over the years, whilst using the dispose pattern which conformed to "best-practise". I actively use Ninject in which has configuratio...
In domain driven design based on domain events, I have the impression that several sources pronounce the rule that aggregates consume commands and produce events process managers consume events and produce commands I am aware that in event sourcing, the aggregate must consume events as well, but then they are usually...