instruction
stringlengths
34
19.9k
Seems like an odd question, but I've been questioning this myself for some time now. I've been told that, if you're working on a open source library/project, you should avoid adding dependencies for other external, open sourced, libraries because that'll make the software, that uses your libraries, become heavier with ...
I have recently learned about the MVC design pattern. I'm learning from the Head First Design Pattern book. According to this book (if I understand correctly): The Model is most of the application logic and data. The View is basically the GUI that represents the Model visually to the user. The Controller is responsible...
I have a db design question that I am sure has been quite extensively covered but I cannot find a good answer already. The problem is how to efficiently link a single school course to a collection of textbooks, a course may have 0 books and it may have 10. The problem here is that multiple courses can use the same tex...
When child processes are created using the fork system call what is there scheduling priorities..are they same? if so will always a child process run first and then parent...or is there a manipulation to this pattern. I have a implementation which apparently is running the parent process first. Is this expected?
I'm using Bitbucket for a few projects, but as of April 28, 2014 they will replace their End User Agreement with a new Customer Agreement. The new agreement mentions in 7.7.2: "You will not submit to the Hosted Services ... any personally identifiable information" One of my projects clearly contains such information, a...
If somebody starts an open source project (for example with a GPL license) where people will make contributions, than who will own these contributions in the level of the whole project? Will the new code become the property of the original author or the contributors will be authors too? Who has the right over the ongoi...
For keeping the "Administration Panel" secure to those who are logged in, for my web application, is the best practice to use an If/Else Statement? if($_SESSION['logged_in'] == true) { include '../styles/templates/admincp/header.php'; include '../styles/templates/admincp/content.php'; include '../styles/templa...
I have the following program: Iterate x from 1 to N. Check to see if x is prime. If it is, add it to a list of primes. The way I check to see if it is prime is iterating through the current list of primes, and seeing if they can divide x evenly. What is the order analysis of this program? I don't think it is O(n^2),...
I am running a program that is supposed to solve a problem with the brute force approach. My computer has a quad-core CPU. When I run the program clearly java uses only one core, because in my program I use only one thread. Is there a way to split up the program in more threads so that more core's are used and so to ...
I'm currently reading about database schemas about how the three-level ANSI-SPARC architecture works and i'm a bit confused about a concept it's talking about. My question is what would happen if an application was modified so it could store data for a column not defined in the logical schema? The book i'm reading ta...
I have several private projects that I might be needed to show to my prospective employers. I haven't uploaded them to any online version control system because not only do I not have the patience to filter the many many licenses available and choose the most appropriate one (as I am not yet sure how I would want my op...
Lets take some random internet site which i am not aware of any API it exposes for it's web services if there are any , is there a way to query that URL for exposed web services ?
I'm wrestling with some code and I think I've finally gotten some state pattern code working with my events. I've got a simplified system that will work like this: This is my first go with State Pattern code and the examples I found were too simple or just not related to my type of device. Q: Is the context class supp...
I come from a Python background, so I'm used to pretty automatic test discovery. For example, the py.test library automatically locates any files which begin with test, finds classes whose names start with Test inside of the those files, and then calls all the functions whose names start with test_ in those classes. Th...
I'm wondering about a good way to deal with a Question/Answer - Model for multiple Users. My goal is to have an efficient and readable model where all the results of my users are stored. Every user has the same questions/answers! At the moment I have three classes, Question,Answer and User. A user has a Set of Questio...
In a recent project; I used MongoDB with MongoEngine (an ORM/ODM for Python). This allowed me to specify schema in a central "Model". My new project I am hosting on Windows Azure; and there is no non-SQL based ORM/ODM wrapper for it in Python. How would you recommend I proceed: Engineer my own Python ORM/ODM for Windo...
I put in this code which does what it's supposed to do, but perhaps there is a better or more general approach? I'm converting a 4-digit base 10 number e.g. "11" to base 16 e.g. "17" (which gets written out on the display as 11 when called with 17 because the function takes bits as argument). int hex1 = perhapspri...
I was following a book Art of Unit Testing, This book says that You must not have any logic in Your asserts as this reduces readability of test, or I may be testing too many things at a time. Suppose there is a method with signature as below: public int DoSomething(int variable1, out string variable2, out float variabl...
By suggestion in comments, I'll try to rephrase my question to better reflect my problem: I have to present users (few at first, as many as possible later) with a website. There they will be able to browse various data. The data will be served from a local "cache" db. Users should be always presented with data as fresh...
I am trying to solve a outdated quiz problem. I am tasked to find the smallest and largest contiguous sequence of repeating numbers in a larger sequence.e.g. {1,3,6,17,19,3,6,5,4,2,5,6,17,19,3,6,7,5,78,100,101} For the sequence above, the smallest (non-zero element sequence) and largest non extensible sub sequence wo...
While many higher level languages have bitwise (exclusive or) and bitwise (exclusive and), for instance C, C++, Java, etc. I'm curious why the ( vastly more useful ) logical short-circuit operators don't have this functionality? Is it simply due to the capacity of being able to concatenate logic through use of "not"? ...
I like to give lots of context, but also to state the basic question up top as concisely as possible. Feel free to read a little or a lot. I'm working on a music sequencer, and have been happy so far to be using a publish/subscribe approach to help decouple the major components of the application, which has helped test...
Is the Model-View-Controller pattern very strictly defined, to it's design details? Or is it a term, like many others, with lots of different interpretations and versions (that all fit the definition)? I have come across many 'versions' and interpretations of the MVC term. For example: Some versions state that using th...
In my database, I have a column for the hashed password and the salt. My application allows users to change their password. Should I use the same salt for the password, or should I generate a new one? Does it matter to the security of the application?
In a software I use records of measurement data. Each record contains basic information like a name, some parameters and the actual measurement data in the form of three arrays of double values that may vary in length from record to record. I currently use a binary format to save these records. However I am not entirel...
I completely understand the Observer design pattern, what it is for and how to implement it. I also understand what the term 'loosely-coupled' means. But I'm not sure how Observer makes designs more loosely-coupled. For example, let's say I want objects B and C to get updates from object A about it's state. The Observe...
I read everywhere that referential transparency and side-effects are mutually exclusive for all functions, however, what about the case in which a function changes some state that has no effect on its outputs. For example: global_variable = 0 def foo(a,b): global_variable += 2 return a + b # Other code ... N...
I'm designing a system, and it needs future expandability for the use of a permission system of some kind. I'm wondering if the flyweight pattern would be a good choice to implement this. I'm not responsible for the implementation right now, as it is just a prototype, and we're not prototyping any parts that need the r...
I'm working with web development since 2009, when I started with PHP. When I moved to ASP.NET, I've heard a lot about DDD and OOAD where a lot of focus is given to this "business logic" and "business rules". The point is that all the apps I've developed until now were all about CRUD operations and I've never seen these...
What makes CPU cache memory so much faster than main memory? I can see some benefit in a tiered cache system. It makes sense that a smaller cache is faster to search. But there must be more to it.
I have to continue feature development, issue fixing of a halfway completed code base. There is a no documentation, all developers had left the company. The technology stack is somewhat familiar to me (Spring, Hibernate, Web Services (Rest, SOAP), MySQL). Also there are non descriptive JIRA items that the team had work...
I have a RESTful API that allows retrieval of data through requests such as GET http://example.com/users/id/1 (Coded following this tutorial). The code igniter controller looks like this: class Example_api extends REST_Controller { function user_get() { $data = array('returned: '. $this->get('id')); $this->re...
I want to publish a small open source project on GitHub. I'd like to release it with either MIT or Apache license. The project has unit tests that use JUnit library. JUnit is released with the Eclipse Public License v1.0. JUnit is not distributed in the project - it is downloaded and used at build time by Maven, the b...
When is it beneficial to use encodings other than UTF-8? Aside from dealing with pre-unicode documents, that is. And more importantly, why isn't UTF-8 the default in most languages? That is, why do I often need to explicitly set it?
My .NET Windows desktop application creates an HTML report, and has 3 main phases. It may create multiple reports. I show a progress bar so the user knows (estimates) how long it will take (as well as reassure the system didn't crash by an updating GUI). So, if I needed to generate 3 reports, there would be a total of ...
While developing an application (mobile app for Android), our team always strives to use best development practices such as interfaces, layering and separation of concerns. When it comes to reporting analytics events from our app, the requirements sometimes force us to send events with data that is stored and managed b...
I've heard a lot of the repository pattern, but I quite didn't understand what a repository should really do. When I say "what a repository should really do" I'm mainly concerned about which methods it should provide. For instance, should a repository really provide CRUD methods, or should it provide some different kin...
I am refactoring legacy codebase. Part of it is a loadProduct() function inside a larger "everything" class. loadProduct() loads data from a database. I want to move this loading-data part out of the larger class, because I do not think it belongs there. I am not sure exactly where I want to move it yet, but I thin...
Reposting here... hopefully the better place to seek opinions on the matter. :) Writing my own log4net wrapper class using C#. I want to create a lib such that I can reference it from any project/assembly in a given solution with a minimum of effort. ie: include the reference, maybe throw in a using statement and then...
I am a bit confused about the nomenclature for the parts of an if statement. Consider the following example: 1: if condition then 2: statement_1; 3: else 4: statement_2; 5: end if; What is the "if clause" in this statement? Here are a few possibilities: Is it lines #1 and #2? Is it line #1? Is it line ...
I'm working on a python program which organizes a music library. The program will basically help me detect misspelled file or directory names, wrong FLAC tags or unknown/superfluous files. It will also make sure that the FLAC files are named correctly according to their FLAC tags etc. The structure I though of looks as...
I have a REST architecture, running PHP on the server side which store and query a Mysql database. I am re-evaluating one architecture design decision: DECISION to re-evaluate: In an attempt to avoid back and forth communications overhead between PHP and Mysql: For some browser requests (for example: 'GET /sessions/4'...
I've recently learned of MVC (model view controller) and am trying to refactor an existing program. I am in a situation where I'd like to have exactly one object of a particular class so it seemed evident that I should use a singleton. This singleton will be used to keep a hashmap of certain things. However this has...
I'm getting into ReactJS and am intrigued but also confused about persistent data structures. I love the idea, but I'm not sure how to take my MV*, Mutable, Observable Bindings experience in designing view components and apply it in a sane way. For example, suppose I have a deeply nested structure: Foo Bar Baz ...
I asked this question once here, but believe the question was unclear. However I'm having a hard time extracting the general problem from my specific case. UPDATE: I've answered my own question below. Read on if you like reading stuff. Maybe is educational, maybe not :) I'm writing a music sequencer. Some existing com...
I am responsible for the design and development of a cloud backup application. Currently we are using xDelta to do differential backup so that only the changed parts of the files gets uploaded. This cuts cost for both us the company and the user. One issue we are having with this approach is that in order to do a diffe...
I'm using view classes for my templating. These view classes often require the Routing class to get URI's from other pages. You could actually say that the Routing should be available to every view class. What I'm wondering how would you deal with the dependency injection. Injecting it through the constructor would mea...
I read the Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation book by Jez Humble and David Farley. The part that throw me off balance the most was their insistence on using a single branch. Thinking about it and what they are preaching, it does make sense. But the question is...
I'm a web developer and I'm currently once again in a situation where a partly clueless ops department requires a "complete" documentation required for technical support of our application by a third-party, including "every possible error situation". Since there is no common ground on what this third-party should be ca...
What kind of use case it would be for to "show ad in part of the view"? Who could be the actor to relate with? User or System? As user has no specific goal to see ads, i am wondering what is the best way to capture this in use case diagram? Any assistance will be helpful
I just wanted to clear up a question I have. What is the point of having a private static method as opposed to a normal method with private visibility? I would have thought an advantage to having a static method is that it can be called without an instance of a class, but since its private is there even a point to it b...
The situation: System A Huge, complicated system. Uses an important Message object with many other Message objects attached, many of which have further Message objects attached. In total, this is about twenty different objects. Due to awkward timing with releases and introduction of code churn, System A cannot have i...
I'm still learning to be good about doing unit level testing, as I've always been a little sloppy about only doing functional testing in the past, so I want to double check I'm doing this 'right'. I have a package which is responsible for auto-magically updating a particular configuration which is expected to change re...
I frequently find myself wanting to use some small function from another library but end up not doing because it's not worth pulling another dependency. Considering BSD/MIT licenses, if I just copy/paste a function from another package, what would be the legal requirement when licensing my code? Also, as matter of neti...
While I know in a perfect world where a greenfield application was scoped out from day one with great BRD's and a competent development lead constantly reviewed code by their underlings to avoid this, I'm going to ask because we all know and have all been a part of plenty of scenarios where this isn't the case... and t...
I'm refactoring a big-scale ASP.NET application written with WebForms which has a very unflexible design of view+code-behind. For this refactor, I'm using MVP Architecture (Model-View-Presenter), which uses a Page Controller approach for pages and controls. Writing a controllers for pages, I've faced a problem of reusa...
In my project we are trying to build up a KIND-of-a-lambda storm based architecture. The component would be responsible for indexing the site usage events so we expect a quite massive random load. The solution for real-time processing of the messages seems fine, but in parallel to the "speed layer" we want to back up t...
I read that virtual calls make the code slower than calling non-virtual ones in C#. However, the IL instruction for both are the same callvirt except in cases where base.somemethod() is called. So how does virtual method hurt performance?
I see a lot of APIs that use custom collections instead of just using strongly-typed packaged generics. For instance, the API will have a Object1Collection instead of just a List<Object1> (or whatever the appropriate generic would be). When do you know to use one or the other? I understand you'd create a custom collec...
I have a RESTful API, built in NODE.js that does what you would expect it to: consumes data and then makes it accessible. Currently, data being submitted to my server is nested form data: data[0][username]=... data[0][email]=... data[0][phone]=... ... data[12][username]=... data[12][email]=... data[12][phone]=... or a...
My employer uses forms to help people search for products. The product lists can change from time to time and the forms need to be updated again. The product information can be accessed through a third party API which I started tinkering with, I've recently built a script that retrieves the information with PHP and cr...
I would assume that instances of the same class would actually share their methods, and just have save different attributes in their namespace. How often do you arbitrary add methods to a single instance? Yet for example in Python that's not the case. Instances' methods are all different objects. Even if you decorate ...
I use to compute primes using linear code which took a long time. As I've an 8 cores processor I thought about multi-threading. At first I use to put a huge number of int in a vector then share the vector between the threads which takeout each number which is not a prime. The first thread processed the 1st/nthread par...
For my A2 Computing project I have created a game using Visual Basic. For the leaderboard section, I have used the My.Settings feature to store the scores when the game closes, but only one or two actually save. My teacher doesn't know and I can't find anything helpful after a google search of the problem
I am developing a small open source project. The application uses many third-party libraries released with a range of licenses: Apache, MIT, BSD, LGPL and CDDL. Each of these licenses has its own “paperwork” requirements. For example, the Apache License, v2.0 says: If the Work includes a "NOTICE" text file as part of ...
I am dynamically loading an MPL 2.0 licensed library to use some of its exported functions in a feature. My code does not distribute the library, it simply detects it's presence on the system and uses it if it's available. I also browsed the library's source code to extract the function and certain type definitions. Wh...
I use SQLyog Community edition and like many other SQL applications out there it puts a 1000 result limit on queries that do not have a limit provided. I am wondering why MySQL doesn't have an explicit NO LIMIT option when it comes to writing queries. I'm sure that i'm not the only developer that ends up sticking a lar...
The basic idea behind OOP is that data and behavior (upon that data) are inseparable and they are coupled by the idea of an object of a class. Object have data and methods that work with that (and other data). Obviously by the principles of OOP, objects that are just data (like C structs) are considered an anti-pattern...
We have some requirements to send emails when various field values are changed in our system. It's an asp.net system using linq to sql with javascript/jquery. Is it preferred to check if a value is changed via js (hidden field is set if the value is changed) or is it better since we are using linq and I have access ...
I have employed a recursive call to a closure in order to mitigate against some race conditions I am getting (That's what I think it is). I'd like to know if (and why) this is a good solution or a bad solution. function getResources(activity, resource) { var q = when.defer(), resourceQuery = constructSelection...
I've built a set of what will be server-side programs in python. Essentially they crawl the net and index news articles. The iOS mobile application will be what the user interacts with. So it needs to query the server somehow to get the results back. I.e. if the user types in 'Google' or 'GOOG' it will return news arti...
Should performance tests be instrumented by build tools as part of the build process, or should they live completely outside? If outside, then where in the deployment pipeline should they live? I currently see performance tests being attached to integration testing lifecycle phases. While it's fine for now, I know thi...
When using gettext or a similar framework, should the translation strings include ':' (like "Label:") for generating labels for UI or should I add ':' in UI code itself?
After reading about the HashLife algorithm, I found that it runs in O(log n). The Game of Life is also Turing Complete, so in theory we should be able to run any algorithm on a "computer" constructed in GoL. As a consequence of HashLife's time complexity, could algorithms run faster? e.g. if an algorithm takes 10 secon...
Say I have this code: Design { public function load() { $this->loadProduct(); $this->loadService(); ... } public function loadProduct() { try { $this->product = new Product(); $this->product->spec = $this->product->loadSpecs($this->a, ...
We follow pair programming in our company and always face the issue of balanced and effective pair rotation within the developers on stories. We follow a simple metrics in which every developer's name is mapped with every other developer and we mark the respective intersection whenever two developers are pairing. This...
I have a website that stores all users in a database. A user can log on to the website and if they have sufficient privileges can add/delete users, as well as change their privileges. How do I ensure there is always at least one Administrator (to create/edit/delete users) in the system or that an administrator can easi...
We are evaluating and setting up Continuous Integration for our PHP project. Each of the Continuous Integration tools has their own proprietary "build language" which will run many commands and check the return status of these commands. Here is an example of a .travis.yml configuration: language: php php: - "5.3" ...
I solved my problem by using simple nested loops and comparisons but I'm wondering if there is a well known Selection Algorithm to solve my problem. Let's say I have an array such as [1, 10, 250, 9, 8,8, 249, 249, 248, 247, 2, 4, 9, 10, 9, 7, 6] I need to find subarrays [6,7,8,9,10] [8,9,10] [247, 248, 249, 250] Suba...
Background I am coding two closely related Java projects. The first project is Single Facility Simulator, which simulates a very simple supply chain with a single facility. The second project is Supply Chain Simulator, which simulates more complex supply chain networks, i.e. multiple facilities arranged as a graph with...
I have been trying to use classes that implement ActionListener to respond to user input. I'm consistently noticing that for an action listener to communicate the event to other objects, it has to contain the object. Like, The object I want to get updated when action_src is clicked: public class Display_Field { ...
I'm trying to find the best patterns for javascript usage in my sites, and in doing so I tend to look at source code at some sites (meetup.com, facebook.com, etc). One thing that sticks out at me is the fact these sites seem to compress all of their javascript and place it in the actual page rather than using a <scrip...
I'm going to use a language-agnostic description of monads like this, first describing monoids: A monoid is (roughly) a set of functions that take some type as a parameter and return the same type. A monad is (roughly) a set of functions that take a wrapper type as a parameter and returns the same wrapper type. Note ...
Recently, I found multiple GitHub repositories that would allow me to perform the same task. (In my case, assess the readability of text strings.) It made me wonder, what are the best practices for programmers to choose between different open-source libraries, and in particular, libraries hosted on GitHub? GitHub stat...
What would be the best design pattern for this problem: I have an Object A. Object A can either be registered or deleted from the database depending on the user request. Data validation is performed before registration or deletion of the object. There are a set of rules to be checked before the object can be registered...
Do the message being passed between objects in Sequence Diagram match with the methods in Class Diagram?
I'm doing this one anonymously. Our company manufactures some kind of machines and also has a software department, which I'm part of. Our philosophy is mostly to have in-house software and components of the machine instead of third-party where reasonable, so we can quickly implement customer requirements. Most recent...
I have 2 applications one is written in C++ and one is written in Java. the applications communicate by passing byte arrays which represent a serialized object. each communication object represent a Command and holds the command id and the associated data. I will use an example to describe my problem. Let's say I have ...
I have a project which involves collecting config data from windows servers in our (very large) server estate. My manager wants me to collect over 150 data items across all configuration areas including network config data, disks, registry values, BIOS version, dll versions, you name it. The server support team current...
I've had a few programming jobs in the past where I was the only developer working on a project. After I've left, I typically get several emails a week from these companies, usually from the developer(s) who's replaced me there. These emails are usually asking for details about how things work and how I'd best go about...
I am currently working with an "interesting" code-base and see the following type of thing alot in the code. public Object doSomething() { Object obj = new Object(); // Do some stuff to the object obj = doSomthingElse(obj); return obj; } I always feel when looking at this kind of code that it is...
I'm using Features to document the features as we originally communicated them to our client at proposal stage. I now want to create User Stories that relate to the features so that I can easily map our stories back to the proposal. Many of the stories naturally map across features, but Team Foundation Server (TFS) do...
Yesterday I was discussing with a "hobby" programmer (I myself am a professional programmer). We came across some of his work, and he said he always queries all columns in his database (even on/in production server/code). I tried to convince him not to do so, but wasn't so successful yet. In my opinion a programmer sho...
Does the variable used for iteration in a foreach loop have a more specific term than simply 'the foreach variable?' Especially to differentiate it from the collection variable? E.g. item in foreach (item in collection) Edit: Loop variant was suggested (wiki): In computer science, a loop variant is a mathematical func...
The application we have in mind is a relay server. The aim is to accept large numbers of incoming socket connections (at least thousands) that will stay open for lengthy periods (hours or maybe days). They will exchange modest quantities of data and they need reasonably low latency. The technical design is straightfowa...
I've developed the standard ELO implementation that can be found here, but the problem I'm running into is that my players will only have between 10 and 40 games in a "season". Since my first season has already completed (I'm just now starting my OWN rating system for my game), I know what the rank of my players ELO ra...
I'm asking myself a question to code the right way on a new fresh project. I have a designed database and I mapped tables to equivalent POCO classes using Entity Framework 6 Code First. Then, I thought "wait, if some day I want to switch from EF to another Framework for whatever reasons, or even say let's go for direct...
I hear that Abstraction is a technique that helps us identify which specific information should be visible, and which information should be hidden. Encapsulation is then the technique for packaging the information in such a way as to hide what should be hidden, and make visible what is intended to be visible. I unders...
I'm a self taught PHP programmer. Because I have no formal training in PHP, I often find my coding style to be considerably different than example code I find on the Internet. I've slowly started adapting some of the more common practices I find. However, before changing my habits, I try to find a good reason to use th...
When working with a single object there are a number of ways to segregate interfaces to it. Breaking it into smaller components that can be treated independently. Breaking it into simpler interfaces. Both of these seem challenging to do with a tree. I think it would be nice to be able to do the following. class Node...