instruction
stringlengths
34
19.9k
I'm setting up the Continuous Integration process for our API and I've split my brain trying to figure out how to connect that process with the API wrapper libs too. Here's what I want to happen: I push a change to the API The tests are run to make sure that the API is green. Temporarily deploy the API and test the fo...
When searching for online code editors (out of interest how all the course sites such as Codecademy has been made) I noticed they are all been written in JavaScript. Why are all those code editors such as CodeMirror or Ace written in JavaScript and not in PHP or Java for web applications?
I've been working on a new application for some months now. It's my first big JPA program, and is still in the early stages. However, the complexity of my JPA object tree is becoming a growing problem. For instance I have an object tree of Users, who have Companies, Divisions, Related Divisions, Currencies, Local Curre...
I am currently prototyping a piece software which must be able to generate different types of documents in different file formats. The document could be a letter, or a receipt, for example, requested as a Word document, PDF, or both. I am using a Word and PDF library which each have their own separate APIs. Each differ...
Is it possible to implement the Repository pattern without using entity framework? I am working on a small dev team of 3 on a small scale (for now) ASP.NET MVC solution. I told my manager that I think that we need a layer of abstraction between our business logic and our controllers. Right now our controllers conta...
I have a need to explain MVC to non-programmers. Namely, to managers of other departments, in the context of progress report. One of the things I do is refactor our codebase towards MVC separation. What is MVC separation they might ask? Why is it needed they might ask? After reading a fairly technical answer like thi...
Is there a possibility that someone who has learned all the key aspects of C++ and knows the fundamentals of the language very well, will learn other languages (such as, Python, Perl, Java) faster and easier?
I need to find a solution for high throughput network data interleaving in my QT framework based windows application. My application is based on server/client architecture. The client connects to a server and both can exchange messages of arbitrary sizes. A message is just a piece of data, with a header describing the ...
I've been working on some abstractions of setTimeout and setInterval in order to process large sets of data without blocking the event loop in the browser. Upon this, I have discovered that browsers "clamp" the number of milliseconds you specify for a timeout or an interval. For example, if you write setTimeout('do som...
I have a tool that I am working on which allows people to create meetings. They can select the Date, Time & Timezone that this meeting is occurring in. I need to determine the best way to store that data in SQL. The end goal is that a user can click on "View Meetings" and it will show them all of the meetings. However...
For a small webapp I want to be able to identify a user. The issue is, if the user cheats in some manner, I want to be able to forbid him the usage of my application. I already have done extensive research on that topic, but to no avail. What is not an option: cookies: can be disabled or deleted (to easily overridable...
We have a project where the scope and resources are fixed. We have a fully groomed backlog and a velocity, so from this I can work out a rough idea of when we may release. As a team, we feel it is understandable that the business will want some idea of when it will be released. My approach is to say something along the...
I was just reading answers to a question Plain English explanation of Big O From that i came to know that Big-O notation is just an "upper bound" of the complexity of an algorithm? But can we apply it to other cases(i.e best and average case) of an algorithm?
How much does learning C to moderate level help you as a programmer. For example, does being competent in C make it easier to pick up languages as time goes on and get a better understanding of them?
I'm developing a new templating language for PHP, and one of the features is an object-oriented approach to nested child templates. For example, I can declare an object of type HtmlBuilder like this: $template = " <div> <h1>{{field1}}</h1> <p>{{field2}}</p> </div>"; $content = [ "field1" => "value1", ...
I have a bunch of x-y graphs given to me and I need to be able to transform them into some kind of data structure from which I will be able to get Y with X value. The problem is, though that I have 4, at max 5 values of Y given to me, and my X values can range up to 9000. So the information I have is something of the f...
I am a self-taught programmer. I started programming about 1.5 years ago. Now I have started to have programming classes in school. We have had programming classes for 1/2 year and will have another 1/2 right now. In the classes we are learning to program in C++ (which is a language that I already knew to use quite wel...
I have two classes which are somewhat tightly coupled to one another. Lets call them A and B. A derives from C and B derives from D. B is the class whose instance is created by the system and then B in turn creates instance of A and also starts executing an application that B will interact and control execution of. All...
As a mid-level developer on my team, I participate in requirements gathering/scope planning meetings of projects that I will be part of. I have been finding it difficult to come up with the questions that add value to the discussion or to my knowledge. After some self analysis, I found that knowing that there is a seni...
Let's say I got code like this: if(conditionA) do something if(conditionA && conditionB) do something more Obviously, I could nest the ifs (although when there are more complicated conditions this is not readable for me) like below: if(conditionA) do something if(conditionB) do something more ...
Consider you wanting to implement a simple game of checkers. There would be a rectangular game board and the player would able to move the pieces around according to a particular set of rules. General good design principles suggest that we decouple the display of the game from it's data and logic. That is, the display ...
I need to compare performance of 2 processors and I concluded I should benchmark then with several various tests. I'm currently using linpack (HPL) (because it's still well known and used for example to build top 500 list) SciMark2 (because of 5 different methods inside) simple for loops written in C (to see differenc...
I'm working on a simple board game that will run in the browser. I'm thinking how to structure the program and I'd like to hear your opinions. The program will consist of the user interface part (the logic that handles key presses, manipulates Html, etc.), and of the data-and-logic part (makes decisions on how to updat...
I am Using SendGrid to Send Emails to my Users. There are two ways to send emails via SendGrid. 1 - Via APIs 2 - Via Program/Code I want to know which one is More Secure and efficient way. I am Using python language, As Python is already slow in processing. So that I want to choose the efficient and fast way.
I want to make an online management tool for a server software using GPL licensed software. For the tool I'm fine releasing all software to anyone how wants it. After all, it's not rocket science. The question I have arises when the tool can be used to write code and applications also using the GPL licensed software. T...
I want to store a number of participants for a meeting. The order of them is not important. The only thing I want to make sure is, that I will be able to add and remove participants, use filter functions (and alike) and get their number. Also duplicates are not allowed. I started using List for the method signature, bu...
Let's say that I have a service for Job Offer entity in CRM app. Job offer is related to many many things, so there will be lot of methods on service layer to interact with above. What should be considered better approach - one big, fat service class for whole Job Offer family (like, 50 methods in service), or breaking...
For a web application we are planning (some kind of product information system). We have to manage all the assets (pictures) of the products. There are system (Wikis or DAM System) that save the assets in the DB itself or only a reference. What are the criterias to decide wheter the files itslef it should be stored on ...
We are planning to build a travel website in which we will be integrating multiple APIs (eg. DOTW, GTA, Expedia) for Hotels. I have initially tried to use MySQL but since there are huge amounts of data in hotels and it may contain numerous "one to many" relationships with Images, Amenities and Rooms, the search becomes...
What programming language is this? It's a Lisp dialect used by GCC internals. (define_insn "*call_symbol" [(call (mem:DI (match_operand:DI 0 "" "")) (match_operand 1 "" "")) (use (match_operand 2 "" "")) (clobber (reg:DI LR_REGNUM))] "GET_CODE (operands[0]) == SYMBOL_REF && !aarch64_is_long_...
I'm a teacher and I'm about to publish a tutorial on how a build a PHP app in several iterative steps. At each iteration, I want to provide access to the associated source code and differences with the code of the previous iteration. Naturally, I plan on using a Git repository for the project source code with a branch ...
In both .NET and in Android and I'm sure other frameworks I've noticed this issue where you end up with a task that takes too long and so holds up the UI thread. Say you have a method that updates a label with text from a network location/internet and comes back again after 3-4 seconds and sets the label appropriately....
I'm creating a little rpg fight program just for fun and to practice my java (I'm pretty new hehe). I have a class called Dice with a method called d20 that rolls a random number between 1 and 20. The method will be used frequently by all other classes in the program. My question is, should I create a single instance o...
I need to store and to be able to query some very large amounts time series data. Properties of the data are as follows: number of series : around 12.000 (twelve thousand) number of data points, globally : around 500.000.000 per month (five hundred millions) mixed value types: the majority of data points are floating ...
I'll start by saying I'm just learning about AngularJS, and I was reading this article, which seems to advocate for obtrusive JavaScript as the right thing: http://www.ng-newsletter.com/posts/angular-for-the-jquery-developer.html My understanding is that unobtrusive JavaScript is generally considered "the right thing" ...
There are a couple of questions already here for whether or not a VM should be used as a development environment. I don't wish to answer that question here but I'm assuming that a VM should be used as a development environment. My question here is on guidelines for which tools should exist in the VM and which should e...
I'm using the Class Table Inheritance architecture with my application and have read Fowler. When mapping my database tables to classes in code, I've realized I have no need for an "ID" property on my derived classes, and, in fact, it can cause issues if it has the same name because it hides the base class property. D...
From two books' review Daniel Bovet and Marco Cesati. Understanding the Linux Kernel (2nd Edition or newer): Note: this book has some tendency to function as a play-by-play of what happens inside Linux (on an x86) as opposed to a design book. You may find the BSD book or the Love book more design-oriented. Robert...
Let's assume within my project which is GPLv3 based I'm using a single library called a-lib.jar. That jar itself is licensed using Apache v2 license, so I should be fine with the GPL as long as I respect the Apache v2 terms (basicly inclueding the license file). Now when I look into the a-lib.jar that I'm using I see ...
I am working on a site where I want to have a header and footer on each page, so I thought about using server side includes for this. I have not used them before so I am a little bit unsure about best practices when it comes to styling my site. I am currently including the styles and scripts in the file for the header,...
I currently have an program in Java that simulates railway movements. Essentially, trains arrive on platforms, pick up and drop off passengers, and then proceed, respecting signalling where possible. However, currently this only exists in the program's state, and there is no actual graphical view of all of this happeni...
I have a "Product" POJO class in my app. A Product object can either be created in-app by the user or by parsing a json that comes from the API. Product has 20+ fields, but Im using only 2 here for clarity Example: JSON productJSON = networkCommunicator.getJSONFromStream(); Product product = new Product(); product.set...
When programming in C (or C++) there are three different ways to specify the parameter in a function that takes an array. Here is an example (implementing std::accumulate from C++ in C) that shows you what I mean. I can write it like this: int accumulate(int n, int *array) { int i; int sum = 0; for (i = 0; ...
I took up programming a couple of months ago (alongside my day job) and am struggling with a couple of basic concepts. Currently, I'm trying to learn how to build a database based PHP login/logout for a web app. Can anyone help me understand the concept of database users? The way I see it, there is: a database server...
I think that in programming error checking is extremely important, not a secondary topic, what if your programme crashes without an error, just silently aborting? What if you must discover a SintaxError at line 1293 by manually checking all the lines? Would any programme longer than 5-10 lines be possible if error chec...
I have an iOS app that uses the VLCKit framework for it's video player function. Today I got an email from the creator of VLC and in the email is stated this: According to the LGPLv2.1 VLCKit and libvlc are licensed under, I hearby request the source code for our libraries. Of course I want to comply with this request ...
I am writing a library in C++ that is used by customers to interface with hardware. There are many different devices that I need to support. For the sake of simplicity, assume I have 2 Widgets, WidgetA and WidgetB, which are physical devices. Both Widgets communicate using the same protocol and share a lot in common. T...
Suppose we have a function, f(n)=n+10. We say that f(n)∈O(n), meaning O(n) represents the upper bound of the function. It is also true that f(n)∈O(n2) or f(n)∈O(n3) and so on. So how can we say that O(n) is the upper bound when O(n2) is comparatively bigger bound and O(n3) is much bigger bound? Please forgive if I have...
When should a private method take the public route to access private data? For example, if I had this immutable 'multiplier' class (a bit contrived, I know): class Multiplier { public: Multiplier(int a, int b) : a(a), b(b) { } int getA() const { return a; } int getB() const { return b; } int getProduct(...
I have an application where users will be able to upload multiple images for one Product (via something like Ryan Bates nested fields, so you'd click "Add Image", and a file upload would appear on the same page). I'm planning on using jQuery File Upload, and Amazon S3, and nested fields. The thing I'm confused about, i...
I really was questioning to myself where to ask this, as I could not decide myself. This is more of a software design question. Context I currently maintain a small Node.js module on NPM which basically acts as an API wrapper for an online service. Issue I have one function in the module which, when called with a stri...
When using Golomb/Rice code in image compression, it is inevitable for us to meet large values. Golomb coding uses a tunable parameter M to divide an input value N into two parts : q, the result of a division by M, and r, the remainder. The quotient is sent in unary coding, followed by the remainder in binary. For exam...
I have an interface called IContext. For the purposes of this it doesn't really matter what's it does except the following: T GetService<T>(); What this method does is look at the current DI container of the application and attempts to resolve the dependency. Fairly standard I think. In my ASP.NET MVC application, my ...
I'm programming a library (so I have complete access to all the mentioned classes). Two classes (A and B) are essentially the same and differ only by their implementation, so they can easily be converted into one another. But I'm asking myself, if converting by passing an argument of type B to one of A's constructors o...
I've got a project. In this project I wished to refactor it to add a feature, and I refactored the project to add the feature. The problem is that when I was done, it turned out that I needed to make a minor interface change to accommodate it. So I made the change. And then the consuming class can't be implemented with...
Besides a faster register allocation algorithm and some trade-off in control and data-flow analysis for optimization purposes, which components/phases of a JIT compiler are different from a traditional ahead of time compiler?
In Modern Compiler Implementation in C of A. Appel some instruction selection algorithms are discussed based on tiling an intermediate representation tree. Each tile (or tree pattern) expresses a single machine instruction as a fragment of an intermediate representation tree. Are there any variants for the single machi...
Is it a good practice to test features that only run in a development environment, or just a waste of time? Specifics: The item that is prompting this question is a line of code that dynamically re-compiles style sheets. For production it compiles them once, then puts them in ./build/. As for research, I did some googl...
At many places, I read that we can use HashMap here for O(1) search. Actually, I want to ask how I can implement easy hashmaps which can satisfy this property. Can anyone tell few hashmaps including collision thing into consideration. I don't want complete codes. I want just pseudo code or algorithm for this. I am cur...
When (unit) testing, is is bad to expect the code to use certain paths. For example, should I be testing for specifically "/build/static/public/css/", or just that server.cssPath has been set to a string and is a valid path? I'm testing a web server.
I was thinking about unit tests and code coverage, and I came up with this thought: It is possible to have 100% code coverage and not test 100% of your code. For example: function myTestedFunction(){ doSomething(); doSomethingElse(); } In this example, if I have a test that myTestedFunction calls doSomethin...
Lets suppose we have some Js Widget, that includes three objects view, controller, model. var MyWidget=function(){ this.setModel(new Model()); this.setView(new View()); this.setController(new Controller()); ... } And I create this widget this way widget=new MyWidget(); There must be some enty point to start this w...
To clarify, the UX professionals at my company are making the big decisions about what the general layout of the application should be, and they are providing wireframes which we follow as best we can whenever they make sense. But when we go to implement a wireframe or feature request, it's extremely common to run into...
Django uses apps to divide projects into manageable and reusable chunks. All examples in tutorials use polls or articles in unrelatable circumstances. In a modern example like Reddit (or even Amazon or Ebay), how would Django apps be used to break up the website?
I recently found use for the following Haskell functions: feed :: (a -> (a, b)) -> a -> Int -> (a, [b]) feed f input 0 = (input, []) feed f input n | n < 0 = error "feed f input n: n < 0" | otherwise = (final, out:prev) where (next, out) = f input (final, prev) = feed f next $ pred n nest :: (a -> a) -> ...
I'm reading "Head first design patterns" (here you can find exact example mentioned in book) While going through Decorator design pattern, everything was crisp and clear until I stumbled into this They are explaining decorator using Extensions. I don't think extending a class through 'Extensions' results in decorator...
I am looking at some legacy code in java that uses the Service Locator pattern as a way of passing global references as opposed to passing them over and over again through method arguments and I am looking to refactor this approach. First of all this is a good approach or does it indicate code smell ? If it is code sme...
I studied C programming about ten years ago, whiles in Uni,however I would like to pick it up again. I'm looking at developing secure applications that utilize cryptography. Would C be the right language to use? What types of applications are developed using C?
I want to create a gem that extends the functionality of Rake, creating commands for compiling .NET code.* Basically, I want to be able to write a Rakefile like this: desc "Build main executable" fsc :build do |t| t.output_file = "nde.exe" t.output_folder = "output" t.source_files << "main.fs" t.packages << "pa...
I'm wondering if someone might explain the last paragraph written in this example on Dependency Inversion & Decoupling. http://www.springbyexample.org/examples/core-concepts.html Following the example code, understanding the reasoning behind decoupling classes by implementing a base class is fine. What I would like som...
I have been studying Design Patterns and I am looking to implement them into my latest project. I am working on a Windows Service that regularly checks a database table for a new entry. Depending on the entry found, the service will perform a number of processes. Possible processes include: 1) Generate report and send ...
Let's say that I want to enter info about multiple users from the command line AND that each user has multiple data associated with it. Is it possible (syntactically permissible) to use argparse to parse something like myprpgrm.py --user john --email john@doe.com --valid Y --user jane --email jane@doe.com --valid N? As...
My question is fairly simple.. What is the closest ORM to ActiveRecord that I'd be able to find for Java? In other words, in terms of thinking patterns and knowledge, with limted development time, what ORM should I use for Java, coming from a Rails + ActiveRecord background? Which one is both good enough and would be e...
I am reading Bjarne Stroustrup's book titled "A tour of C++". The following section is confusing to me: When a class is a resource handle – that is, when the class is responsible for an object accessed through a pointer – the default member wise copy is typically a disaster. Member wise copy would violate the resource...
To give a slightly contrived example, let's say I want to test that a function returns two numbers, and that the first one is smaller than the second one: def test_length(): result = my_function() assert len(result) == 2 def test_order() a, b = my_function() assert a < b Here, if test_length fails, th...
I am given a task which I need to do research on codebase and report my progress. The dev environment is not set up. I can only read the code and analyze it, e.g. the workflow of user account creation. There is a lot of uncertainty as my understanding on the code may not reflect the actual execution of the code. I unde...
I have a question, because in most serious sources I read, all say the same No variable is ever declared in Ruby, but still I have doubts, because according to what I was taught in my university implicit declaration is when a variable is created via allocation, where you can specify the type of a variable through conve...
I've got an solution which consists of Windows Services and websites. When updating the applications currently, the following steps are undertaken Build of solution Post build tasks copy the DLLs to a specific application folder Build script is ran which gathers the DLLs relevant for each application (this is done vi...
What programming language introduced the word "field" to describe what we might call a member variable in C++? What modern programming languages carry on this usage as the preferred term? I've seen this word used in both a C and C++ context but it always feels a bit foreign. I don't have a copy of the C standard, but ...
Lets say I have 10 xml message types that come into my program via some type of input (file, port, etc). I have 10 subclasses of a type Message to handle the unique needs of each message type. When a new message comes in, is there a better way than a switch statement that switches on a substring of the message, or a hu...
Myself, I can't wait to write a function when I need to do something more than twice. But when it comes to things that only appear twice, it's a bit more tricky. For code that needs more than two lines, I'll write a function. But when facing things like: print "Hi, Tom" print "Hi, Mary" I'm hesitant to write: def gree...
I started learning Python and I am wondering why empty function are needed in a programming language. e.g. in python: def empty_func(): pass Even in shell scripts empty functions are available. My Understandings and question: Why do programming languages need empty functions? Is it for just playing around with p...
Many languages define that compare functions should return ANY negative value, zero, or ANY positive value. Is there some reason that it shouldn't be clearly defined as -1 0 and 1? Does a wide range in possible return values help more advanced algorithms to work more efficiently? If so, what algorithms work this way...
Right now I'm building an app that relies heavily on Parse.com's products. The app uses nearly all of their features: Data storage User management Push messages Analytics Crash reporting There are of course upsides Very very fast development: less time to market Service reliability Free of cost (to a certain extent)...
I'm studying for my exam of logic later this week and I have to prove that this while loop: i := 0 s := 0 while i < n do i := i + 1 s := s + (2*i -1) calculates n^2. This question is made up of 2 subquestions. We have to prove that 0 ≤ i ≤ n ∧ s = i^2 is a loop invariant for this while loop. I managed to prove...
Imagine I have two distinct OS processes (the actual OS is unimportant). Process A is responsible for playing a video file. Process B is responsible for playing the audio that accompanies the video file. Both processes are clients, connected via a local area network to a server. Assuming that the video and audio stream...
I want to do this in the right way to learn I have a few classes which have only one method. For example: public class RedColorText { public void AddRedColorText(string text) { //something here } } public class WhiteColorText { public void AddWhiteColorText(string text) { //something here ...
I know that there are plenty answers to this question on stackoverflow, but I can´t find one that give me an answer that can help me to solve a question that came out after read a lot of Javascript, JQuery articles and using those languages for several months. Here is the deal: Apparently, I can do a generic site that ...
In Event Storming, there are "Commands" (blue sticky notes) which are, in most cases, triggered by an Actor. How should these commands be named, prosa-wise, especially in relation to the actor? Something like Visitor -> "klicks checkout button" or, Visitor -> "go to checkout" ..? So: what is the intended naming scheme ...
I am using Visual Studio to create a GUI application in C#. The Toolbox serves as a nifty component palette that allows me to easily drag and drop buttons and other elements (for clarity I'll say button whenever I mean "control") onto my form, which makes static forms quite easy to do. However, I run into two problems:...
I wrote a program to find prime factors of a number. When I give a large number(600851475143) as input, MemoryError pops up. Below is the code: def fact(a): factors = [] for i in range(1,a+1): if a%i == 0: factors.append(i) return factors num = raw_input(">> ") #600851475143 a = b = ...
I work in a small team that creates and maintains quite a lot (> 100) of ASP.NET website projects. Our current workflow is that our projects are all located on a network drive, which everyone works from directly. We have a couple of shared code libraries, which contain both binaries and css, js and xsl files. With each...
I have a function to show or hide a certain UI control. In my example case below, the framework is jQuery I'm using for an event to show a tool tip that may fire a LOT (based on mouse movements) - but the underlying problem is more general and may also arise in a similar manner in lots of other UI frameworks. In fact, ...
I have a user interface with two numeric input boxes, send amount and receive amount. The values are in different currencies and are related by an exchange rate. That is, receive amount should always be send amount * exchange rate. But the user is allowed to click into either input box and modify the value, which cause...
I'm new to Domain-Driven Design and I'm using it in an application I am developing. I'm getting stuck on how to put new entities into a repository. My repository is just a big collection of entities that I can query. One of my entities can have child entities, so I gave it an AddChild() method. It uses a factory to ins...
I just started doing android development stuff after getting pretty comfortable with Java. Android apps tend to do this weird thing where they have all strings for their program held in an XML file called strings and the program refers to the strings instead of string literals in the code or even String objects. The on...
Basically i'm writing a game in Java where i want the program to tell the user that he can't move right or left if that move will cause the player to move out of the array, which means this: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 at Game.printmap(Game.java:58) at Game.main(Game.java:17...
Currently, I have a single Node server that provides both (a) stateless API routes returning JSON, and (b) session-based web routes. My API routes and web routes have started sharing a lot of code, and I'm wondering if and how I can avoid that. I would like to separate the functionality into two servers so the API and ...
I am trying to understand the difference between server workers and server jobs. Google has not been very helpful because the keyword "jobs" is being construed as an employment term... I have yet to find an article answering my question. :/ Would someone please elaborate on the distinction between server jobs and worke...
Given a web page with input fields, does it have a performance difference whether or not you assign the onblur handler inside of the onfocus handler like so: var inputFields = document.querySelectorAll("input"); for (i = 0; i < inputFields.length; ++i) { var thisInput = inputFields[i]; thisInput.onfocus = fun...