instruction
stringlengths
34
36.1k
I'm practicing with dynamic programming and I'm trying to solve this exercise http://www.geeksforgeeks.org/collect-maximum-points-in-a-grid-using-two-traversals/ But I can't understand how to use dynamic programming. My reasoning is to use a table T[n][m] to store the results and in every cells to find the max value to...
We've recently started to use the Scrum framework and we gradually went from 1 team to 5. I am doing the Scrum Master role. In the last months, each Development Teams worked on their Definition of Done (DoD) with the Product Owner. Each Teams have negociated their own DoD. There are some differences between each Do...
Recently I signed up for new account for a service provider's web site. I entered the usual the name, email , password (strong) , repeat password and I was signed up. Great everything works well. A few days later I had some trouble logging in, I did the 'forgot password' process and yet my new password (strong) did no...
While researching the subject matter - lock-free and wait-free data structures - I'm seeing a worrying amount of mention of patents with this area. I've hobby-researched compression algorithms years ago and by comparison the situation seems worse as hard as that is to imagine. Background I have a project in progress th...
here my Question it is said that "Java is not actually a pure object oriented programming language since it needs primitives" I want to know that how data types can affect to java be an pure object oriented Langugae ?
I have no prior USB integration and about 8 months of learning embedded systems on Atmel devices. I am trying to use an Atmel SAM L series to connect over USB to a computer. The use case is for data transfer. Specifically, the MCU will be gathering data from it's sensors and packaging it for USB transfer. I have search...
I have a basic unit test (for the sample) that involves this code: void testShouldCreateACar() { Car car = someone.createFerrari(); assertTrue(car.name == "Ferrari"); // can't access name since name is private } I can't access name since there's not a getter in Car (or Ferrari) class for it. I don't want to creat...
i've been wrapping my head around this and I want some ideas. How would I go about making a remote shutdown program for one computer to shutdown another? Would I use http or another protocol? I was thinking like a direct message from a computer to another and a listener program on the computer to get shutdown that woul...
I have some enums in a concrete API/library that will be publicly used by application projects. My problem here, is that I cannot write an interface to these enums (that I know of). I should have thought of this before starting the project, but I did not. What really complicates this is that some of the methods accept/...
Is Super.someMethod() a good practice to add clarity to the code by explicitly stating that someMethod is not a method included in the current class but in the parent class? For instance, would this make sense... private void someMethod() { super.someOtherMethod(); // this is in the parent class otherMethod();...
Does anyone know if there is such a thing as a run-configuration launcher for the JVM for "production"? Where you can set environment variables and arguments, just like in an IDE ?
Currently I have a model class that represents a user. This class has a constructor that takes an object with all user properties, used for example, when creating the user. In this case I instantiate the model passing it the necessary information so it's constructor can do the job, then it will use its own "createUser"...
Can some let me know how does maven internally manages package dependency? Is there any architecture diagram available on the net for the same? I also asked this in Quora and maven user mailing list but did not get any response their nor I am able to find any suitable resources in the web that explains the working of m...
I'm working with a small team that creates a proprietary web application and UX isn't much of a priority since our own people will be the ones operating it, but we do try to make their jobs easier. Should I, as a developer, create a UI mockup before I start creating a new screen? Nothing too fancy, mostly the general ...
My company is planning to integrate 3 in-house libraries into all of our applications (with possibly more on the way), and I'm wondering what the best way to go about this would be. My initial reaction is to put the code of all 3 into a single library and use that in all of our applications, but it seems like that woul...
Are there any real alternatives (i.e. non-customized software license agreement) to the AGPL license if you want to share your source code and make money selling software licenses?
Why doesn't Object.prototype.toString return a string representation of an object? I don't see any use for the current output and it seems that it would be more useful for the toString function to be the equivalent of JSON.stringify. Is there a particular motivation or reason as to why ({ val : 1 }).toString() produce...
I made a program that connected to the microphone and captured wave_format_ieee_float data from it. I noticed that if I made a really loud noise the data seems to fluctuate between -1 and 1 (when I cast the buffer pointer into float*). What is the significance of this? How do I connect this to deciBel Sound Pressure Le...
I wouldn't call myself a superstar dev, but a relatively experienced one. I try to keep code quality to a high level, and am always looking to make improvements to my coding style, try to make code efficient, readable and consistent as well as encouraging the team to follow a patterns & methodologies to ensure consiste...
I am creating a simple MiniMax implementation in the functional programming language Elixir. Because there are many perfect-knowledge games (tic tac toe, connect-four, checkers, chess, etc), this implementation could be a framework for creating game AIs for any of these games. One problem I am facing, however, is how t...
I have built a small Windows desktop application that I intend to sell and distribute copies over the internet (not as SaaS). The application in question uses ImageMagick library, which has a free licence (see here), if I understood it well. The problem is that my application uses ImageMagick components who depends of ...
I have an application that reads a large binary file (1GB on average) and compresses into a bzip2 archive. I started out at first compressing these files synchronously, as I didn't want to impede performance on a client machine. Sometimes however, these files come in bursts and I'd like to handle these files as quickly...
How does slow internet access affects the response time of a web based system hosted on local server that is being access by other clients from the local server? I'm accessing the web based system on a local server through the ip-address of local server. ex: 190.168.1.110/local_system/login
So for the past year or so, I've been trying to self-teach myself programming. The problem is, every time I start to try and teach myself (like on Codecademy and such) I start off great and then proceed to get lost. I've tried a few different langs (Python, Java, C) and all end with the same result of me struggling to ...
For example, I have a clan and a character. There's a character that is the leader. To give the clan a specific feature, some money from the character is required. I don't want to have too much tight coupling. Right now I have a member in the clan class like this: bool clan::give_rank(character* chr, int rank) { i...
I am having trouble thinking through what best-practice dictate I do in this situation. Say I have the following class structure Class A { public: bool isCompressed() { return compressed_; } private: bool compressed_; } Class B { private: ClassA *a_ptr_; public: /* Accessor here */ } If I needed to ge...
I've been asked to write a mobile app for a business I have connections with, and I've been trying to decide what I should charge. One thing I came up with was to research what other companies would charge for such a service, but all the ones that have the 'online estimators' are really over-the-top expensive and the c...
Have been hired to modernize an old binary compiler that has been forgotten since a few years by people who have died already. The compiler has a parser, an objectmodel and a generator of bytecode. The main problem is now that the generation-part built the binary from top to bottom in one step. while linkage w...
This side question bothers me: Has_This_Case_A_Name? Here is what I could find, but This_Case_Is_Missing: +---------------------------------------+---------------+ | Names | Example | +---------------------------------------+---------------+ | camelCase, lowerCamelCase ...
I'm writing a social app in Django where all users sign up through Facebook using Python Social Auth. All content that a user sees will be content created by her Facebook friends. Initially, I planned on creating individual users with no database relationship to each other, and relying on requests to Facebook to determ...
We have a requirement for a new feature which requires some seed data to be present in the database (basically some default values) for the feature to function correctly. We have this in 2 different scenarios at the moment, and the best method of generation / insertion of the seed data seems to vary depending on the da...
I am promoted to team lead position in my organization. Previously I was working as senior software developer or senior software engineer. Now company want to build their own product which is a website. Requirements and technologies selection are established as well. They want to hire team for this project. Senior so...
Recently I've been dusting off my knowledge on how Monads work. I've also been introduced to the concept of a 'Comonad', which is described as the inverse dual of a monad. However, I am impossible to wrap my head around it. To understand Monads, I made the own analogy for myself: Monads can be seen as 'a blueprint to ...
Java has an automatic GC that once in a while Stops The World, but takes care of garbage on a heap. Now C/C++ applications don't have these STW freezes, their memory usage doesn't grow infinitely either. How is this behavior achieved? How are the dead objects taken care of?
I have the following structure in my Outlook Public Folders. -Public Folders --1001_RandomProject --1002_AnotherProject --1003_Yetanotherproject ... and so on, basically there's a couple of thousand(!) subfolders each corresponding to a project and prefixed with the project number. Now I'm trying to create a Macro whi...
The AngularJS documentation mentions that it considers one-way data binding to be 'bad' and two-way data bind to be 'good*'. However, on looking over the definitions of two-way data binding used, all it seems to be is an auto-sync put in place between the view and the model. Diagram Surely this has a performance hit ...
I was working on a C program and i just noted that i can execute my program even if i didn't declared the required libraries, this is the code: #include <stdio.h> #include <string.h> int main(){ char x[999],y[999]="copyme"; strcpy(x,y); printf("Output: %s",x); return 0; } After i undeclared the string.h li...
I am looking for solutions for a field where I think I don't know the adequate terminology. The problem is that I have a central SQL database in the cloud. Then I have child databases only containing a defined part of the central database. The child database will not always have connection to the main database but as s...
I have heard this term many times, and it makes sense in theory. That app is doing many things and it'd be easier to manage, scale, test and improve them if they are not completely connected to each other and work like functions instead. This way you could have option to even easily replace components of app with diffe...
I process a lot of tweets in real time using python and for each tweet I need to assign it in to a specific bucket. I have about 50 buckets, each with their own rules. The majority of them are simple like so bucket_one = ['test', 'foo'] if any(x in tweet['text'] for x in bucket_one): tweet['bucket_one'] = 1 So the ...
Is there some historical or practical reason why SQL (or more specifically T-SQL in my case) does not support the closure property in many areas where many other language families like C do? (That is, the closure property as seen in math, where a real number time a real number is always a real number; nothing to do wit...
Which construction is more readable: someVariable == null ? SOME_VALUE : someVariable; // avoids negation someVariable != null ? someVariable : SOME_VALUE; // normal situation first I have to use such expressions very often, but I was never really sure which one is better.
I see all websites (THE big ones) make both PHP and HTML in same page .. Do I need to make all my website pages as PHP and embedded HTML inside it ? Can't I make the website all as HTML Pages and PHP pages separate and the required output of PHP page I make a separate HTML for it ? i need an explanation or advice for ...
Java garbage collection takes care of dead objects on the heap, but freezes the world sometimes. In C++ I have to call delete to dispose a created object at the end of it's life cycle. This delete seems like a very low price to pay for non-freezing environment. Placing all relevant delete keywords is a mechanical task....
I program as a hobbyist. I mainly code using an online tool (a website) that allows me to write, run, share, and debug code online. The website I use does have version control built in. Quite frequently, I forget to save my code. I close the tab accidentally, and lo and behold, hours of code are gone. This is really...
On page 45 of Robert C. Martin's Clean Code: A Handbook of Agile Software Craftsmanship, Martin writes that output arguments should be avoided. I'm having trouble understanding the meaning of "output argument" and why they should be avoided. Martin's example for an output argument appendFooter(s); calls the function p...
If I remember my compilers course correctly, the typical compiler has the following simplified outline: A lexical analyzer scans (or calls some scanning function on) the source code character-by-character The string of input characters is checked against the dictionary of lexemes for validity If the lexeme is valid, ...
When I try the below code I am not clearly able to analyze malloc api internal calls.What I am not clear is about the system call mmap is called only once for 2 or more malloc calls.If I am assigning more then 4069 bytes also it is calling only one mmap internally(trace is identified by using strace -p processid ). #in...
I have 6 web servers which are giving me problems due to cache inconsistency. I am thinking of building a cache invalidation service such that there is a topic on which all the servers can publish a message to invalidate an object. I am considering using the Amazon SNS for the making the topic. Now for the servers to r...
I recently moved from Java to JavaScript on Node.js. I was very excited, opened up my IntelliJ IDE for an existing Node.js project only to find I cannot know what the parameters I see functions receiving actually are except for their names (in java I could click the parameter type and see what it is..), I cannot use C...
Open source software should be developed by different contributors in decentralized fashion. I understand that Open JDK is reference implementation of Java which is open source and it allows contributions towards security and bug fixing. I believe Oracle makes most of the contributions to Open JDK. Does Java qualifies ...
What is the best practice for logging user-related data in microservices architecture? In example: I would like to audit/persist to database information on who deleted a resource. I have user info on the first (client-facing) service, but I don't pass it further. I wonder if there is a smart way of doing it - like inje...
In the past couple of weeks I have seen a couple instances of people passing an ErrorAccumulator type of object into functions that aggregates errors as Strings inside of the function then after the function returns the errors are iterated over and logged. To me this feels like bad OO design because you are modifying t...
I'm reading Domain-Driven Design at the moment and I'm trying to understand what should go in services and what should go in domain models. Say there is an application where you can reserve seats for concerts. Then after this you have a certain amount of time to pay for the tickets, after which the reservation is...
I would like to draw a UML sketch to communicate part of a software but the type of relationship between classes does not seem very clear cut to me. Let's say I want to periodically fetch the recent orders from the database and update a graphical view that has the order details. This is a highly simplified pseudo cod...
I am currently working on a pet project in Python with scrapy that scrapes several ebay-like sites for real-estate offers in my area. The thing is that some of the sites do seem to provide more structured data in their web pages(ie. presenting a table of all the utilities the apartment has etc.) while others don't. Th...
Background My program communicates with a device that is usually asynchronous, but can sometimes behave synchronously. I have an event handler that I use for receiving the data asynchronously, then I have a separate event handler that I use when the device is in the synchronous mode. So, when I need to communicate with...
There is a Java program that reads a list of orders and for each order starts a thread that receives data from SQL and prints the list of items in a given order to an order_name.html. I want to write a class that would generate all_orders.html that contains a list of items and the quantity of each item in all orders. ...
I want to structure my Python project in a manner such that others can use a package manager (PIP) to easily clone the environment for team development, and GIT to contribute to the project, plus a library dependency. My confusion relates to organizing a project around PIP and GIT (I'm familiar with SVN). The project d...
We are trying to adopt some CI practices and methodologies into our organization. I'm currently reading over some of the points in "Continuous Delivery" book written by Jez Humble and David Farley. And the point that I am debating is when unit tests should be run - before or after git commits. The book seems to sugg...
I made a few classes for processing and validating data in xlsx and csv. However, I am curious in testing how fast the methods I wrote in C# for the heavy lifting are. Here's what I currently am thinking of (written in C#): // use this to test the performance of the method on files with various sizes class FileProcess...
Why code in C? Isn't C++ basically C but with better features? Why do people still use C? Would it be easier to make a game with C or C++?
Chatting with a friend about a game we used to play, and thinking how to implement it in code. Here are the rules: Given a list of number e.g. {1,2,3,4} Try to use all the numbers from the list to perform +,-,*,/ operations to reach a target number (e.g. 2). The numbers can be used only once, the operators can be used ...
In my game I want characters to be able to cast spells which deal a certain amount of damage of a certain type to other characters in the game. I also want abilities that negate an amount of damage of a certain type to be equipped to a character. I don't want to have to program a huge wall of damage resistances that us...
Suppose a web application relies heavily on the third party APIs and I am expecting a response from it but somehow I don't get any, maybe because of the API exception or missing value on the API side then, in that what should I do? As far as I can understand if I get the API exception I can catch it and send some error...
I am trying to create a thread that will sit and wait to detect new objects in a vector (the queue). Using a loop will crush the resources on the given machine, so I am trying to figure out how I can create a blocking thread that waits for a notification from the main thread. The application will essentially wait for n...
I have these two classes (Getter/Setter/Constructor omitted): public class Company { private String name; private String adress; private List<Employee> employees; private Uuid id; } public class Employee { private String name; private int age; private Uuid id; } The two entities and their ...
Given a piece of code, I may use one of many methods to determine the big O complexity of the code manually (runtime and memory). But, for a given piece of code, how do I determine whether what I found earlier is correct or not? Are there tools available where I give an EXE, give test cases and I get an output saying t...
Hello i'm developing an app that needs to do many requests with different socks connections. I was doing it in C# but i'm not sure how well it will work on a linux server even with .net core . Java Socks connection is unique for the JVM correct? It needs to have 100+ different socks connection and can't be that thread ...
I wanna ask about Neural Network. I have a research and programming about Neural Network using Backpropagation algorithm for prediction. My input data using binary form. But, i'm still confuse, because i get some input data from expert. I have separate some data for training and the remaining data i have use to testing...
What is the difference between the following two methods of creating an array in C#: int[] arr = new int[] { 1, 2, 3 }; Array arr = new int[] { 1, 2, 3 };
I have three questions concerning Demeter's law. Apart from classes which were specifically appointed to return objects - such as factory and builder classes - is it okay for a method to return an object, e.g. an object held by one of the class's properties or would that violate the law of demeter (1)? And if it violat...
I'd like to check what best practices are avail out there. I have the following requirements: I have a repo which is used for development (master and develop branches). I would like to keep track of alpha/beta/release candidates and release build. I am considering to create branches for alpha/beta/rc/rel and then when...
I am writing a program to crawl the web and find frequently used words. What would be a good way to store the data? I was thinning of using an RDBMS with a single table (with columns 'word' and 'count') but for something so simple it seems like overkill. I need to achieve some functionality like sort by count/find n le...
I'm reading the head first c# book and don't quite understand what this means. "Any class can see private fields in another instances of the same class"
Often when I program in C I write the expression for (int i = 0; i < j; i++). I never wrote a macro or a define expression, but could I write a #define to simplify the above expression so that do i,j gets pre-processed to for (int i = 0; i < j; i++) ? Or, is it for some reason not a good idea?
I'm reading the 'Refactoring' book, and i'm at the "Extract method" technique: Original code: void printOwing() { printBanner(); //print details System.out.println ("name: " + _name); System.out.println ("amount " + getOutstanding()); } Refactored code with "Extract method" technique: void printOwing() { p...
I am very confused about what should a SPA's REST backend do and expose. In most blog posts and books I read they depict the backend pretty much like a direct access to the DB, practically CRUD methods that allow access to the DB after authenticating the user. However I don't see where to put the actual business logic....
Inside system I'm developing I have several Windows Services, couple of applications running in Scheduler and COM+ application that is running my custom DLL's. Some of them are running on same PC, but most of them on different machines but in same local network. I'd like to monitor status of tasks each element does. Fo...
Is it possible to add a new row to a database using DataSet? When I created a new DataSet and dragged the table from the database I could see that in the DataSet methods there was one called insert that in the preview showed a parameterized query almost like a stored procedure to insert data. However, when I create a n...
Background Thinking about OOP I feel that it binds data and behavior together, taking the real world example we already have array data type which is a collection of homogeneous type and in Java we have build a nice abstraction over it hence, we have methods like clone which does its job perfectly i.e. we have data and...
We are contemplating breaking up our monolithic monsters into microservices based architecture progressively. We have 5 teams, each team containing 2-3 C# developers, at least 1 database developer, and 2 QA engineers. Besides the huge culture and paradigm shift going from a monolithic architecture to microservices ther...
We all know that properties in C# get compiled to actual plain old methods. But unlike method(-group)s, they can't be given as arguments to other methods that expect a delegate like a Func<T> or Action<T> (getter and setter). Is there anything special prohibiting this, or is it just a feature that didn't come "for free...
I have been teaching myself how to code for about a year (I'm 17) and one of the most common things that I've come across while reading articles about programming is automated tests for your code. I know automated testing is something very helpful but I still don't get it, what are you supposed to test in your code? I...
I want to provide rest api for my iot service to read state of a sprinkler on/off. So far I've come up with two solutions: GET /api/sprinkler that returns 204 if on and 404 if off GET /api/sprinkler that returns 200 and {"status": "on"} The first example is based on this. By returning code 404 we imply that the resou...
I was assigned to a new project recently. Well, an old project actually, written in classic ASP. Now a new version of the application is being written in the latest ASP.NET, but it's not expected to be RTM in a while (estimated release date is January 2017) so I have to perform some maintenance on the old application u...
the What is free software page on the gnu.org web site states among others: »An example of such an acceptable rule is one saying that if you have distributed a modified version and a previous developer asks for a copy of it, you must send one.« I like this clause, but I do not know how to add it in my licensed software...
So I have a set of given locations (i.e. two-dimensional points) G, a set of wanted locations W and a natural number N. Assume |W| < N. I want to choose N elements of G such that the elements of W are somewhat covered (i.e. for each element of W there is a chosen element of G that is "nearby") and the choosen points a...
I'm a freshman in a Computer Science academy. Every semester there are a lot of different classes like Discrete Math, Linear Algebra, Algorithms etc most of which I find very interesting. Unfortunatly each day has only 24 hours and I find myself unable to get a more indepth knowledge of each of those classes, beyond th...
We are a bunch of freelancers working together making websites and apps and we starting using Scrum recently. We're enjoying Scrum and its transparency but we're encountering a problem with the budget side of the equation. It feels like Scrum doesn't consider budgets, but we are too new to know for sure. Is there a way...
I'm trying to find a good name for a library where I can put in all non-UI related code that I want to share between iOS apps (networking, filesystem, logic, algorithms, data structures). Names that I don't like too much: Model Backend NonUI Core Suggestions?
Haskell’s String type is an alias for [Char] (i.e. a linked list of Chars). Does any other language use an implementation of strings like this?
Most architectures I've seen rely on a call stack to save/restore context before function calls. It's such a common paradigm that push and pop operations are built-in to most processors. Are there systems that work without a stack? If so, how do they work, and what are they used for?
Are events only used for GUI programming? How do you handle in normal backend programming when something happens to this other thing?
In my unit tests, I often throw arbitrary values at my code to see what it does. For example, if I know that foo(1, 2, 3) is supposed to return 17, I might write this: assertEqual(foo(1, 2, 3), 17) These numbers are purely arbitrary and have no broader meaning (they are not, for example, boundary conditions, though I...
I am using GhostScript on a desktop application that I intend to sell online. The GhostScript library has an AFERO license (see here). I do not mind to make the source code of my application available to anyone who requests it. Therefore, can I license my application under the GNU Affero General Public License (GPL), e...
Question: In a database for a clinical reference lab a specimen, when taken, triggers a test order (for testing obviously) creation.If that test order produces a failure, the specimen is given a new test order and tested again until a non-failure result is obtained. And test order is created for exactly one specimen. ...
final CyclicBarrier cb = new CyclicBarrier(value,new Runnable(){ public void run(){ ...statements } }); suppose you have a cyclic barrier in which one of the the arguments is the direct override of the run(). Is there a specific term for this kind of object creation? Are there significant pros and cons in t...
When is memory allocated to a constructor in a C++ program run? I think it may be when the instance(object) of the class is created or so. Is it correct?
Some methods are deciared this way: public int myMethod() throws Exception { (return an int or throw Exception if method fails). However, stub methods in NetBeans look like public class JavaApp { public static void main(String[] args) { if(false){ //this branch is never used int a = ...