instruction
stringlengths
34
36.1k
I have some very slow integration tests that use Selenium and require a lot of database setup. The setup and tear down times are in the order of tens of seconds while the test bodies only take a few seconds each. Since there are hundreds of these tests, this adds up to a lot. My previous place has an elaborated resourc...
I put together my first line-of-business app using WPF/MVVM/EF6(db-first)/MSSQL and realised that multiple users could not see each others' changes because I was using one dbcontext and keeping it open.I've read loads of articles about dbcontext and whether to dis/connect and whether to eager/lazy load and they all say...
For a while now, I have been automating tasks by writing shell scripts in bash. These have gradually become more and more complicated, and I am now finding that bash scripts are a little too simple for what I want - for example, I recently wrote a 1000-line program that includes multithreading, IPC, a CGI interface, an...
Today I had a task to "write a health check" for a long running service that is an orchestration system to deploy a web-app. I am trying to determine what the scope for such a health check would be, and came up with these questions related to the scope of the health check : Is it good enough to consider the service ...
When I'm working on a feature branch, I tend to want to cleanup the commits in the branch using an interactive rebase before my work is reviewed and integrated in the main branch. During development of the feature, I want to push my intermediate work to the remote repository as a backup measure. I.e. when my hard-drive...
I tried asking this question first on StakOverflow in a more concrete manner, but after being pointed here I realized I should rephrase it in more general terms; however, you can still review the original question, if you want more concrete detail about my specific use case. Assume a relatively complex reporting interf...
I'm trying to figure out a way to handle default variable values when making functions without side effects and have ended up with the following: function getDefaultSeparator() { return ':'; } function process(input, separator) { var separator = separator || getDefaultSeparator(); // Use separator in som...
We are using Visual Studio Team Services to host our code in a Git repository and to manage our Agile planning through iterations (sprints), user stories in a backlog, a taskboard for the current sprint, etc. This works really well for planning and executing the current sprint and for reviewing the previous one, but I ...
I'm finding it hard to divide work in a group of programmers when a project starts out. It seems like every project has one big piece of core functionality that everything else depends upon. I find that I tend to make decisions on how this core is going to work as I write it. So I see two ways you could do this:: Have...
I have a currently-existing stock management dashboard. The user selects a warehouse, and it displays the current stock in this warehouse. The stock management teams wants to display a date, calculated with various parameters. The problem is that there are several warehouses, and since they work differently, they want ...
I have built a setup which solves my problem, but I've pretty much just hacked it together by reading AWS docs and trying things out, so I want to see if there is a better way. For the purpose of this discussion let us define a "task" to be a set of processes which 1) gathers data, 2) processes the data, and 3) stores ...
Background I currently have a situation where I have an object that is both transmitted and received by a device. This message has several constructs, as follows: public void ReverseData() public void ScheduleTransmission() The ScheduleTransmission method needs to call the ReverseData method whenever it is called. How...
We are using SonarQube for code quality testing. It tests the quality of code, and not the function of code. It has the concept of quality gates, so you can set for instance a 90% quality gate, meaning that anything over 90% quality is considered a pass. Some folks here like this idea and have decided to apply it to fu...
So I was reading over this question Should I remove unreferenced code? Some of the advice was to delete unreferenced code since the code is in source control for reference in case it is needed later. How do you organize this deleted code so that a later version of you (or some other programmer) can find it later? D...
Suppose I wanted to test that both my inputs are positive. Can I do something like this? test :: Float -> Float -> Maybe Float Float test a b | a>0 && b>0 = a b | otherwise = Nothing I thought I would have this function test that the inputs for the next function were positive. So two floats go in and two com...
I'm currently working on a fund project and I have it set up so I get the holdings from my database and store in in to a DataTable to process. I've created a function where my Database results are returned as a DataTable var dtAll = db.GetTable(query) Since a group of accounts have the same holding ie: MSFT, AAPL yo...
From this question on SO, I read that: Proprietary Source code + LGPL Source code statically linked: Either you must release both parts as LGPL. Or provide everything that allow the user to relink the application with a different version of the LGPL source code. In this case the other requirements are the same as if...
So I know that matrices are used extensively in the field of games and 3D graphics, for example, you need to know how to do matrix multiplication if you want to understand how scaling an object works, or you would need to know how to do matrix addition if you want to translate an object. In short, all pretty simple stu...
I am making a web application using the javascript framework Meteor, which runs with mongodb. In the web app I have a db set up that holds individual video games in the documents. An example of this would be the video game Fallout 4. The document would contain the title of the game, the genre, and what consoles it ru...
I need to know whether Static code analysis and code Quality are same or not because, I need to find out the tools for code quality and each time I google for it, I'm getting response for the tools related to Static Code Analysis.
I'm not sure what to title this question or if this is the right place to ask it. After Googling and continually coming up empty, I'm turning here as a last resort. I've developed a SAAS web application that generates complex reports for our clients. The reports are generated by pulling data from our client's SQL Servi...
We have an word game commercial mobile application for which we want to use dictionaries for various languages. Most of them have GPLv3 or CC-NC3 licenses. We modify the dictionaries: basically, we filter out some unallowed words and convert them from TXT to DAWG. The resulting files are not distributed along with the ...
I'm receiving objects in JSON, and currently the app only uses a small amount of the properties I receive. I'm wondering which of the following is best practice, or simply generally advised. Would it be better for the server to actually send partial objects (smaller data)? That way, I wouldn't have to worry about mapp...
My IDE (NetBeans) type checks my Collections while I am typing code. But then, why do I have to cast the returned object of Object.clone()? Which is fine. No harm no foul. But still, I don't understand. Is type checking, without casting, the returned object of Object.clone() not possible? The generics framework makes m...
I am working on a report system which aggregate a lot of data from multiple sources (databases and internal APIs). Among other things I communicated with another departaments and told them I need some aggregated data from their database, so they just gave me pretty huge SQL query (about 100 lines, 15 joins etc) which w...
I have recently started my own small development company and was looking at developing a framework to sell to clients. I discovered that there were many open source solutions already developed, licensed under the GNU Affero General Public License (AGPL). I would like to know if I could use one of these and customize it...
I've always noticed this, but never actually understood what's happening here. I have a fairly simple object that I've put in a console.log. It has a seemingly never ending pattern of prototype -> constructor -> prototype -> etc. What exactly is it's purpose?
Although most time-boxed meetings take the amount of weeks in a sprint into consideration, none of them seems to include the number of team members when calculating the max duration. What I mean by time-boxed meetings: Sprint Planning, Sprint Review, Daily Scrum, ... - not the sprint itself. Let's compare a team of 3 t...
Twice now I have encountered an office where there are many projects being done simultaneously. The two different approaches I've seen to this is splitting people up into very small (1-2 people) dedicated teams and the opposite where everyone works on many projects (perhaps 1-3 projects) and split the time they work on...
I'm trying to get involved in an open source project and I am feeling a little lost for several reasons: I've been reading the project's mailing list, but its a fairly large and complicated project with many contributors and I'm having a difficult time keeping up with everything that is going on. I've been lurking in ...
I'm building a web app that hits up some APIs to get JSON dumps of data. I'm running across a problem. I can either grab all the data, dump it into a DB, then pull it from the DB as needed. OR I can just keep hitting the relevant API every time I need the data. (I have upwards of 7 different functions, each of which re...
I'm writing some serialization code, and I'm wondering how to deal with binary data. As I'm doing it in Python, my goal is to make it very simple, not require a lot of programmer overhead, etc. Three options I am considering: The fields that will be binary data are represented as hex-encoded strings. Thus you'd have s...
The keep things as simple I will use very basic example. The problem is to aggregate 4 numbers to have 10. One developer uses below code/algorithm (Case 0) in his program file and license it as proprietary. var firstNumber = 1; var secondNumber = 3; var thirdNumber = 3; var fourthNumber = 3; var sum = firstNumber + sec...
I have a philosophical disagreement with one of my co-workers, and I'm trying to get back to basics here. What is the purpose of a method? In this question, consider this example. I was criticized for writing the following two methods. I would like to give the caveat that this is a boiled down baby-example, that there...
Background I'm working on a project that requires me to keep track of transactions as well as the flow of items in a game. In order to do that, I'm storing those transaction in a graph db (Orient-DB). A Shop in the game can have zero or more basekts each of which can hold one type of item. So when a Player sells someth...
Moving a windows desktop game to a web server based one. User will use a modern web browser and communicate with the server via WebSockets (SignalR). Server runs .Net4.5/MVC - ie stateless. Game itself allows one to many users to connect and constantly runs in a separate process from the IIS host (supposedly better any...
I am trying to build a class where user can compute floating operations with a particular accuracy. For example, if the user wants to have up to 4 digit accuracy, everything less than 0.0001 is zero and everything bigger than 9999 is inf. I think the best way is to create a bit (or maybe byte) array to store sign, mant...
I am making a time-sheet portion of a website and I was wondering if using to create the time-sheet portion is an appropriate usage of table or would div be a better use?
I have a ASP .NET WebApi and a Web Project. I'm about to create a DAL class library... Which will be my codefirst/POCO's or possibly edmx files. I'm wondering do I need to have another class library for DTOs of ViewModels?... I'll need to map db entities to some sort of ViewModel that will probably be needed by both t...
I have a commercial software project that uses a third party lib (org.quartzscheduler), this has an Apache 2.0 license. I thought I was ok but when I checked the transitive dependencies I found that Quartz uses the c3p0 library which is distributed under the LGPL. My understanding is that the LGPL is a fairly "weak" co...
public class example { private String one; private String two; public example(String one, String two) { this.one = one; this.two = two; } public static void main(String[] args) { System.out.println(returning()); } public static example returning() { ...
I'm trying to solve a problem, so I'm not looking for code, but for similar algorithms so I can solve it myself. I am given n bookcases each with a size amount of books inside. I am to move some of these bookcases to a new room as follows: The first bookcase will always be moved; I will keep the order of the bookcases...
I might be wrong for some things here, but here is what I recently though about. Modern frameworks MVC such as ASP.NET MVC 5, CakePHP, Java Spring etc. has their logic clearly separated into Models View and Controller. Specifically for handling the presentation layer in ASP.NET MVC we have Razor Views, in CakePHP we ha...
I've noticed that, for example, WordPress appends what seems to be some kind of hash or random string to its wordpress_logged_in cookie, making a cookie name of, for example, wordpress_logged_in_abcdef1234, which makes accessing it from within a script less than straightforward. Could someone please explain why this ...
Hi is there any stats that a MIT/BSD licence project is hindered (as far as getting people to contribute) from closed forks? Stats or resources but not opinions of which license is best please. Note: I have updated the question to show I'm only looking for facts on contributor count or change of contributors in close f...
If I have a series of edges that branch and curve, such as in a road network, is there an algorithm that will identify the areas (defined by sequence of geographic points) defined between those lines? e.g. From to Keeping in mind that the areas can be irregular shapes.
I have my C# project separated in several projects, so each will become a separate .dll after. I have one project for my Model and one for my Data. Model is responsible for Business Logic and objects representations of what's in the Data Base. Data is responsible for creating the Data Base and general ORM operations. ...
I was asked this by an interviewer today and unfortunately he wouldn't share the kind of answer he was looking for so I'm hoping maybe the community can help. Say you're an engineer at company X and you begin to notice visiting x.com is slow. Assuming you're dealing with a highly distributed architecture, what question...
I'm designing a NoSQL database schema - MongoDB in particular - and I'm wondering if it's a good idea not to embed certain one-to-one relationships. For one example, I have an accounts collection, which stores all the account information. The account balance requires some calculation to compute, and I see two options: ...
So as you know there is a best practice saying Limit a row of source code in 80 characters. Here are 2 links: Why is 80 characters the 'standard' limit for code width? Is the 80 character limit still relevant in times of widescreen monitors? And I am sure you can fine more if you search for this best practice. But ...
I am studying the OWASP Level 2 review measures and methodology. I am applying this to a software I am designing and developing now, so the goal is to write the software the proper way so that it will pass the level 2 review. The OWASP standard is here: https://www.owasp.org/images/6/67/OWASPApplicationSecurityVerific...
I would like your opinion regarding a good style/format for short messages when committing into a repository (GIT or SVN). Considering we are using a feature branch development approach, with one branch per feature assign to only one developer at any time and I am interested to commit often in the repository. Let's im...
I came across this problem of finding the shortest path with exactly k edges. After some searching, I found the code below. It uses a 3D DP. States are there for number of edges used, source vertex and destination vertex. It seems like they have used something like a Floyd Warshall algorithm here. In that case, should...
Background Construction Note that I am using C# here, but it may not be necessary to provide input to my conceptual questions about design. Consider the following design methodology... I work at a place where we have a number of different versions of a particular product. Recently I was given a design specification for...
I have a class that transforms a complex model, for example an abstract syntax tree or intermediate model. The model can be either valid, invalid or partially invalid, i.e. it contains errors but some parts of it are valid and can be processed further. The most simple error reporting is to use exceptions: public class ...
Background I am considering a design that includes a public API class containing many nested private classes. I am doing this for the following reasons: Why private nesting? They will have no use to any other classes except for by my public API class. Why classes in the first place? The objects being represented have ...
Let's say I'm modelling an organizational hierarchy which consists of Divisions that contain Departments that contain Teams. So Division -> Department -> Team. While it makes sense for the Division class to contain a collection of Departments, should the Department class contain its parent Division object or just the p...
We are using GitHub for managing source code and waffle board for managing workflow/issues. Right now when we test the system using custom written test cases, it generates a CSV file. We want to be able to keep a record of these test results, so we can go back and run the same test again with the same Inputs and verif...
From the Apache non-lawyer version of the license: It requires you to: include a copy of the license in any redistribution you may make that includes Apache software; provide clear attribution to The Apache Software Foundation for any distributions that include Apache software. The license itself clarifies deriva...
I am seeking a good argument for: Why is it NOT a good idea to embed data retrieval code in my view? Example <tr> <td>Product</td> <td><select name="product"> <option value="0">--</option> <? $sql = "SELECT id, model FROM product"; $result = db_execute($sql); for ...
Let's say you want control a motor in real time. Normally you would use a microcontroller or PC with e.g. c-programming language. So you would use an imperative approach. You tell the microcontroller exactly HOW to do the motor control. And for determinism you would use specific time frames to do the control. My quest...
I work on a large software project where many vendors contribute have forks of a shared repository. Everyone has their own internal repositories and issue trackers. The problem that I'm trying to solve is to let people use the relatively common practice of including the phrase: fixes #123 This has the awesome feature...
I am trying to write a generic method which goes a particular DB table depending on the entity which is passed (all valid entities implement IStaticData) : IEnumerable<T> GetEnumerable<T>() where T : IStaticData I am using the nop commerce framework and have at my disposal IRepository<T> for every entity in the databas...
Say third party library Beautify renames one of their methods from beauty to makeBeautiful because they want the method to be a verb and by some lack of initial planning didn't do this from the start. Now, I use this beauty method a lot... how do I rename all occurrences of it to makeBeautiful without doing a plain str...
I've got a question about the semantics of C and was wondering why the powers that be decided to make arrays different from every other type in the language. I understand that arrays and pointers are different compile-time abstractions in C. An array has a fixed length and sizeof returns stride * length for an array. F...
I want to show the following action. "Administrator removes and adds users to the system" Since context diagram contains just inputs and outputs, I can add users in the following way: Administrator-----User registration details---->System(input) Administrator<----User login details--------System(Output) But how do I...
When a user hits the load balancer and the load balancer determines which web server to forward to, what happens next? Does the load balancer forward the request and all its data to the webserver, receive the webserver's response and return that back to the user? Or is it more like a redirect where the load balancer li...
Let us consider a purely declarative language such as SQL, XQuery, or a logic language like Prolog, or a purely functional language without variable mutability. Considering that the interpreter or compiler for a such language is free of bugs and can check every type errors, could a program written in such language hav...
I'm writing a camera control program which uses many methods for each of the different commands. One example is: public void CameraPan(int Id, string Direction, int Speed) { StringBuilder sb = new StringBuilder(); sb.Append(_cameraRamp); //command to camera - start moving sb.Append(_camID); sb.Append(Co...
There are plenty of similar questions that have been answered. Example here. However, they all have both the Reader and the InputStream within the same scope or method body, and so suggest to close the last in the chain (Reader) instead of the first (InputStream). So for my particular case, I am building an API, and wa...
From Java 5 language guide: When you see the colon (:) read it as "in". Why not use in in the first place then? This has been bugging me for years. Because it's inconsistent with the rest of the language. For example, in Java there are implements, extends, super for relations between types instead of symbols like in ...
Given the set of rules explained in "Clean Code", can one really use for loops? My confusion stems form the fact that a for loop is a low-level construct per se, thus it can only be used at the very lowest level of abstraction, by the book. But then, does it mean that using the loop is forbidden in those pieces of code...
I believe we have to use a variant of master theorem...can someone suggest me how to find complexity of such equation which doesn't directly fit into Masters theorem.
Lately I've been trying to wrap my mind about the following fact. On one hand, there is a host of coding guidelines and standards for what is considered to be "healthy", "clean", "well-written" and so on code. See the "Clean Code" that appears to be widely discussed here as well. Example rule: 7 line long methods and 1...
I'm creating a live scores application for Rugy League. It shows scores in real-time as a match is taking place. In Rugby League the match clock can be paused at any point during the match (similar to Basketball). I'm having trouble accurately syncing the time representation of a match in my app with the actual match t...
In the language I work with, Progress OpenEdge 11.5.1, there is nothing like anonymous classes. However, the system design would really benefit the use of such classes. Is there some nice known way of constructing such classes without having them in the language specification? My thoughts goes like a class having a co...
When I write... l2 = [my_computation(x) for x in l] ..., I wonder if python is applying my_computation to every x using all cores of my CPU. If not, why ? Is there a simple way to make python parallelize list comprehensions? Is this related to the behavior of map() or not at all?
I am working as SAP developer, where in many cases you have traditional requirements to applications (reports): Read in some data from the database or a file Do some magic with that data, e.g. do various calculations Write out the results into the database or a file again This is the typical use case for many SAP pro...
In his great thesis, Benjamin Erb says about scalability, reliability and availability: The essential technique for ensuring availability and reliability is redundancy and the overprovisioning of resources. From a methodical viewpoint, this is very similar to horizontal scaling. However, it is important not to c...
I am learning Haskell, and I was looking for an auto indentation tool. I didn't look much, and learned that in Haskell (as in Python), indentation signifies a block. As a result, I'm guessing that it's impossible to create an auto formatting tool, as strong as in other languages in the C family, that use explicit marke...
In an Asp.Net Web API 2 project, We're logging every http request and response with log4Net. Some controllers have critical parameters such as "CreditCard, CVV, Month, Year" etc. This data should not be stored in a database. I don't know how to check for these. Should I use a RegEx? Or should I hide the controller met...
This question is related to this one: Why not commit unresolved changes? When needing to merge a large code base with many conflicts, I would like to have a way to commit progress to be shared across a team of people executing the merge while maintaining the ability to use all our merge tools during the process. We hap...
Niklaus Wirth wrote a book that popularised the informal equation used as a title: “Data Structures + Algorithms = Programs”. I like to write this equation backwards as in the title of the question, because it hints at a simple but subtle aspect of programming: we are responsible of deciding which ideas of our program...
How is the Agile process affected if a stakeholder requests that a specific operation in the software need to perform better? This could mean that it runs very slow for a customer's needs (even with hardware improvements) or it crashes completely under the demand. How would this affect different parts of the Agile pro...
In thinking about the principle of "be conservative in what you send and liberal in what you accept", I generally try to make my methods receive IEnumerable parameters, but emit a IReadOnlyCollection (except where deferred execution is truly valuable, then I do emit an IEnumerable). However, I just realized that when s...
I am building a REST API where clients can query user-sent messages, like this: GET http://example.com/api/v1/messages?from=0&to=100 Response: [ { "id": 12345, "text": "Hello, world!" }, { "id": 12346, "text": "Testing, testing" }, ... ] Now, I need to include the n...
We are planning a redesign of our front-end and would like to roll it out using a feature toggle. We want to expose the changes to limited sets of users as we iterate and perhaps allow users to opt into the new design. I have seen this done on a number of sites, but am having trouble finding details on how this sort of...
We're working on a bugtracking system. Our design has a BugReport class that represents the filing of a bug of some Project in the system. BugReports have tags, representing the state/progress of the BugReport. Possible tags are e.g. New, Closed, Duplicate, Under Review, ... Tags have no responsibility other than repre...
Was doing some reading today about Razor Syntax with MVC Framework and was wondering why would/should I use Razor? What benefit does it provide over doing the same thing in the code behind and/or controller? As an example I saw, they showed how you can use Razor to display the current time, doing arrays and loops, a...
I'm working with a Laravel app and am development a "referral" feature. A user clicks "refer friend" and a URL pops up that can be shared on Facebook etc, when another user clicks on the link they are taken to the site, a session parameter is set, and later if the user signs up, the original user gets credit. There a...
Given N non-comparable arrays of different sizes, what is the best method to combine them into one output array? Since the input arrays are non-comparable, a metric is needed to represent how frequently the value on top of the array in question is appended to the output array. Lets call it weight and let it be an arbit...
When I add logging (e.g. log4j2 in Java) to existing code, is it ok (good practice), to alter the code? Consider the following example: //if process returned 0 return true return (returnCode == process.waitFor()); This construction is rather neat, but when I want to add logging to it, and I want to use two different...
I'm working for a small webdevelopment company and we want to set up development environments. We'll be using the Laravel framework in combination with Homestead. Now, Homestead has its own database and can work with migrations from Laravel, meaning that any changes to the existing database from previous versions can b...
The title is pretty self-explanatory. I have a minified JavaScript code (100k+ lines) and would like to find all occurrences of a particular variable so I could rename it to better understand code. Is there a way to do that?
Which data structure are used for commenting text and which algorithms take care for updating the comment position? A commenting feature is present in every good word processor such as Microsoft Word, Google Docs etc. I can imagine two approaches: One would be surrounding the commented text with some sort of markup (e....
Context I work in the energy domain with devices that send data in clear text over some medium, that finally ends on a computer. The data is there decoded and stored in XML files. A current XML file storing data for a device looks like this at the moment: <Device> <Address>1234</Address> <SomeOtherParam /> ...
I've got a Windows application coded in C++. I want to provide a web-based interface to them, with a view to porting them to embedded Linux systems. The web pages are a series of dynamic 'status pages' into the system, with possibly some simple interaction controls Modern HTML/CSS/Web technologies are all comparatively...
I have explained to my students that equal-to testing is not reliable for float variables, but is fine for integers. The textbook I am using said that it is easier to read > and < than >= and <=. I agree to some extent, but in a For loop? Isn't it clearer to have the loop specify the starting and ending values? Am I mi...
I'm interested in language design and in general I can reason easily about widely known features (e.g. inheritance, polymorphism, delegates, lambdas, captures, garbage collection, exceptions, generics, variance, reflection, and so on), their interactions in a particular language, the ways they can possibly be implement...
Because any kind of persistence updates/inserts/deletes represents in some sense a kind of state change in a database, it makes me wonder whether databases can be considered monads. We say the same about monads in functional programming. What one can possibly gain or lose while designing a system with such thought pro...