instruction
stringlengths
34
36.1k
I want to ask for any suggestions for an architecture I can implement for a Java app I need to create (initial thoughts below). It is supposed to be a local Swing application for tracking financial aspects of multiple construction sites. Excel-like but with a few additional features like mailing data etc. After some th...
So, we have a problem. I googled to find if it was a solved problem, and found a link describing an algorithm which is just about what we need. They also included a sample implementation. Just, not a std:: or boost:: library, like I was hoping for. Copying and pasting is of course dangerous in itself, and of course mi...
Simple question: is the result of a slope calculation in Python (say, stats.linregress() function) in units of radians, or unitless (e.g. what's 18 deg or 0.314 rad would be equivalent to 0.2 in the function output)?
Given a password, I am trying to validate if it passes all validation rules such as Be at least 6 characters long Contain at least one letter (a-z or A-Z) Contain at least one number (0-9) Contain at least one special character (@, $, %, etc) So I am creating a common validation class which can be used for in an...
I use an online kanban-board for my projects. Even though I work mostly alone, it helps me keep track of what would otherwise be an Alexandran Library of post-it notes. While I'm sure my process is pretty far away from actual kanban/scrum, I try to keep my process similar where possible, as it helps me avoid process de...
I am working in a team, which is developing new web applications versions for our old solutions, but there are some innovative ideas as well. We are using Angular at the front end, Java at the back end, MongoDB for database and running it via Spring Boot. At the current stage, we have two applications finished, and mor...
I have a web application with medium-high traffic where users can save designs made by fabricjs, so each saved design is a json with many parameters. So basically two days after launch users have stored almost 300 rows of designs, PhpMyAdmin says a total of 31 MB of size. Each json is stored as a longtext data type so ...
I'm developing an Java Web Application with Spring, and I have some questions about my architecture. Before showing it, here is the context: I am developing a web application with more than 80 existing tables in the database. Both the application and the database are on the same server machine. My application will gro...
I would like to hear opinions/best practices for the following scenario: I have an application A (C# app from a vendor that does not have an accessible database, it has a sqllite db but we don't have access to it) that needs to export small amounts of data to application B (custom C# homegrown app with a SQL Server Bac...
Hypothetical situation - can a currying function have an unknown number of arguments (kind of like varargs) Eg in Python: addByCurrying(1)(2)(3)(4) Should equal 10 addByCurrying(5)(6) Should equal 11 How could I implement it?
Is there any standard/encouraged Windows batch file coding style? I would think that if I want my batch files to be easy to read/mantain, I should care about this, but searching the web I found very little about it, and I didn't get any reviews (not even comments) on this Code Review question, so it makes me wonder if...
We do simple data entry validation with attributes on the viewmodel. Think format of an email address, mandatory clientname, format of a date, the housenumber being numeric etc. Now there are also more complex validations which will hit the database and external services: check if the id is a valid one (external servic...
Suppose you are designing today a JavaEE JSF web application. You have a choice on the one hand between making the methods of your CDI beans @Transactional, and on the other hand injecting (session stateless, or singleton) EJBs in the CDI beans, and then the methods of EJBs would be executed under CMT transactions. Wha...
This might sound weird and probably is, but I am struggling to find a good place where to place what I will just call "Doers" for lack of a better name. Basically, my project currently has these Namespaces (Folders in src) / /Error (Custom exception classes) /Facade (Facades for legacy operations of things not yet conv...
So, as stated on wikipedia: Lustre is a formally defined, declarative, and synchronous dataflow programming language for programming reactive systems. It began as a research project in the early 1980s. A formal presentation of the language can be found in the 1991 Proceedings of the IEEE. In 1993 it progressed...
I am currently developing my own programming language (written in Lua). The text analyzer is composed of two functions: lexer and parser. lexer takes as input a string, cycles over each character of it and divides it in tokens, either single words, numbers, strings, or symbols. It then returns an array of them. parser ...
I'm working with a Blue Giga BLE112 usb dongle. They supply an API in the form of several header & *.c files. It all works off of callbacks. For example. int main() { // defined in a "cmd_def.h" & implemented in "cmd_def.c" ble_cmd_connection_get_status(); // read messages off the usb serial port forever ...
I define an algorithm to be best if it minimizes the total run time over commodity hardware (e.g. normal desktop and server PCs). I have sets A and B. I also have function f that works like f(a, b, n), where a is some item in A, b is some item in B, and n is some natural number. The output that this f(a, b, n) returns ...
At first, I thought that the people writing the code should also document it. But there are reasons why this might not be true. A person who is new to the code could ask the right questions which might be dismissed as "obvious" by the author. My question is if there is an established practice (or practices), and what i...
Let's say you implement an interface like: public interface Example { InputStream getThatContent(); } In this case there is no property, and the implementation may also have side effects (it can open a new InputStream). This is happening also in other API, like JDBC: public static Connection getConnection(String url...
The page is loaded as a normal MVC page. The ajax is so the user can add items to their model without having to reload the page. Right now there is no Web API in the project. I don't want to add it unless it makes sense but I'm worried that using AJAX on an MVC controller is bad. All the books I've read and at work we ...
I'm studying the SOLID principles and I'm having some troubles dealing with the Specification Pattern and the open/closed principle. The fact is that the Specification pattern introduced by Eric Evans and Martin Fowlers creates some abstraction and a really open way to manage business rules. But I was wondering if it ...
I have been pondering over the idea of a Python-based Operating System on top of the Linux kernel, much like how Android uses Java. What if most of the system components were built using Python, this way most of the Operating System can be modified by anybody who understands Python code. This can allow anybody with Pyt...
Say that I have a REST endpoint that takes an integer as a parameter: /makeWaffles?numberOfWaffles=3 In this case, I want the number to be positive because I can't make a negative number of waffles (and requesting 0 waffles is a waste of time). So I want to reject any request that does not contain a positive integer. ...
As I begin to make the leap from the Firefox Selenium IDE to Selenium 2, I'm realizing that a significant portion of tutorials, guides, books, and documentation regarding WebDriver is based in Java; C# seems to take a somewhat close second. Is there a benefit to one language (C#, Java, Python, Ruby) over the other? D...
Can anyone give me some insight in what happens to traditional release management when an entire enterprise moves into agile? for example, lets say an enterprise operates in a waterfall method, does one big release a month and the systems are tightly integrated. lets say the enterprise moves to agile and the dev teams ...
Gosling said that "[C# is] sort of Java with reliability, productivity and security deleted." (from Wikipedia)
We are using gitflow and currently have an open release branch. The release at A is currently on the test-system to get tested by key-users. In the meantime we need to release an urgent hotfix. Commonly we pull out a branch of master (so the latest live-system release) and merge it into development and master. If we ...
I'm thinking about the right database design for this requirement. It's a manual maintenance check. A company can have a maintenance contract comprising HW checks, Sys checks, both or none. The part with the CommandParameters worries me especially. The amount/name of the commands can be changed after a while, furtherm...
I'm would like to know your opinion of what is an ideomatic way writing a OR function in functional reactive programming. That is, if I have x number of signals which can return a truthy or falsy value, how can I evaluate if at least one signal is truthy, or all signals are falsy? Finally I would like to send the resu...
A comment on a previous answer made me think about our hotfix policy. A current project for example is used by about 300 users all around the globe. One location found a strange bug where they issued a specific number into a combobox. That resulted in a complete server error (the session was reset with a 500 http error...
Is there a convenient and sustainable way to handle code indentation and style in a team in which multiple IDE's (Emacs, XCode, VS) are used by different programmers? We are using git, so, should we use a precommit hook or should we integrate the auto-formater into the IDE of each developer directly? I think the first...
I have always known that goto is something bad, locked in a basement somewhere never to be seen for good but I ran into a code example today that makes perfect sense to use goto. I have an IP where I need to check if is within a list of IPs and then proceed with the code, otherwise throw an exception. <?php $ip = '192...
The basic arithmetic a computer chip can do only works on numbers(integers or floating point) of a fixed size. There are many algorithms that could be extended to work on numbers of arbitrary size (and some require them). Therefore, a way to store and perform arithmetic with arbitrary-size numbers is good to have. For...
I'm trying to learn the language Inform 7 and its very odd programming model. Unfortunately I'm finding it hard to get my head around it because the language reads so much like natural English. I can't seem to intuitively understand what natural English statements are and aren't valid statements within the grammar. Ha...
I've got some code that's searching pixel by pixel from a starting point, at a certain angle, until it finds a pixel (a non-white pixel) It only has to search around 300 pixels: I'm currently using polar to Cartesian function 300 times... def pol2cart(rotdist, cwangle): x = rotdist * numpy.cos(cwangle) y = rotd...
These days I'm learning CSS by reading specifications, but I noticed W3C marked CSS Basic Box Model Level 3 as "Dangerously outdated" without any further explanation. So my question: What's the reason for considering that specification outdated? Why CSS3 Box Model is Outdated but CSS2.1 box model is not outdated(beca...
One of the important concepts in Object Oriented Programming is Encapsulation. However, lately the software world seems to be tilting in favour of other paradigms like functional programming. It makes me think, what about encapsulation and other OOP tenets? Are they wrong? Is it that OOP is applied wrong? For instance ...
I am currently facing a problem in the application I am developing that I think is the same as, or an analogue of, the Dining Philosophers Problem. In my application I have a list of N resources. I also have a queue of tasks that need a number from 1 to N of these resources to run (which are continually generated at un...
Lets say that our Tetris board is represented as a 2D array of zeros and ones, where a 0 means empty and 1 means occupied, and you where asked to find the highest row in which a tetromino exists. Assuming that we didn't keep track of the height that is for every tetramino placed check if its row is > previously placed...
I stumbled across an API from a popular vendor in my sector that asks the client to dynamically determine the max records allowed in a single POST request by first performing a GET request and retrieving a property called MaxRequestSize. The idea is that the client is to use this property to split up their records and ...
Suppose you have a very simple CRUD where you are just storing a simple tuple-like type of data, but its natural primary key is cumbersome for the user to remember (very long, difficult to write, etc.). Further, suppose I want to let users refer to the records using a handle such as an autoincremented integer value (wh...
Assume you have a client application which is known to connect to a given IP, and send a fixed size message (of size X = ~dozen bytes) upon connection, and wait for a reply. If you're writing a server, can you guarantee that the first (non-EAGAIN) call to read() (assuming no errors) on the (non-blocking) socket after t...
Our team develops an application. As this application intended to run on Debian, we've done it in a proper Debian way - via .deb packages. This app is written in C++/Python and versioned using Git. We have a private Debian repo where I place snapshot and release versions (approach taken from Java world): appname-1.2-S...
Python has many modules (such as re) that perform a specific set of actions. You can call the functions of this module and get results, and the module as a whole has an idea behind it (in this case, dealing with regular expressions). Classes seem to do almost the exact same thing, but they also seem to use properties q...
We are building a REST API which creates items in a CDN. Each item takes between 5 and 7 seconds to create, and we need to create them as quickly as possible until we have about a million of them. One school of thought in our office is that we should make lots of small transactions. Another is that we should have f...
I've got a problem and I haven't yet found an explained solution to get it drilled into my head: I want my object to make a basic rotation TOWARDS the mouse cursor, not the lock-on. I know it must be embarrassingly easy since there's not many threads documenting this, yet I'm loosing my mind when seeing (wantedAngle-ob...
I wrote a small program, about 10,500 lines and everything works perfectly. It is a Math game, which has is login and sign-up process and all data is stored on the user's computer in multiple text files. It has support for multiple users. I wrote a function which allows the user to search for another user in the datab...
I have a Java application which does the following: Tool takes a document which it will parse. Tool calls external webservice Tool completes execution However, when I tried to run this application in two different 'environments', there is a huge gap between the performance of the tool. On the first environment, it ta...
In language Swift, to initialise an instance, one has to fill in all of the fields of that class, and only then call superconstructor: class Base { var name: String init(name: String) { self.name = name } } class Derived: Base { var number: Int init(name: String, number: Int) { //...
I have a method called Buy, when called it does the following: It calls a factory to create an order Calls pay on a payment object Calls empty on the customer's cart Calls the dao to save the order This is what my sequence diagram says should happen, however, when I write my unit test for testing that it calls Empty...
So I am facing a problem with handling all sorts of exceptions within spring-boot application. Basically project is structured: back-end (services, repositories) <----- RestControllers <---- UI (React\Angular) The gist is that UI depends on Rest API wile rest API depends on Back-end services Now - Rest API is designed ...
I am building Rest APIs for an iPhone app using the PHP framework CodeIgniter. Please let me know how I can ensure that the API is accessible via the app only. This means that if anyone wants to access the APIs from outside the app, it should not be accessible.
I have an entity class package org.demo.stack; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; @Entity public class ValueHolder{ @Id private Long id; @Column private Long value; /* getters and setters... *...
I'm doing a lot of code analysis using lexer and finite state machine. For time being I'm using table to describe FSM: | token | current state | target state | +-------+---------------+--------------+ | . | start | dot | | trace | dot | method | | ( | method | detected ...
We have authorization server which is in charge of checking token validity, expiration etc. Which HTTP status code should be returned if the authorization server is down? Should it be 401 with "Authorization server down" message, error 500, or something else?
Is it correct that homeitem should be declared inside the OnLoad method and overgiven to all the render methods instead of just declaring it as a global variable and accessing it by all the render methods? public partial class Default : Page { /// <summary> /// Initializes the module. /// </summary> ///...
The following code snippets are simplified to demonstrate the context! The actual interfaces and classes are POCOs having additional properties. The types are part of library I am working on, the interfaces are public API, the classes internal API. I have: an interface IValue public interface IValue { Int32 Value ...
Say I'm offering a REST'ish API that offers you Meals Now If you want to get ALL meals naturally you get it through something like: GET /meals if you want to filter those meals you can do something like: GET /meals?vegetarian=true But what do I do for a very complex Request where the "query" looks more like: [ vege...
First: This is for a project that is already deployed, and requires a solution that isn't "rewrite how the whole thing works"! I have a "record detail" screen of sorts that is storing the corresponding RecordID in a static variable. Within this screen you can drill down, which passes the RecordID into a bundle and is r...
I am new to the Java 8 time package, and am trying to better understand it and make sure that I am making good use of it. Is there a specific reason that LocalDateTime's truncatedTo(TemporalUnit) does not support ChronoUnit values past Days. I think I put together a successful implementation of such a method, but had c...
Given a list of items, I want to break it up into four groups with as equal length as possible. The items need to stay grouped by the first letter in each item as well. 26 letters / 4 groups would generally cover 6.5 letters in each group. If we had an equal amount of items starting with the same letter in each group i...
Context: We have 2 servers (internal and external) that have to hold identical data and remain in sync the entire time. Our internal system is like a local cache and we allow read/writes to the data before saving. Saving triggers a local save and a save to the external system. Single atomic changes are easy, but we ...
With respect to computer vision (CV), I always hear these three terms used almost interchangeably: Structure from motion (Sfm) 3D reconstruction Stereo vision/processing However from what I've read, these are similar-yet-different, but nowhere can I find a universal definition of how they are different. According to ...
My main language is currently JavaScript, and I'd say I'm fairly proficient in it. That is, when I think "I want to do x", I don't (generally) Google "how to do x", but I think "I know! I will use features/techniques a, b and c to do x". I am not very familiar with the new ECMAScript 6 features (basically an update to ...
I am new to MVC, and just inherited a project that is still in it's early stages. The scope is a user interface to manage a single SQL table. There is a model that represents the entire table (select * from table). The previous programmer also created several models that represent a single column (select columna from t...
It is clear that it is preferable to put your source code in a version control system e.g. SVN. When a source is compiled, you get an executable. Different versions of the executable and various different input parameters (which in my case ~1000) and other input data is proving to be hard to manage. On top of this I ma...
I heavily use Excel and CSV at my workplace. File 0 Excel File The initial file is an Excel file. Let's call this File 0. This may or may not change with time depending upon the requirement of the project and input of the client. File 1 CSV Data Sheet By observing the notes in File 0, a CSV file is created. Let's call ...
I am trying to figure out an implementation for a solution to a problem I outlined in another Programmers.SE question. I need to find a solution for this problem in C# most likely using the collection in the System.Collections.Concurrent namespace. My problem is a classic problem related to the Dining Philosophers Pro...
Unit testing has been widely lauded as an indispensable part of software development, and TDD has many proponents. However, due to the combinatorial nature of various pieces of code, it can be difficult to know when you have enough coverage of even a single method. Consider a method that checks for an intersection betw...
As any good password storing developer I have user unique salts that I use to generate password hashes. ie I store a uniquesalt and SHA1(salt + password + "applicationuniquestring") in the database for each user. If someone were to get my database they could theoretically create a rainbow table for every user and have ...
Some people have this problem that they cannot think without words. And writing down their thoughts and decisions is the most effective way to proceed. So - is it normal and acceptable that I write down my thoughts and decisions in some Notepad++ file during coding? Sometimes it should be acceptable, e.g. when recreat...
DI frameworks like Guice and Spring are the common tools to abstract out dependencies to make Java code testable. However, there are several alternate methods to achieve the same goals. One in particular is making the code to test depend directly on certain classes and then varying which implementations of those classe...
I want to keep the end-user (often myself) from being presented with inapplicable methods when coding directly in an interpreter, but I also don't want the user to have to inspect the incoming data and then determine which class to instantiate. This is probably the XY problem, but here's a working example, in which I s...
What name can you give the surrogate key column in a database table when the convention suggested name collides with that of an existing user field business key? For example, if I am creating a Product table and ProductId is already used and known by that name in the company, business-wise. A example value of existing ...
So I'm coding a way to send events to multiple clients, and then having the clients decide how they want to handle it. I'll exclude the bits that don't lend themselves to explaining the situation. class Event_Beacon def add_event_eater( self, ee ): self.event_eaters.add( ee ) def broadcast_event( sel...
I have inherited an application which performs approximately 100,000 executions in a C# for-loop against SQL Server. for (int i=0; i<100000; i++) { //Execution can take 0.250 to 5 seconds to complete. ExecuteProc(i); // no result returned } To reduce the time it takes to execute all 100,000 procedures, would it be...
I have a web application and a REST API server (Microsoft Dynamics CRM 2016) that I don't have access to it's code, but I have access to the available resources. I need to create a data sync between both servers, some of the tables are one way and the others two way data sync has to be done, I haven't found any good so...
In my Django web app I want to monitor my remote Raspberry PI clients - up to hundreds - using WebSockets: I have to check in their status in real-time (online, working, offline etc.), send commands to them (start, stop, reboot etc.) and so on. I had a look on Django Channels and, following this tutorial, I set up a wo...
I have a object that needs values from a grandparent object to perform a calculation. What is the best way to handle this? Should I create a separate calculation class to get the data, perform the calculation, and return a value? Or a "parent" field, so I can traverse back up the object to get the data? Or a service th...
On the GPU, each thread has access to "shared" or "local" memory, which is analogous to cache on the CPU. So instead of just caching the most recent page, I can tell my program which pieces of memory will be accessed most frequently and manually keep those in cache. My question is: why do CPU designers not allow an ana...
I want to implement something similar to the algorithm described here. I don't even know if "algorithm" is the right word, since many of the steps are considered to be algorithms themselves. What I've done in the past in situations like this is to encapsulate each step in a private method of a class, and then provide a...
We have a big set of survey questions, which we distribute to users online. We collect submission from users and based on their submission, we decide the answers for those questions. Now, each user gets a set of questions, say N. For each submission given by user, he/she gets some points(cost c). Now, there is a upper ...
I am trying to implement the use of two database in my application, sqlite and mysql. Currently i added references to both database connection library, and duplicate all first checking which database option the end user selected, and calling the appropriate function. Though i only implemented a test, i thought this wou...
What are the actual perks of using an annotation that adds a particular functionality to a class or a block of code (other than rapid development purposes of course)? This may come down to preferences but I do not use annotations at all, as they can put a limit on the developer. One can easily lose the freedom of custo...
I am developing an application which will use user sessions stored both in the client and on servers. Should I treat them as different repository implementations and use DI to use them inside domain services? Any suggestions?
On my team of 5 coders, we've traditionally adhered to a common git commit message standard stating (only) two rules: commit messages should include the why rather than just the what and they should be written in the past tense. This is quite loose (e.g., some people prefer writing longer messages, some write shorter o...
I've joined a very large new company who have very different ideas about what constitutes quality in development. In trying to convince managers about what should change, are there any well accepted documents about development practices in an agile environment? We work in mobile development and the existing developers...
I have just finished an iOS application for a company that will be sold commercially to schools and other organizations for a flat rate with an access code. I was wondering if anyone has had any previous experience with access codes, and what would be the best way to implement this design in to the app? I received equi...
I'm a heavy VBA user that when has the chance to do a little project in python it's like going from hell to haven when it comes to programming itself. Still, I know that my users want reports in excel (for good reasons) and I'm just not ready to give up how amazingly easy is to deploy a new version in excel: just save ...
I've created maybe five services like RoleService, AuthService, etc. Each of them has some state (e.g., RoleService.role, AuthService.isLoggedIn) affecting a lot of controllers and some other services and directives. Sometimes I need to $watch the variable, so my hacky solution was to put the whole service in the $scop...
I have recently started a project where I need to make extensive use of videos and books. And all of them are needed to be stored locally. I want to be able to search all these books and get access to them as quickly as possible. I don't want users of my application to have access to the content (books and videos) out...
for example, I have A.h, which has a class A with some empty methods: class A : public B{ public: A(){ } virtual void b(){ } ~A(){ } //other methods }; should I move all empty methods definition into A.cpp: #include A.h A::A(){ } void A::b(){ } A::~A(){ } //other methods ? and which i...
While working with one project I was assigned to, I noticed a small problem with our SVN strategy. A few months ago, someone created a new feature branch from our trunk. In this branch he implemented a second implementation of an already implemented feature (but in a more efficient way). He changed actually only one c...
I wonder whether there is a concept for attribute dependency in object oriented terminology? It's an example showing what I mean with attribute dependency: 2DShapeclass may have an areaattribute. Then, Rectangle is a 2DShape and it has lengthand widthattributes. Now, area is dependent to lengthand width. It's a one-wa...
I have created a Project in Java which helps generate HTML's from an Excel Sheet & a template file. I am trying to understand, if I want external users to use this facility from an external service, then what should be the thought process to choose an infrastructure for setting up this service. By infrastructure I mean...
I am currently debugging a very old game (so there is no customer support) that keeps crashing under certain condition and I have found out it is because unsigned short to unsigned int conversion was done by signed conversion (possibly code similar to "short int x = 0x8000; unsigned int y = (unsigned int)x" which lead...
I am building an API where the user can ask the server to perform multiple actions in one HTTP request. The result is returned as a JSON array, with one entry per action. Each of these actions might fail or succeed independently of each other. For instance, the first action might succeed, the input to the second actio...
Code context I have a complex page as part of my web app that is dynamically populated with information using knockout.js. The page has dynamically created anchor tags that link to each other. For example, there might be a tag <a data-bind="attr: { id: 'top-' + myArray().length, href: '#bottom-' + myArray().length }">...
Imagine you want to have a room painted. You are the owner of this room and a Painter is capable of painting the room. There are different types of Painters: a BluePainter, a RedPainter etc. For every color there exists a Painter! You don't care in what color the room is going to be painted, as long as the room gets pa...