instruction
stringlengths
34
36.1k
We've got a spaghetti mess of an application that I've been tasked with rebuilding. I really want to make the new code much more flexible, and also more distributed. On a basic level the application collects data from hardware, performs some control actions, displays the data, and lets the user send settings to hardwar...
I'm new on Node.js and Express and now I'm observing that when I change the method on my calling app the params are in req.param([name]), req.body.[name] or req.query and it depends by the method. Now my questions are two: Are there some differences between these three objects? (something that could explain why a diff...
I have a JSF Page (Primefaces) with a datatable that contains entries from a Database. Thoes entries represent transactions created by users. Each time this page is loaded, I do this: Clear the table Call a service that gives me all entries Fill it again with these entries Since the Bean containing the entries could ...
Suppose that I have an object used by my code, say Person: public class Person { public string Name {get;set;} public Address Address {get; set;} } public class Address { public string AddressLine1 {get;set;} public string AddressLine2 {get;set;} public string City {get;set;} public string Stat...
Since zombie processes are processes having all resources freed but still existing in process table because their parent might ask for their return status, is it a separate state in Linux like ready, waiting etc. or is it just like normal waiting process in the table and can be scheduled also?
My company develops technology for visitor management. We currently have 2 solutions, one that is in the field, running on on-site hardware. The other is cloud, running on the cloud and processing all visitor related thing remotely. Management wants us now to build a 3rd product to retire the two previous products and ...
I'm working on a web application where the server side makes calls to a foreign server's web service API. The data passed to this API could contain sensitive data (like a user's password) as part of the header and/or in the body of the request. I want to be able to log what's in the request (URI, header, body, response...
Writing SQL like parser in .NET At this point on the first basic parse select col1, col2, col4 from documents where col1 any ('a','b','c') and col2 all ('b','c') I can identify what I call all the token type select is select col1 is column col2 is column from is from where is where col1 is column any is conditio...
I've heard here and there that arrays contain runtime data about their type, making you unable to instantiate an E[] (E being a generic type parameter, for example in a class Foo<E>), and that while you can achieve the same effect by doing (E[]) new Object[n], it is bad, which is why the compiler raises a warning. I'm ...
There are two points (x1, y1) and (x2, y2), each of which can be any real integer pair. These define a rectangle R with vertices {(x1, y1), (x2, y2), (x1, y2), (x2, y1)}. The rectangle exists in a coordinate system where (0, 0) is the top left corner of the screen, positive y is down and positive x is right. I need to ...
I'm currently working on a school project inspired by these software and device. Drums anywhere: https://www.youtube.com/watch?v=8PRBx5o15-A&t=0s Mogees: https://www.youtube.com/watch?v=vUzQQUpf4C8 I found out about the input device, and kind of get the idea on how it works. I can do a little bit of coding in python, j...
I am designing a system which fits quite nicely into a RESTful architecture. Users can navigate a resource hierarchy from a root node, each resource links to other resources, resources have URIs etc. In many ways this is very similar to 99% of the CRUD web applications out there. Where things get a bit different is tha...
I'm writing an app it needs to have generic registration step item. It needs to be able to do some specific things (I use interface for that) and it needs to be a visual element (of Xamarin. It doesn't really matter, though), say VisualElement (I use abstract class for that). This is how it all looks like: public inter...
How can you actually determine the size of fixing something which is broken in an unknown way? I tell people in my classes I only know two sizes for defect fixes: 1) Trivial because I already know what’s broken and how to fix it, or 2) Infinite because I have no idea what’s broken or how to fix it! If those are the o...
We currently have 4 environments for a project (local/dev, test, acceptance, production). We created some integration tests which want to run. The big question we now have is where to run them? Run them on all environments. The pro's for this is that we know for sure it works on all environments. The cons are that a) ...
Okay, please consider the following method. Let me first tell you that my goals of the method is to determine if file system assets exist. That's to say this is an internal company site where you'd expect the base directory to already be there on the installed server and the same with the parameter passed directory and...
I'm using comet polling in Joomla (PHP) application on shared hosting. I can't use either WebSockets or Node.js, as they might not be available on client's server. I managed to maintain only one request throughout to reduce the space it will take up in Apache. However it still makes my PC very very slow. In my friend's...
I am making a module that will output a list of objects that are missing on a list. Currently the code I have takes too long for a list of about 300,000 objects. public List<SimpleObject> GetNonExistentObjects() { List<SimpleObject> source = GetNodes();//contains 300,000 List<SimpleObject> target = GetNodes()...
I would like to understand the difference between stateful and stateless applications. What would be a non web app example of a python application which is stateless vs stateful? Would a script which scrapes the web and saves the results to disk be considered stateful and one which saves the results to a database stat...
I am currently working as functional tester. I have been assigned to do web services testing for a project. The test strategy is something like this: our company is switching vendors who provide a service by accessing data in our company's system the new vendor should be able to search for a particular data in our sys...
So I am doing this project on Rock Paper Scissors, something with 5,059 combinations, but that's besides the point. In my case, being a beginner, I was wondering if it is possible to make each option a string and then later convert those strings to integers. Or as Candied Orange was saying, would a Hash Map be more e...
I recently heard of the statistic "87% of the US population can be uniquely identified by a tuple of their zip code, birth date and gender". This is apparently not true, and I was wondering how I would verify it if I had the census data. So imagining I had a 300-millions-line-long unsorted text file containing the gend...
I have a database where some tables are Collation utf8_general_ci and some tables are Collation utf8_bin. Is this an issue that will cause unexpected behavior, or is it just a matter of performance?
I couldn't find an answer, so let's try here... I thought a bit about security and came to the conclusion, that the used hash algorithm should be as slow as possible, to slow potential attackers. (Slow means like ~1.5s). I don't want to use multiple hash function or the same just a few times again, I just want a slow o...
Consider a system with a finite number of users and a finite number of groups. To each group it corresponds a set of users. (We say that users "directly belong" to a group.) Groups of users form a directed graph without cycles. If A→B for groups A and B, then I say that B is a direct subgroup of A. The following operat...
I am building an implementation of the [Merkle-Hellman Knapsack Cryptosystem] for my study.(https://en.wikipedia.org/wiki/Merkle%E2%80%93Hellman_knapsack_cryptosystem) One of the things I would like to do, is to create a new private key. A private key in the Knapsack Cryptosystem consists mostly* of a so-called superin...
I'm trying to figure out how to support the following example scenario ill be using C# as the example language. Scenario NASA is sending Rovers and Satellites to different Planets these vehicles need a lot of logging, and to reduce clutter, would like to be able to filter these logs in the following ways: i should be a...
So i have the following data for over a month ( an app that registers all i do) Lat Long On ( DateTime ) Now i am interested in creating a history on plotting the points on Google Maps, similar to this blog post How would i do this? I thought to group the queries andadding a weight per radius every 5 minutes ( eg. wi...
This question was asked by my professor in an exam and I couldn’t find an answer on Google, so here I am. I don't understand what objects are in C at all.
I've been using Web Forms for way too long now and I want to switch to ASP .NET MVC 5 because I think that it's the "next step" for a ASP .NET developer. I also find it to generate pages a lot faster and provide better control over the HTML, but I feel like the concept is physically too big to grasp. This is my main ...
I'm about one week into studying C++ so please bear with me. So let us say that I have a function that returns a value that I need to use in another function. Is it better practice for one to assign the returned value to another variable first or is it better to simply call the function as a parameter of the other? Bot...
To be able to scale I would like to use async programming. It works really well if I have to read something from db and push to frontend, however I do not know how to use it correctly in blobs of buniess logic that live their own lives. I have object, that has lots of properties that should be lazy loaded. For instanc...
In the company I'm working for we have a certain service where users can upload documents (text, sometimes document scans), it's nothing confidential but if those documents will be leaked, I'll get a lot of headache explaining why all of them are publicly available. Recently we had a breach of out network and while thi...
I'm receiving continuously data streams of log messages. In each data stream there are some special messages representing states. Now I want to track if all states reached until the data stream ends. And if not, which state reached at last. I don't know how to implement that efficiently. I was thinking to use two lists...
I am working on a CRUD app where I have things called requests that can have many iterations. I have an endpoint to hit called iteration/create/requestId. When this page is hit I show an empty table with fields for the user to fill in. I take the index of the row and assign it to a field in the iteration called the ...
I came across one of the books related to information security where i saw these two terms, fabrication and modification of data. I can't figure out how they are different? What is the difference between fabrication and modification of data? Could anyone please explain me these, in very simple terms? Update: fabricati...
I've read quite a lot about this subject in the past and watched some interesting talks like this one from Uncle Bob's. Still, I always find pretty difficult to architect properly my desktop applications and distinguish which should be the responsibilities on the UI side and which ones on the logic side. Very brief sum...
Suppose you have a file that contains all representable integers for an architecture (so, on a 64-bit machine, it would contain all integers representable in 64-bit). However, not every integer is actually present, and the goal is to find which ones are missing. For only a single integer missing, it isn't too difficult...
Is there a universally accepted classification of error handling strategies? What is a general term to refer to those strategies, which can be used while searching for books and articles that compare error handling strategies in different languages? Some languages, such as C and Go, report errors via exit codes. Anot...
After researching how a parser generates an AST, I believe that I can know attempt to create one. Before I started on this project, I began to ponder what I should be done next after creating a AST that represented my language grammar. Despite my research into this topic, I have not surfaced any quality resources expla...
Given a map that associates labels (strings, say) to lists of ints greater than or equal to 0, I'd like to get list where the labels are ordered by the sum of their associated lists' values, descending. To take a concrete example, given: "a" -> [1, 1, 1] "b" -> [2, 3] "c" -> [9] I would like the result to be: ["c", "b...
I was reviewing the big O cheatsheet at http://bigocheatsheet.com/ and ran into some listings under sort that I do not understand. Runtimes are color coded, green being better than yellow. There are cases where Ω(N) is color coded better than Ω(N+K) and even Ω(NK). An example is bubble sort best case vs counting sort...
I have a periodic functions and I have the values of this function at discrete points. So I have: f(t_i) for some t_i, i\el(0,n) Now between these discrete points I want to lineary interpolate the function such that: f(t) = f(t(i)) + (t - t(i)) ( f(t(i+1)) - f(t(i)) )/( t(i+1)-t(i) ) for t\el(t(i),t(i+1)). The implemen...
I'm just wondering if there's any popular terminology to refer to program output that is going to be compared to some canned golden data in a unit test. I'm trying to inject this terminology into my code and so far I've come up with things like int goldIdx; int outIdx; double goldValue; double outValue; so basically g...
Lets assume we have to model the following entities: Application : Application submitted by users Application Study: the study to determine if the Application should be accepted Consultation : A consultation with an external party as part of the Application Study. Consultations with external parties could also be i...
I'm focusing my question on Windows OS, desktop applications. What would be a decent way to get a unique identification for every machine? obviously there many ways to do that, such as concatenating a hash from network card's MAC address, or hard drive serial number, or even generating my own GUI number on initial laun...
Situation We are a large team of developers, using SVN for source control on our project. One of our files, FileTracker.cvs, is very large: it contains metadata about almost every file in our repo. The format of FileTracker.cvs is that each row respresents a file, and each column represents some piece of metadata about...
I'm new to Spring MVC, hence the question may appear trivial. I have a login form which is submitted via ajax and in return I receive a ModelAndView (displaying existing list of contacts of the user) from the Controller, which I use to overwrite the existing content - the existing login form HTML upon success. My model...
If A sends an async message to B like for example, to load async images to UI from the web. Where should the response message go? Should it be slant as well or direct? And where would the activation of the sender (A) would be?
I'm looking for a way to achieve some kind of code execution validation, so for example if I have a server and a client, I want the client to execute some code (assembly) and send the server validation of this code was actually executioned fully. (and make sure no one tampered with the code running) Is this thing actu...
I have seen questions similar to mine, but there are some unusual specifics to mine not covered. I have a SQL SERVER driven ASP.NET web app (website). I am using the older webforms model, not MVC. I understand that MVC is usually a better overall model from what I know of it so far, but I'm not sure in my situation so ...
I am having a scenario wherein we have a Product Entity or a Front End Module which can be Added, Edited and Deleted. Now Product ( when added or edited) can contain a Dropdown called as Manufacturer. User can select one value out of it. I have written a Spring Controller->Service->Dao->Model type of Code to serve th...
At an operating system level, mobile operating systems support the notion of push notifications or a socket level 'persistent' communication with an app, whenever it is online. Why have the major computer operating systems (OSX, Linux, Windows) embraced this idea at an OS level as a higher level abstraction. This can ...
As a means of learning and gaining some experience with domain-driven design, I'm restructuring/refactoring an old application written in PHP which utilizes the Laravel 5.1 framework. Below is a mock-up of a simplified structure I came up with to begin my refactoring process which includes, in part, the default Larave...
Suppose we have a base class Aand derived class B. A implements a virtual method foo() which is overloaded in B. If we have an object test of type B, then the object would surely contain both implementations of foo(). When we call the method, how is the correct (most derived) method found? Would the vptr contained in t...
I am trying to develop the structure for a basic state machine that can also take in input and produce output. I've hit a bit of a mental block in trying to figure out how to model the relationship between states and transitions, where my design won't support the state machine having a cycle. Here are a couple of the ...
Suppose an object that has like 100 properties, but to create a new object only a few pieces of information are needed. We are using WCF, and I see the following options: 1) Use the same domain object for both saving and reading the data. Downside is that it may not be immediately intuitive what properties need to be p...
We are going to use our new own programming language. We have designed grammar, json parser and everything seems to work. Code in my language is transpiled into javascript and interpreted by node.js (server side part) and by chrome (client side part). Now I'm experimenting with Ace editor as IDE. It has highlight and ...
Call stack may contain several methods returning Task. If all of them are decorated with async, the flow of execution is quite simple. However, what if one of them is not awaited - are other method calls from that method executed asynchronously or not? Here's an example: If I have async Task A() { ... await B()...
I have a project which supports multiple cpu architectures and multiple compiler toolchains. Some part of the code is the same for all architectures/compilers, but the other part is architecture- and/or compiler-specific. I think this is quite a common situation. So I'm wondering, what people write in their commit mess...
I've seen two methods of declaring an array, such as the String[] args portion of the main method: public static void main(String args[]){ or public static void main(String[] args){ The textbook that I am using has wrote it the first way I described. However, I feel more comfortable writing it the second way. Is ther...
I need to implement something like mail merge using PHP. Meaning, I will have a string containing special "merge tags" that will be replaced with certain values. For example: Dear *|FIRST_NAME|* The *|FIRST_NAME|* is what I'm calling a "merge tag", by the way. Of course, this can be implement using a simple str_replac...
(I really hope this is the appropriate place for a question like this. Nevertheless, I hope some of you can give me your opinions, regardless). I am building a forum with Laravel. Progress has been great and I love how it is turning out. I have just added the ability for users to report topics and posts. (Posts are rep...
Can I have const variable in a c++ interface? Is it valid as part good design? (Not wrt syntax but as per good practices). For example, if I want a class interface "modellable" which is implemented by models and I have a variable isModel in the interface which will be set to TRUE when instantiation of model class is do...
I believe there are languages where all names with associated values cannot have their associated values changed. An example would be a language where all names behave like a does in the following C code: int main(void) { const int a = 0; a = 1; } i.e., all names act like what C calls a "read-only variable" here. ...
First, let me give some background before I actually state the question. I study physics and all my programming classes have been in easy programming languages like MATLAB. By easy I mean that the language does much of the thinking for you... For the next years I will be taking computer science courses and I am thinkin...
In order for users of my software to receive auto-updates, their copy of the software will need remote access to ~100mb of private files (manifest, jars) which means I need a server. Currently I don't have any customer so was thinking about shared hosting, but I've read in numerous Terms of Service that file storage is...
We have a few projects in my organization that are being developed in parallel and I have found that they are increasingly using similar Utility/Logging/Etc functionalities that they have as separate projects. Having heard about Git Submodules in the past, I figured that this would be the perfect time to set this up. T...
Not that it's really a problem for anyone that has faced this syntactic issue before, but I see a wild amount of confusion stemming from the use of the caret (^) as the XOR operation in lieu of the widely accepted mathematical exponentiation operation. Of course there are a lot of places where the (mis-)use of the care...
Would creating a controller's interface a bad idea? I have a controller that derived from ApiController, so knowing that you can only derived one class to a class but able to derived one or more interface to a class. public class FooController : ApiController My problem is I have code that is in another controller tha...
We are two senior students and we want to develop an app. Although we dont have experience on using git & github. Our app will consist of a server handling requests with a mongoDB database. The server will communicate with many different APIs and it will render data to a view. And now I have some very simple yet import...
So I'm working on a new project along with my project lead for the past 1 year. Initially we had our own sub-projects that resided in separate git repos, I had little interaction with his code, so the code smell didn't bother me. Some 6-months later I began to maintain and add features to his code, as I was taking a bi...
(Please excuse the level of simplicity in this question, as it is very basic) I have been working with very simple Object-Orientated Programs and learning basic concepts. For example, my programs would only have one or two objects, each being assigned to a variable. TStudent student1 = new TStudent(); TStudent student2...
I have a software application. Currently at the start of each Controller it loads in only the Models it needs for that Controller. I recently tested and found that including all the models appears to takes around a microsecond. If I always loaded all Models, it would simplify the application and make things a bit more ...
I load data from a website's pages. The problem is that the ammount of pages is unkown. Since this process takes a long time, I want to display a progress dialog. For that I have to find the last page. My idea to find the last page is: Try to load page 1000 if page 1000 exists try to load page 2000 if page 2000 ex...
I was having a discussion with a friend on the Infinite Monkey Theorem and that's when this came up. Suppose we want to generate an image of size 60 x 80 i.e. 4800 pixels and we want to use 8bpp (bits per pixel) or 1 byte for each colour (for a total of 256 colours). Now what is the algorithm to generate all possible...
I am writing a custom drop down list. I want to make it reusable (obviously), so I have a method PopulateList. I can populate list in two ways though. First, is passing a list or an array of strings to PopulateList. But I almost never want to select a string, right? Most of the time it's some complex objects. For examp...
I am trying to implement Uncle Bob's Clean Architecture in my C# WPF Application. Currently my view (form) calls the presenter and the presenter calls the interactor. Should the interactor return a value (if any) directly or invoke a presenter method. In the latter case, the presenter is attached to the interactor bef...
Here is the situation, I wish to use the last programming language of ruby, python and some more on my development machine, but the server where it will be is not last version of that programming language. Does that will create troubles?
I have times for start and stop and date of service, like this: 2000-01-01 23:00 23:20 2000-01-01 23:50 00:10 2000-01-01 00:20 00:30 The end time of the second period and the third period need to be moved to the next day, so the result would be: 2000-01-01 23:00 2000-01-01 23:20 2000-01-01 23:50 2000-01-02 0...
I have a similar scenario to this: public class VatCalculator { public decimal GetValueWithVat(decimal value, decimal? vatRatePercentage) { if(vatRate == null) { return value; } return value * (1 + (vatRate / 100)); } } public ReceiptGenerator { private rea...
I'm fairly new to C# and .NET as a whole and I want to create an application, I have strong experience in Java, Hibernate and using MVC frameworks like Spring. I want to create an application that will have the following purpose: Be accessible by people that can login to it (active directory) Store data that is releva...
I am working on a Spring-MVC application in which we are using Maven for dependency management. As the project is big, we are thinking of splitting the project into several parts. I had some doubts, which I hopefully will get answers here. Currently, we are deploying a single WAR file as ROOT.war on Apache tomcat on o...
In GoF there is a two way adapter concept: A potential problem with adapters is that they aren't transparent to all clients. An adapted object no longer conforms to the Adaptee interface, so it can't be used as is wherever an Adaptee object can. Two-way adapters can provide such transparency. Specifically, they...
I have a large integer N < 10^2500. I need to get the number of bits set in its binary representation. The number is given in base 10 in a file. Here's how I'm doing it right now : I made a class called BigNumber which uses an array to store very big integers. I am parsing the number into a BigNumber object in base 1...
I want to model a use case to show that if a PersonalTrainer object is linked to 20 Client objects, it cannot be linked to any more. However, drawing 20 boxes and 20 association lines looks cumbersome and messy, what is the correct way to represent this use case in UML?
I'd like to ask why people devote their time to research algorithms and their efficiency so extensively when computers nowadays are so fast. Trying to come up with an answer I thought that maybe my assumption is short-sighted, because computers are indeed fast nowadays, but there wouldn't be so fast if we haven't rese...
As follow-up to this question I started digging in the UML specs regarding control flow in activity diagrams. Consider this simple example: Notice that it neither has ActivityInitial nor ActivityFinal. I know (though I actually can't find the location) that the specs state that a flow is terminated when it has no outg...
This is a question on how to model database entities and relationships when it comes to storing persistent data and dealing with differently-handled types of products. Use Case Company sells various many Products that are made inside the company, and various many Motors, which are not made at the company and are treate...
By definition, dynamic typing and dynamic scoping have different purposes. But some cases make me wonder if they can lead to each other sometimes. Dynamic typing allows a name i.e. identifier to refer to objects of different types at different points at run time, e.g. x = 1 x = 'abc' When dynamic typing changes the t...
As we all know, security is very important when making any kind of application. That's why I came up with this idea, or rather I already made it happen. Thing is I am not sure whether it is really securing my applications, or is it just extra weight. To keep it simple: I made a simple function that enables "admins/owne...
I've decided to take upon myself the task of learning functional programming. So far it's been a blast, and I've 'seen the light' as it were. Unfortunately, I don't actually know any functional programmer that I can bounce questions off of. Introducing Stack Exchange. I'm taking a web/software development course, but m...
I want to know if it possible to use arrays for a more viable alternative of getting a non-predetermined number of inputs as an array and with an indefinite number of inputs. (python) original code --> if inputs == 1: print("more than 1") elif inputs == 2: a1 = int(input("type integer\n")) a2 = int(input("t...
Given this function let readInput() = Seq.initInfinite (fun _ -> Console.ReadLine()) |> Seq.takeWhile (fun s -> s <> null) ` |> Seq.map int` is the _ in the function called by Seq.initInfinite a wild card, so that anything can be read off STDIN? I've got a couple of different F# books, and am looking on the Inter...
A bit of background information: I'd been a Java developer for a company for about 6 years. This company used a variety of Linux-based operating systems for its day-to-day operations; all of our servers and development machines were some variant of Linux. When we were developing new web-services and wanted to discuss u...
I'm creating a library in C# which will be used to query databases. In order to use this library, a user first needs to tell the library what the database schema contains, by creating Schema, Table, and Column objects. A Schema object consists of: A name, which is a string. A collection of Table objects that it owns. ...
I'm trying to devise a way to create a 'loot table' for an RPG, mostly to see if it can be done. I'm partly inspired by old D&D style tables, which would list a range of values for each item on the table (i.e. 0-20 weather is clear, 21-50 weather is raining, 51-99 weather is cloudy) and you would roll a dice to see whe...
If I need to use only HashMap, why do I need to override equals() method along with hashCode()? How will not implementing equals() affect the working of HashMap?
I'm developing a node/edges graph using the d3 JavaScript library (the language isn't that important—this is a conceptual/approach question). My graph has the ability for nodes to be dynamically filtered on the basis of various criteria, including type and specific attributes. As an example, let's assume I have the fol...
I'm looking for the correct design pattern to decouple some of the logic on some abstract classes I've got. First we have a base class Fruit and child classes apple, orange, and mango. Then I have some classes that perform some logic on the fruit. These classes are the chopping, cooking, and peeling classes. Now much ...