instruction
stringlengths
34
19.9k
Well this has been a question I have puzzled about for a long time: Suppose I have a dictionary of input:output like: This {2: 6, 5: 15, 20: 60, 26: 78, ... 982: 2946, 997: 2991} where output = input*3. or This {0: 5, 3: 8, 17: 22, 19: 24, ... 991: 996, 996: 1001} where output = input+5 or something els...
I am developing a commercial application. There are several programs under GPL which have some common features with my planned applications. Can I take ideas from those applications under GPL and implement them myself without copying the code? Would this violate the GPL?
Apologies for the long post... Where I work we have a system with many subsystems which are located in different locations. All the subsystems process some data and write the result on A database. In case any other subsystem needs the output f other subsystems it gets connected to the database and read from it. And tha...
I apologise in advance if this question is too subjective but I'm struggling to find a good answer, probably as there is not really a correct answer to give. I'm currently writing a database abstraction layer to unify the use of a single API throughout my applications. Possibly re-inventing the wheel but I'm mainly doi...
I want to use a dictionary (basically a text file, and no code) that is included with an open office spell checking plug-in. The plug-in is under the tri-license GPL/LGPL/MPL which I don't understand. is that legal? If it is illegal, what if I wrote a script that uses the said open office plug-in to generate the dictio...
I see myself using more and more immutable types when the instances of the class are not expected to be changed. It requires more work (see example below), but makes it easier to use the types in a multithreaded environment. At the same time, I rarely see immutable types in other applications, even when mutability woul...
I'm writing a program to automatically make the draw for a competition. There are four objects: Debate Judge School Team Each Debate has two teams and a judge. Each team participates in three debates. With this, there are the following rules: 1) A team cannot face someone from their same school 2) A team cannot face a...
I've read it at many places that unit tests should be independent. In my case I have a class that does data transformation. These steps must be done sequentially, otherwise they don't make sense. For example, load_data parse_float label normalize add_bias save_data For example, I cannot normalize the data before I lab...
I'm writing an application that deals with the network and the hard drive. For the network portion, the application measures in bits per second, while the disk portion measures in bytes per second. This becomes an issue as they both are abbreviated b/s or bps everywhere I've seen. How could I inform the user that one m...
I am building an application which, at the moment, consists of many small Python scripts. Each Python script processes items from one Amazon SQS queue. Emails come into an initial queue and are processed by a script, and typically the script will do a small unit of processing (for example, parse email and store some da...
I've read about the "hypervisor" in hardware virtualization. VMs are not my area, so I can't quite see where the term came from. THe wikipedia article talks about how "the hardware's supervisor state was virtualized as well, allowing multiple operating systems to run concurrently in separate virtual machine contexts" ...
As from March 2013, Microsoft allows Adobe Flash content to play by default on its immersive Internet Explorer 10: http://redmondmag.com/articles/2013/03/11/new-ie-10-flash-policy.aspx When asked about Silverlight, Microsoft says Silverlight will not be supported in immersive Internet Explorer 10 since these capabili...
I'm a bit confused if saving the information to session code below, belongs in the controller action as shown below or should it be part of my Model? I would add that I have other controller methods that will read this session value later. public ActionResult AddFriend(FriendsContext viewModel) { if (!Mode...
I am a student and a freelance programmer. These days I am developing a software in VB6 which has recently crossed 100KB of source code. The main problem, I face is, many times I have to refactor my existing source code which is really very boring. Also the size of my code base is not very big (only 100KB). What are th...
The consensus seems to be that one should follow the convention of the platform they're developing for. See: Underscore or camelcase? Naming conventions: camelCase versus underscore_case? However, PHP doesn't seem to strictly follow any convention internally (no surprises there), even for methods and functions (e.g. my...
Our product registers new players on our service, and we've chosen to host it on Azure (we're using .NET) and we wanted it to be stateless (for scalability) and relatively secure. Since this is the first REST WS I'm writing, I wanted to get some feedback on whether or not it's a solid solution. Some presumptions to kno...
I need to build a web service API for our mobile app to interact with our server & database (in ASP.Net MVC 4, but that's hardly relevant). Wile most actions do not need users to be registered with our service, we would like to restrict access only to users of our app. What are the methods to make sure that calls made...
The question is - what is an effective way to deliver files to users? Consider an asp.net application which gives an ability to view various files. A kind of image library or web file directory. Key points are: user can upload arbitrary files of size <= 10Mb files are stored on disk files never change user can remove ...
I have seen many answers in SO regarding using Google's CDN to load jQuery instead of loading it from the local server. In essence I understand this is the issue related with decreased latency, better caching. But I want to know the technical answer, perhaps an example mentioning why it is even an issue to just load a...
I'm looking to write a program that will generate valid sudoku puzzles. Essentially, a sudoku puzzle is just an 81 digit number. (The blanks are zeroes.) I would then like to use these puzzles in an Android app. Is there any risk to using randomly generated puzzles in an app? If another app has the same puzzle, am I...
I'm a CS student and I have been coding for a few months shy of a year now, and I seem to have developed what I think may be a "bad" habit and I'm wondering if anyone does the same (or whether it's a bad habit at all). When I'm coding / solving a problem with code, I find that my initial implementation is lengthy and o...
We have a project that keeps recurring. The client expects us to run a website twice a year and this is happened for the last year and a half. I took the last working copy and based our latest website on it. Now, a co-worker has suggested that next time we should start from scratch instead of fighting against legacy co...
Let's say I have a set of items {e1, e2, ..., en}, and I also have a set of constraints {c1, c2, ..., cm}, with ci := ej appears before ek, for some j and k. I want to produce an ordering of my items which maximizes the number of satisfied constraints, with the possibility that some of the constraints are contradictory...
i am working on a project consisting of sending and receiving streaming multimedia.So,i have installed JMF, but i have seen that JMF has 32 bit library as mine is 64 bit so i wanted to use Xuggler for streaming videos. Can anyone clarify me about the support of Java Media FrameWork with Xuggler..
I was looking through some Objective C docs.. and got this : UIGraphicsBeginImageContext : Creates a bitmap-based graphics context and makes it the current context. Also, the same term is used in Robotlegs : (http://www.adobe.com/devnet/actionscript/articles/intro-robotlegs-pt1.html) Context: Context is the boo...
I need to implement some graph partitioning algorithms for my thesis. I have mostly Windows experience. I would like to know if it is hard to migrate c++ console program to Linux. I want to program it on Windows but I want to test and compile it on Linux as well. It will be pure cli application, with no use of windows ...
I'm writing an InputStream that processes data streams containing "trailer" data. That is, the final n bytes of the stream is a piece of data that must be handled separately and shouldn't be returned from the read methods. My class will maintain an internal byte array of length n and read data into this byte array fro...
So I'm planning to use APIs for my host app. But the APIs are built such that it requires a sessionkey for every request. So my question is, how would I dogfood my API? Cause, apparently I'm thinking in the line of creating a "special" key for my host app (cause it makes no sense to request for a key for my own use), b...
I have a fairly new C# application, approximately 6 months old, that we are now trying to incorporate testing into. (Should have been done from the start but I can't change the past) Parts of this application involve pushing some documents out to a folder. A third party application then picks these up, does its own wor...
I have a large module which have to process more than 10k request/ response per second. Every request has a json and need to process it and verify it on the database and generate the response on the basis of the db query. Here is an example Function 1 function ('/get' , fucntion (req1 , res1 , next ){ //to proce...
Now, when I make a programming mistake with pointers in C, I get a nice segmentation fault, my program crashes and the debugger can even tell me where it went wrong. How did they do that in the time when memory protection wasn't available? I can see a DOS programmer fiddling away and crashing the entire OS when he made...
We are currently designing a REST API to access classical customer data. One of the elements in the API are the assets of an user. The assets are added under a given service. The backend API will only add an asset to an user under a given service. So, there's no User--Asset relation, but a User--[Service]--Asset rela...
Preamble My aim is to create reusable code for multiple projects (and also publish it on github) to manage subscriptions. I know about stripe and recurring billing providers, but that's not what this module is aiming for. It should just be a wrapper/helper for calculating account balance, easy notifications to renew a ...
I am trying to broaden my understanding of the history and development of object-oriented programming, and I am curious to find out if C was designed to facilitate Object-Oriented programming? (like C++ and Objective-C definitely are) or if it was, on the contrary, simply just a clever exploitation of the language's c...
The problem Let's say I have a class called DataSource which provides a ReadData method (and maybe others, but let's keep things simple) to read data from an .mdb file: var source = new DataSource("myFile.mdb"); var data = source.ReadData(); A few years later, I decide that I want to be able to support .xml files in a...
I have a number of objects storing state. There are essentially two types of fields. The ones that uniquely define what the object is (what node, what edge etc), and the others that store state describing how these things are connected (this node is connected to these edges, this edge is part of these paths) etc. My...
In this blog post about acceptance criteria the author explains that good acceptance criteria should: State an intent not a solution (e.g. “The user can choose an account” rather than “The user can select the account from a drop-down”) Are independent of implementation (ideally the phrasing would be the same regardles...
I'm looking to refactor an existing design; to move a bunch of stuff out of a database and into memory where it should be (There are many reasons the DB approch is dangerous as it is now). My first act was to take all the existing objects and expand more state to them. The previous objects new only their parents, and...
If you had a manager, a couple of levels above you, tell you that building software is like building a bridge, how would you respond to that? If this manager truly believes that we should be able to accurately estimate and build a system, what good metaphors are out there to explain why this isn't the case?
I'm going to develop a fairly basic re-usable blog component, with simple CRUD operations using ASP.Net. Which method of storing blog posts would be best suited to the situation in terms of performance/maintainability? Create an XML file and store data in filesystem, filesize will not likely be any more than 50kb in s...
I'm implementing a Windows 8 app using C#, part of it is One Way Chat. It will be for multiple users such as teacher and student. We want to use a chat room for every course. Teachers teach different courses that include many students and students study different courses, so when the teacher and student open the course...
I have an SQL query which does several things at once¹: it does multiple checks and then, if the checks pass, updates some data. Without entering in the domain-specific details, here's an imaginary example: -- The user password should be updated only if the user account is not removed and -- not locked, and the thresho...
A few times in my past I've wanted to store data in code. This would be data that seldom changes and is used in places where access to a database isn't possible, practical, or desirable. A small example would be storing a list of countries. For that you could do something like: public class Country { public string ...
So I have been building this ORM style library for AngularJS (JavaScript) and since I come from a C++/PHP/C# background, I always try to make sure that private things stay private. While this can be accomplished in JavaScript, I keep running into issues that I have to work around probably because JavaScript really doe...
After reading Applying UML and Patterns (Larman) and looking around on the Internet it still seems ambiguous to me if a UML communication diagram should depict implementation details (such as GUI related function calls) or be more bound to the analysis. What is the correct answer? Does UML even specify it?
So I have a generic framework with a concept of children and parent objects, the objects don't have to be the same type, and I can add or remove any of them. Adding calls add on all the children, and informs the parents, inverse for remove. the concept of Parent is generic enough that there can be a loop across classe...
I have a list of objects that all require the exact same filtering, basically a set of conditionals in a function which outputs if the object is "good" or "bad". I want to keep all of my "good" objects in the list. Lets say I have 1000 objects in this list and the function I want to filter on in written. What langua...
I am working on a CMS that is starting to evolve a bit. We started off with content that had the following priorities ( columnn in the db on the content table): HIGH MED LOW. Data was fetched by priority HIGH being on top etc. Now after a few months a need has risen to have sub priorities: HIGH [ high, med , low ], M...
I was reading this article: Designing Flags Enumerations @ msdn and it says Combining flags enumeration values is an intermediate skill that should not be required for developers implementing common scenarios. I think flags enumeration are awesome - something I learned about during my experience with C. Why does it s...
Before asking my question, I must explain the situation. I'm working for a company as a junior software engineer. One of the seniors always stops me when I have finished my development and want to commit. He always wants me to wait for him to review it. This is ok, because usually he finds some bugs, and does some opti...
I have an abstract class A which declares an abstract method doStuff. Currently there are many classes that inherit from A and implement doStuff. The class' instances are initialized at run-time via AFactory based on user input. Originally all the classes had the same single parameter (the user input). But now I have...
I can see that GitHub allows you to have multiple mail account and associate every organization you are part of with a different address. Can this be done also for SSH keys? What I would like to do is having two different keys, one to push on my private repository, another to push on an organization repository.
When working on code, I face many of the same challenges that my teammates do, and I have written some helpful functions and classes, and so have they. If there is good communication, I'll hear about some great thing someone put together, and six months later when I need it I may remember it and call that function, sav...
I want to know how exactly, we can ensure that a project is 100% tested ? In banking or financial applications not 1% also tolerable. So being a developer, how can you say your code is 100% tested? Explanation with example is highly appreciated.
I work in a team that keeps growing. However, there are no code reviews and I see this as a problem every day. There are people with really limited skills committing code to our repository that I believe should not commit. I'm not the team leader nor am I in a management position. I already proposed code reviews abou...
It seems like Python, PHP, and Ruby all use the name "argv" to refer to the list of command line arguments. Where does the name "argv" come from? Why not something like "args"? My guess is that it comes from C, where the v would stand for "vector". Wikipedia has a footnote that says: the vector term in this variable's...
I'm not necessarily asking if a NoSQL database can be ACID compliant, which has been asked here: Is there any NoSQL that is ACID compliant? I'm wondering if we have a database either now or in the future that is wanting or is another option to a traditional RDBMS? I know NoSQL was supposed to be the big thing and RDBMS...
When I first came to OOP (at first in Java, and then C++) after years of working in C and VB, it was amazing. The idea of extending existing behaviour and operating generically over things of related types was very appealing, and I almost immidiately saw why it was that I wanted this. That is, my motivation for OOP w...
For those who have sold software successfully over the Internet, after going to the effort of writing the software, creating a website, get a domain name, hosting the website, setting up a merchant facility, creating a trial version, etc - what do you do about the legal aspect of allowing the version downloaded from th...
I work for a large bureaucratic (and security paranoid) organisation that provides SVN for its development teams to use. I am working with a 3rd party vendor (at their site) and we currently share code via SVN export and patch files. The only way I have for transferring files is by a FTP drop box or email. I would lik...
I often feel that it would be more convenient if, within an issue tracking system, each issue were attributed to a certain function/method. Then, we can easily list all the issues related to a certain function/method. Many issues can be clearly attributed to a certain function/method. At times, we may want to look at i...
I work in a control systems company, where the primary work is SCADA and PLC, along with other control systems stuff. Software development is not really something the company does, apart from little bits here and there, until there was a decision to create an internal project management and appraisal system. This proje...
I started with sftp, then switched to WebDAV and I'm currently using rsync through ssh to deploy any updates/upgrades from my development server into my production server. I'm still not very happy using this system and think using git to deploy may be better, mainly because of the possibility of rolling back any change...
I am currently a reviewer on a Best Practices document for Developers or Business Analysts in writing a Functional Requirements document. This document is not necessarily a template for functional requirements documents, but a guide to what elements are necessary, optional, and dangerous to include a Functional Requir...
I have a Java HashMap with a String key and POJO value in a long-running application, and it's taking up a large chunk of memory (over 500mb, and this number is expected to grow - I'm guesstimating that it will exceed 2GB in two to three months); this is used to memoize the results of an expensive calculation (typicall...
These days there are more cross programming language compilers (specially from some 'X' language to JavaScript). I wonder how these are developed? What are the general steps to be taken care to write algorithms if I were to develop one? Do I need to be completely thorough in Lexical Analysis? As far as my knowledge is ...
Let's say I have 4 (A,B,C,D) parameters with 3 possible values, also 81 unique combinations. With e.g. orthogonal array, I will end up with 9 test cases, each combining 3 pairs. But that means that if one test case fails, I do not know which combination in the test case is faulty, right? Whether values of A,B or A,C or...
Let's have a program that checks an email mailbox and then "processes" the messages contained there. (For this question it doesn't really matter what it actually does with the message). The program will run once per hour and can easily handle the volume of new messages and there is no penalty for processing a message t...
Can anyone help me think of a way to dynamically generate the patterns section of a tool I am creating? I'm not sure how to store and generate these "patterns" dynamically. What the program does is take a big list of links (100,000), puts them in a database, groups them by domain and then curls a page from each domain ...
I've been thinking a lot about best practices regarding branching in distributed version control systems such as git an mercurial (the two dvcs's I have experience with and use on a daily basis). The way I've been doing it is slightly different in each of these, but generally follows these guidelines: master branch - ...
I hope this is not off topic. I have to save output from a command to file, but only if length of this output is positive. I've thought about two solutions: save output to a python variable, check length, if positive save to destination file; save output to a temporary file, check length, if positive rename to destina...
Please tell me why the same piece of code behaves differently in C++ and JAVA. Ok first I implement a function to calculate the factorial of an Int RECURSIVELY In JAVA: int f(int x) { if(x==1)return 1; return(x*f(x-1)); } System.out.println(f(5)); -----> outputs 120, ok that makes sense. JAVA ...
I'm starting a side project, the first stage will be a building a web application with MVC, in later stages we will be adding clients for mobile platforms. My thought was to create one API that all of the applications (web and mobile) go through to get/save data. Because these different platforms will be on different ...
A customer asked me to add a (fairly generic monitoring and notifications) functionality to the in-house solution he has assembled on top of JBoss and couple of GPL-licensed components (downloadable from the open source vendor as EARs). I am using JMS and JMX to communicate with these components. Do I have to provide t...
The first part of the license implies you can do basically whatever you want with it (copy, modify, sell etc). But the second part says that these freedoms must propagate into all copies of the software. My interpretation of that is, you can incorporate the software into your proprietary project, but that portion must...
I am maintaining a small code base that I am considering selling– but I want to allow developers that use it to submit code for addition to the trunk. This way they can extend the framework and the community can benefit. I want them to retain copyright to their code, but to allow me to use it however I desire, for com...
Sorry for the confusing title of this question, but I can't think of an exact way to word it. I have a very long class with hundreds of similar methods and I am trying to find a way to construct it without so many lines of code and so many DRY violations. Each time I add a new property to my class I have to write two m...
I do a lot of web development and there are many code snippets that come up again and again so I dive back into the most recent project where I used it which isn't that efficient. How do you store all your useful and oft used code pieces? Are there any products meant for this?
In my application I keep track of the running threads via a hash map, in that way I can retrieve the correct thread and do any actions. The app evolved in a way that new threads are created and old threads must be destroyed. My concern is if I'm removing the elements of the hash correctly, or if there's any efficient p...
I very much enjoy the functional programming paradigm, but I am still not sure how to go about designing a small/medium project with it. When using OO, I have a set of labelled entities (classes) with clearly defined boundaries. I can reason about stuff like: what is this class doing? should I put this code inside or ...
I have a Visual Studio solution with multiple projects: Acme.Core Acme.Core.Tests Acme.UI.MvcSite1 Acme.UI.MvcSite2 Acme.UI.WinformsApp1 Acme.UI.WinformsApp2 ... The entire solution is checked-in in a single GitHub (private) repo. Acme.Core contains our business logic and all UI projects are deployables. UI projects ...
Unlike other professions (such as Accounting, Law, Medicine, etc.), there is no profession-wide certification for Software Engineering. I am well aware of the multitude of technology and methodology specific certifications that aim to serve as proof of specialisation and experience, but there is no public Software Engi...
Should boolean methods always take the affirmative form, even when they will only ever be used in the negative form? Say I wanted to check whether an entity exists before creating one, my argument is that the first form below is better than the second form, whether or not the method is ever used in the affirmative form...
I am having a head ache understanding quicksort with middle pivot. I found lot of explanations about using left most or right most, but not many about a middle one. Can I safely assume these?: If left and right pointers meet at the same position, means that the element at that position is at its final sorted position,...
I have two lists of data, A and B. These lists are themselves aggregated from multiple sources, and contain typos, abbreviations not found in the other, and also lack a 1-1 mapping, but will never have a value in A that maps to two values in B and vice-versa. Right now, we're doing a naive (string comparison) match to ...
At the beginning of each sprint our team will pull in a handful of user stories and then, one by one, write slightly more detailed tasks for them as well as assign specific hours to each task. Having individual tasks helps us establish our sprint burn-down by having a specific total number of hours up front, as well a...
I believe that warnings should be treated as errors. If you start ignoring warnings you'll start missing "important" warnings among the "unimportant" ones. So my Continuous Integration system fails a build if there are warnings. One of my compilers has a bug that causes it to raise a warning when it shouldn't. My code ...
I designed an application framework by considering the SOLID design principles and supported by design patterns. However, I wonder if there are any automated tools or well-known approaches to evaluate whether the SOLID design principles are satisfied or violated in the proposed design?
I'm trying to document my code using JSDOC3, that has a similar syntax to PHPDocumentator / Apigen. But is there a de-facto standard for Javascript inline documentation? I think Google Closure is the most complete (or so it seems), but what is widely adopted by IDEs and what most people expect to the docs to be?
I apologize if something like this has been asked, I did try to look for something similar. I am graduating May 16th, and I applied for a position posted as '.NET Application Developer' requiring 1-2 years experience and a Bachelor's in CIS. I had the phone screen, which went well. They brought me in Friday for an inte...
Browser support issues aside, if you're being an Http/hateoas stickler what verbs should the request to log into/out of a site be? DELETE would seem like the obvious choice but I'm not sure what the resource you're deleting would be.
I have a requirement to read a text file with lines in tag=value format and then output the file with specific tags listed first and the rest sorted alphabetically. The incoming file is randomly sorted with the exception of the first line. The output needs the first two lines to always be the same. For example, give...
Is there any possibility to automate/semi-automate deployments of ASP.NET web applications using Jenkins. It can be under controlled or uncontrolled environments, for uncontrolled user needs to enter userid and password. I am looking out for ways to copy the files from target to destination and run sql scripts in web f...
Design By Contract uses preconditions and postconditions of the public methods in a class together to form a contract between the class and its clients. a) In code we implement preconditions and postconditions either as assertions or as exceptions? b) We implement preconditions and postconditions in code as exce...
My goal is to have a Python application that runs a web server which hosts the user interface, and based on interactions from a user in their browser, long running tasks get kicked off and through some process, feed status information back to the web server and subsequently back to the browser. The application will not...
Recently, a colleague told me that it wasn't advisable to make conditions in the join clauses. Instead he suggested to make conditions in the where clause. He told me that the SQL engine was optimized for this way. Here is a simple example to illustrate my question. In this case, I think it would make any difference. W...
I'm writing a PHP API wrapper for a third party API. I want to make all the methods consistent, but I'm not sure how to handle the number of arguments some API routes accept. One API request accepts up to 30 arguments. Obviously, it would be unwieldy to list each argument as a parameter on the method. Currently, I'...
I'm not so hot on the maths for this but for what I understand... A graph g exists with v vertices and edges. g = (V,E); The spanning graph for this is an acyclic copy of this where all the vertices are present, and all the edges are a subset of the graph with the condition that each connection is distinct. Apparently ...
Please excuse me as I am a bit new to the following technologies and practices. I have been given the task to create a management suite utilizing an MDI GUI. This suite will be the front end to a WCF data service. My question is, what design pattern is typically used by most professionals when designing such an appli...
I am working on an application that connects to another application (Quickbooks) using an API by sending/receiving XML requests/responses. I am able to work with the data in the XML response and load it into a datatable in c#, so that's not the issue. What I am looking to do is write the data from the Quickbooks XML ...