instruction
stringlengths
34
36.1k
Right now I have a webpage with various buttons and options that I'd like to use to send commands to a python script running on the webserver. The python script is being used to interface with devices over a serial connection as well as performing computations with the data received from both the webpage and the serial...
Does UI interface is just an Image created by graphics tools?. I need to know that when a user interface created to read an textbox in c#. When a text entered is it take values from keyboard by Readline.console method and displays on screen terminal or it display first to screen and reads from screen coordinates. Got ...
I'm making a piece of rendering software and I want to make the tools it encompasses extensible. I've built a UI that lets the user write custom C# functions for blending values. The functions (and accompanying values/constants) are added to a class and compiled using CodeDom, and the blend function is used from there....
When creating a table with similar bits or data such as names. Is it preferred to have the column name prefixed with a common value? Consider a table to store user information. Looking at the columns related to the users name they may be structured as follows: title first_name middle_name last_name Would it not be bet...
I have an architecture/performance problem. The problem: One voting based application with: 1 loadbalancer, 2 webservers and a database 10 candidates and 200k voting users. There may be more than 100 users voting at the same time. The database can only hold 1 write concurrently and does not support transactions. If t...
I am writing a wrapper function for database calls, and I am confused about the best way to handle the error cases. The function has only one argument, the id of the object to be deleted. I've handled two error cases : 1)If the object is not found i return false. 2)If the object is found but delete fails due to...
Given the following code in the DoWork() event of a BackgroundWorker object, how can the concept be converted to the Async/Await model? I wish to execute multiple downloads simultaneously in order to maximize bandwidth. I also will need to retain the ability to increment a progress bar on the dialog. Dim oChunks As Sor...
Having read about the 4+1 Kruchten, I am required to document a system architecture using this concept. Instead of the notations proposed by Philippe Kruchten, we decided to go with UML instead. I am particularly interested in the process view, as I don't understand how to map this to my processes. I know I can use seq...
I have a Python script that continuously makes GET and POST requests to a third-party API at about 1 request per second. It uses a while loop, so the requests all come from the same process. Currently, I just run and kill the script on my local machine with python run.py, but I'd like to be able to start and stop this ...
I have the following class that doesn't implement IEnumerable but is working perfectly with foreach. And also, arrays are working without implementing IEnumerable. So why does it keep saying that IEnumerable needs to be implemented in collections to use with foreach. I'm confused, please assist me. class Parent { ...
I need to create an immutable object but it requires several parameters to work like: class FooRepo { public string ConnectionStringName { get; } public string SchemaName { get; } public string TableName { get; } public Dictionary<string, int> ColumnLengths { get; } public Dictionary<Type, SqlDbType...
In my classes of parallel programming the teacher mentioned three models, dynamic thread creation (create threads according to demand), thread pool (create a fixed amount of threads) and mixed or hybrid (create a number of threads at first, but you can create more if the demand increases too much and then return to the...
I am trying to solve this exercise. It is about reimplementing the map function in haskell for learning purpose. I found a solution which doesn't browse all the elements of the list (simple linked list, so accessing the last element will browse all the list) at each iteration, but I didn't found one which is tail recur...
I have a question that is crucial for my end of year project. Background My web application allows users to build other webapps based on drag&drop (within the domain of the webapp). These web applications can contain regular elements, but also functional widgets in the form of ReactJS components that can even talk t...
Context I recently wrote a final exam that required using a BindingSource object with ADO.NET to populate a number of combo box and label controls from which the user could perform basic business functions. I got it working but had some reservations about my design choice. The setup When a user selected a product from ...
I'm writing a game in Java where each game object has a number of properties, but these can all be changed in one of two ways: Every second, a tick runs which may automatically cause a change. Users can send a request to the server and make a modification themselves. Should I lock the Object while the tick is running...
I want to show that in my new system, plugins are used to control the core software components. What would be a good way to show that in UML? I will definitely use sequence diagrams to show interactions between the core and the plugins, but is there some sort of static diagram that fits?
I recently (1 month) start working in a project and as I was going through the code I saw an using Microsoft.Practices.ServiceLocation and as I searched for the documentation on that library is says: This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still ...
I was playing around with variables in Java. public class Hello { public static void main(String[] args) { byte byteV = 127; short shortV = Short.MAX_VALUE; int intV = Integer.MAX_VALUE; System.out.println("Short: " + shortV + ", Integer: " + intV); long longV = (10 * byteV) ...
An increasingly popular definition of factory method is: a static method of a class that returns an object of that class' type. But unlike a constructor, the actual object it returns might be an instance of a subclass. From : https://sourcemaking.com/design_patterns/factory_method Doesn't it violate OCP? I h...
This is part of the code of a calculator that works on command line. It works fine and the math is correct but it's a little redundant: switch(Operator) { case "+": result = num1 + num2; printResult(); break; case "-" : result = num1 - num2; printResult(); break; case "*": result = num1 * num2; pri...
I'm thinking about whats the correct pattern to handle this case in CQRS / Event Sourcing: I created events to calculate a balance and system goes into production. By accident, this implementation has a bug and calculation of balance is wrong. Should I fix the implementation and rewrite the events in the event store as...
I am struggling with applying the "programming to an interface" guideline because I can't seem to decide in which situations it is necessary and in which ones it's overkill (or even counter productive). I would like to know of any heuristics or rules that you use in your projects to decide if you need to create a new ...
I'm working with scrum methodology. thus weekly schema updates are performed to the final product. However our customer is already populating the database. How can I update the database without dropping the tables? How can I deal with these schema updates? I am using DB First approach. this way I don't have Code First ...
"Singleton" is widely considered anti-pattern ("bad" in everyday language). What about this alternative modified singleton pattern? An object constructor for our class ensures that at any given point of time there is at most one instance of the object (yes, this uses a global boolean variable). If the user attempts to ...
In my current project, I have a screen which pulls data from several webservices, pulls data from database via backend API and checks that all resources have the same data or not. The other webservices are partial mirrors of the data in the db and the screen shows a table with the state of the data(if everything is the...
I am confused over Virtual Inheritance and disinheritance ? Is both are same ?
Are there any viable approaches to dealing with data coming from devices with unreliable clocks? We have a database system running on a central server. The latest addition to the system is a bunch of mobile barcode scanners running Android. We are creating a specific app and the devices will be completely locked down s...
Is this design bad? Does it break encapsulation? The structure class B is a component of class A. Therefore, class A needs access to class B's members. Let a house be class A. Let a housekeeper be a component of class A. Let a room be class B. A room, and therefore class B, is a component of class A. A housekeeper nee...
I have a question about how to structure a response where I return objects related to other objects (one-to-many/many-to-one), and to tell me if the way I've structured my endpoints are wrong or not, or if there is a better way. My scenario: I have an JS app built on Flux where I have these stores: - Meetings - Users F...
Assume that the parameters of functions representing operations of the relational algebra are represented by individual types: structs or classes. An operation such as (natural) join will have parameters of two types (T1, T2) as inputs and produce a return value of a third type (T3). There is a relationship between typ...
In a Winforms project I've been working on recently, I've been dutifully using using-statements for objects that implement IDisposable. I want to reopen a database connection, however because the using-statement that it was in earlier disposed the connection, I can't reopen it. So this leads me to the question, is it b...
I'm looking to implement dependency injection in a relatively large application but have no experience in it. I studied the concept and a few implementations of IoC and dependency injectors available, like Unity and Ninject. However, there is one thing which is eluding me. How should I organize instance creation in my ...
I want be to be able to re-write the code of an existing PHP function in an abstract manner. Here is an example: scandir() scans a directory for files and folders, and returns the relative paths '.' and '..' . While I could just create a new function to run scandir() and remove these entries, I want to try and re-write...
I'm just about to set up CI for my web application. I'm using Bitbucket and Pipeline beta as a CI. The web application is strongly coupled to the database, nothing can be tested without data in it. My team also has some issues with the local devenv, as due to frequent DB schema changes, Django migrations are irreversi...
The PHP codebase I'm working on has an utility class that returns a database connection. The implementation looks like this: class Database { private static $conn; private static $init = false; public static function connect() { if (!self::$init) { $cnf = new Configuration(); self::$conn = new Da...
I have the following app scenario where i would need to implement the cell-level encryption. Database - MS SQL Server Web Technology - ASP.net MVC Existing app scenario:- Currently the web application is serving multiple clients and the app is attached to multiple db's such as ClientX, ClientY, ClientZ etc. All thes...
I tried to repeat this results: 27^5 + 84^5 + 110^5 + 133^5 = 144^5 (Lander & Parkin, 1966) and 95800^4 + 217519^4 + 414560^4 = 422481^4 (Roger Frye, 1988, 110 hours this is the only counterexample for values below one million) The first counterexample can be found by a direct search in several seconds. The second cas...
I'm trying to create a nodeJS application. It allows users to rate a bunch of songs and it stores them in their user profiles. I use this information to compare them to other users, and try to find users with similar interests in songs, and I suggest them new songs based on that. Each user profile basically looks like ...
Imagine that I've got a piece of custom audio hardware that I'd like to be able to control in a multitude of ways via a tablet/touchscreen GUI. In particular, my goals are to have the tablet's control GUI be "pretty" (i.e. nicely animated and modern looking, as one would expect from an iPad), have it be cross-platform...
For a GameJam I'm trying to code a simple web-based text adventure game with sprites and small animations in AngularJS. I'm a little new to Angular and am having some trouble figuring out how to structure it. I think my trouble comes from my struggle with Controllers vs Directives. My game essentially needs to pull tex...
I would like to provide design decisions in the comments as well. I want design decision comments to be distinguishable from function contract comments, on cursory examination of source code. How to go about it?
So I would like to be able to call a function like this: void func(1, 2, 3, (void*)label) // can return normal or to the labels //some code label: //different code Is it possible, and is it bad practice?
I have a register page that uses text inputs as well as an avatar input. There's another part in the website where the avatar input is also used, but it's used alone this time. So I'd like to make it reusable and since it's coupled to a part of a view, I want to use a controller for this. Simplified, here's how it look...
When writing an unmanaged Win32 DLL that exports functions, it's not uncommon to have some functions, variables and/or classes that aren't meant to be exported and are only for internal use within the DLL. Since we were targetting applications written in both .NET and Visual FoxPro at the time, using a .def file inste...
I have a C++ program that read game data from memory process. For example, int points = 0; while (1) { points = ReadProcessMemory(..) // points will be read from game's memory Sleep(100) // Don't read too often } I want to sync the data so that it display this point (not necessarily real time but fast enough) ...
I recently started at a company as a Automation Developer. My job is to automate periodic reports (in Word) for all of our customers (~50), one for each. Each report is slightly different, so I am going to have develop code for each company. The position is new and there are no automation in place; all reports are com...
I downloaded one of the projects using vc++ and using visual studio 2008. The problem is some of the files are in .lib format, to understand the project completely i want to know the contents of this lib files. Is it possible to extract this .lib files into C files (I am assuming they are written in C).
I'm trying to convert a set of SOAP-based services to a RESTful API. I started by identifying resources by analyzing operation names and I got the resource Subscription. When I need to update the state of the subscription, I cannot simply send a POST request to the server, because I don't have direct access to the res...
I have some network device(IOT) that contain temperature sensors to collect the temperature of milk mixing tanks and send that temperature to another networked computer.I have more than 100000 of tanks to collect data.Data collecting interval is 5 seconds.It's requirement and cant change the 5 second interval. Then an...
I read on http://spark.apache.org/ that Spark supports cyclic data flow. How can data flow be cyclic if the RDDs used by Spark are immutable? I thought the processing done by Spark looks like an acyclic graph where the nodes are RDDs and the edges are transformations.
I know MP3 is not open source format but proprietary and I found this website http://mp3licensing.com/help/developers.html that states that you need a license for basically everything that uses MP3. But the thing is that even hardware devices that support MP3s need license. So if a mobile phone is able to play MP3s al...
I'm starting the modeling of the following problem: I have many clients (millions) that interact in a network forming a graph. At the highest granularity of my business problem, each realationship has 3 attributes. In the "realistic" worst case scenario, the nodes compose a unique mesh, having relationships with ~100 o...
I'm not so sure whether this questions fits here, but I need help in this case, cause I'm searching for days to apply this. I have a website of rugs and carpets, in this website I would like customers to be able to change the rug colour by clicking on some part of a rug and change the colour using colour-picker. For ex...
I am looking to formalise an algorithm that I have created, however, I am having trouble knowing how to correctly use Greek symbols (such as Epsilon, Omega etc.). Are there any guides/standardised way of doing this? This is an example of an algorithm that was previously worked on that a college formalised. Does a "glo...
I am using mercurial on my project. Now I face following problem: I have two separate mercurial repositories with their own history. Now I need to have identical branches/bookmarks for both of them. But this leads to lots of potential problems: somebody merged first repo and forgot do same for second created a bookma...
In one of youtubes videos about scalling web sites I found the statement that, however, in term of scallability, noSql is easier and more flexible, though it is better to use SQL for data important enough to not want them be lost (not necessarly secure). Why is so? What mechanism make SQL safer in such term? I'm very V...
I have question based on the following fragments of "Clean Code". Those have been cited before, but I wanted to ask more basic question. 1. Data/Object Anti-Symmetry (...) the difference between objects and data structures. Objects hide their data behind abstractions and expose functions that operate on that data...
I have a stream parsing method in C# that reads portions of a protocol frame from the STOMP protocol; the specification isn't the important part for the question though. What is important is that I have written the code in an imperative style, since that is what I know. Can anyone give some examples of processing in a...
I'm writing the Fortran bindings for a static library written in C++. This will be distributed with the library (both open source). The bindings consist of modules containing interface blocks and no executable code. The question is: Should the modules be compiled with the library (possibly at the user's request through...
This is probably a common question and I've been reading a lot about this, but I can't look into a solution. Let's say I have an enterprise application in one glassfish server located in New York. Then, my application grows very fast and I need another server with a loadbalancer. Now my application is running in two d...
OK so a lot of code review is fairly routine. But occasionally there are changes that broadly impact existing complex, fragile code. In this situation, the amount of time it would take to verify the safety of the changes, absence of regression, etc. is excessive. Perhaps even exceeding the time it took to do the develo...
Is it good practice to code entire business form as single component (control) and then proudly put it on window/form as the final step in development? Of course, this form can involve some other custom components/controls, e.g. business applications can use custom controls for selecting partners, stores, goods, becaus...
I’m implementing glossary/dictionary in Javascript. It is populated with a set of terms and their definitions internally, then gets handed jQuery elements and searches the HTML, replacing any of the terms it finds with a link to their definition. The current implementation runs by forEaching the dictionary over the H...
C# has made a language feature of the NotImplementedException. It's added to a lot of auto-generated code, such as event handler stubs: // Auto-generated private void TextBox_MouseDown(object sender, MouseEventArgs e) { throw new NotImplementedException(); } What makes this exception useful? a good language featu...
Suppose you have top level Dependency A. Dependency A is licensed under MIT. Dependency A packages Dependency B as part of its distribution. Dependency B is licensed under GPL. In order to use Dependency A, do you need to agree to the terms of both MIT as well as GPL, or just MIT.
Generally what kind of algorithm is used to solve when dealing with overlapping data sets . In the below problem set, we can see that region (point 2 to point 3) is common to both statement A and statement B. Problem Set Statement A : Point 1 to 3 --> Speed is 30kmph Statement B : Point 2 to 5 --> Speed is 50kmph Goal...
I'm so confused about how Void operator (in javascript) works and what is it's role. as i read, Void is an operator that evaluate an expression without returning a value, but by executing that script for example: <html> <head> </head> <body> <a href="javascript:void(alert(1+1))">Click me!</a> </body> </html> ...
I am having a concept problem at this point & I can't find any info about the differences between Test (UnitTest, etc) vs Spec (Rspec, etc). As far as I know, specs is into Integration tests and test is into UnitTest but just that. Can you explain what the differences are?
Say you've just started working in a very small team on a {currently relatively small, though hopefully bigger later} project. Note that this is an actual project intended to be used by other developers in the real world, not some academic project that is meant to be scrapped at the end of a semester. However, the code...
I'm unit testing a class which has two dependencies, both of which are external packages (I'm using C# so these are NuGet packages, AutoMapper and CompareNETObjects). (NOTE: Both are just utilities, related to converting an object from one type to another, and to comparing objects. Neither makes any external calls) ...
I have a Windows Form for creating configs. It has around 50 fields of data, which represent a group of entities, that I need to capture when the user presses the save button. Currently, on the press of the save button I build the group of Entities by creating each entity, extracting the information from the controls a...
I have one ArrayList in Java and a save the socket and one unique id. When someone client is add in the ArrayList, the unique id i have is NOT the same with position in ArrayList. When someone client is gone i remove the client from ArrayList put i need to find the unique id. My problem: Is when i want to send informa...
Is concurrency and idempotency mutually exclusive for a REST web service or can it be done so a service can be both concurrent and idempotent? Using a optimistic lock methodology like using Version property seem to be preventing a method to be idempotent if I'm not mistaken? For example, let's say you have User A wanti...
In my last company, on handling view commands, in the ViewModelBase there were one central command implemented, like public ICommand ToolCommand { get; set; } And in the ViewModelBase, it's been initialized, and all buttons hooked to this Command were differentiated by its Command Parameter: public ViewModelBase() { ...
I made a simple responsive single page web app (about 5 views) to replace our old jsf web application using angularjs+bootstrap. Now looking into frameworks like ionic, cordova and trigger.io. what I don't understand is, am I supposed to directly reuse my responsive web app code in, say, ionic framework? I know there a...
Martin Fowler describes the Flag Argument code smell as a "kind of function argument that tells the function to carry out a different operation depending on its value". Answers to Is it wrong to use a boolean argument to determine behavior? seem to conflate all boolean arguments with flag arguments. I think that quest...
I come from java, when I got an expected error I printed stack traces. I'm coming now to work on nodejs (never really worked on javascript). and in the nodejs project which I need to maintain (project was already coded by other javascript developers) I see error logging following: logger.error('some message ' + e.mes...
This may be more of a software design question - but I've been working on my first "real, non-academic" Java project and have recently learned about good code practices (such as breaking down methods into respective classes, so that my controller class doesn't necessarily have 50+ methods all together) - and it's led m...
tl;dr: "Am I, with any given location, inside of any number of circles with varying radii" Assume you have a database full of locations (coordinates) with arbitrary radii. Now the user enters and provides the backend with their current location. How would the backend efficiently figure out which locations to return? ...
I am relatively new in terms of Java web development skills. I have a project that I think would make a good candidate for a RESTful service from what little I understand about APIs. I'm trying to get into the details of how this is supposed to be structured, but not really getting anywhere in terms of google searches ...
My college professor told me that main functions should be defined on top of other function definitions. We should use a forward declaration in order to accomplish this (we use C at that time). So yes, my question is why should main() be on top of other function definitions? Does this apply to all programming languages...
I am looking at A SAT-based Public Key Cryptography Scheme and got inspired to challenge myself to write an implementation of this Cryptography Scheme on Python. A part of the cipher encoding would be to generate random Boolean functions in Algebraic Normal Form in a certain set of binary variables. I am new to codin...
Modern PHP is mostly written Object Oriented. Other than the fact that there is inertia towards the Object Oriented in the PHP community, is there anything about the language itself that would make it a poor idea to use functional programming?
I'm looking at the alternative that can substitute the use of eval() and new Function() javascript techniques. I'm developing a solution build with javascript and the platform on which it is built (Salesforce) recently has announced they're introducing CSP (content security policy) that will block the use of eval(), an...
I am working on the frontend of a product, and it is now broken due to bad data from the backend. This can be caught internally before it gets anywhere close to production, but we end up fiddling with our fingers as the backend is being fixed. (Hence why I'm here...) I have some hackish fix that does a sanity check, in...
The very popular IntelliJ IDEA‎ has currently saved a lot of dependencies as actual jar files in their git repository e.g.JUnit, which I don't understand. Build tools like Maven provide excellent dependency management abilities. Of course Maven dictates a lot of how the build has to happen (source), but imho that is a...
How do I create a dictionary of synonyms that is efficient in terms of retrieving synonyms of a word? Basically, I want to use some sorts of data storage to store groups of words, and enable an end-user to request any word and be prompted with all the other words in its group (its synonyms). Afterwards, I want to be ab...
So I have been working on a C# Matrix library. I've been documenting it really good so far. The thing is I don't know if I should document my overloaded operators, I mean, it is kind of obvious, isn't it? Sample code: public static Matriz operator *(Matriz A, Matriz B) { if (A.map.GetLength(1) != B.map.GetLength(0...
A method getReminder takes two integers and returns r = (a^5)%m. This method relies in two BigInteger numbers BigInteger.valueOf(a).pow(5) and BigInteger.valueOf(m), but BigInteger was never declared. At the same time, int was declared twice even though just one int is enough. I realize that int doesn't cost much spac...
How do I name API endpoints that serve the same entity in different ways and still adhere to the RESTful API guidelines? Let's consider I'd like to get a customer with ALL his details. I just expose a GET endpoint at address "/customer". Now I'd like to check if a customer with a particular customerId exists. What d...
This problem came up while designing the API for a SPA web application, which communicates with the server via AJAX. On one page the user, who is creating a list of people to invite to an event, has the option to add people who were invited to previous events. Imagine a dropdown containing the names of the previous ev...
In other words, is it possible to create a PCRE "regular" expression which takes Ackermann(m,m) time for an m length string?
We have multiple tables which we need to retrieve data from and dump to one centralized table. Currently what we are doing is running an ETL job made from Pentaho, retrieve the records from the source tables, and dump it in the destination table, this runs every 5 mins. But now, we are required eliminate or at least le...
I've got a Java Script object like this: let obj = { selected; true, level1: { level2: { selected: true } } level1: { selected: true, level2:{} } }; I want to remove all instances of 'selected: true'. How can I do this? I need to solution to be generic be...
abstract class Product { public abstract Product createProduct(); ... } class OneProduct extends Product { ... static { ProductFactory.instance().registerProduct("ID1", new OneProduct()); } public OneProduct createProduct() { return new OneProduct(); } ... } class ProductFactory { p...
I am currently using MVP pattern to develop an android application. I have to implement pagination (i.e. on scrolling at the bottom of the RecyclerView I need to fetch new data). So what is the best way to handle current page state in this scenario?
We are a few developers develoing an enterprise project includes several modules and approximately 200 UI resources for our company. Project will be written/programmed in Asp.NET MVC, WCF services for each module, and layered structure adhering to design pattern pirinciples and within the scope of an enterprise applica...
So me and my friend came up with a rather interesting (maybe?) algorithm question but ironically, we are having a hard time solving it. The question goes like this: There is a sale of precious stones going on in a city of the Rich. Each stone on sale has one or more variants of it. For example, a diamond can be round, ...
We have a REST Webservice build with Symfony3 and PHP7. The application is served via Nginx and PHP-FPM. The Webservice returns a list of products. Products inside the list are filtered by attributes. The result would be the list with a subset of its products, filtered by attributes. Those attributes are send via GET p...