instruction
stringlengths
34
19.9k
I am developing an app that will use the Twitter and Facebook login APIs exclusively. Suppose a new user downloads the apps and is presented with the option to log in through Facebook or Twitter. The user chooses Facebook. I think the procedure at this point is to a) create an auto-generated user ID in my Users table ...
I've got some code I use to take regular screenshots of my screen - it's useful to work out how much of any given day I'm spending on various activities. It looks like this: /** * Code modified from code given in * http://whileonefork.blogspot.co.uk/2011/02/java-multi-monitor-screenshots.html following a SE * quest...
class Vector { public: Vector(int s) :elem{new double[s]}, sz{s} { } double& operator[](int i) { return elem[i]; } //function 2 int size() { return sz; } private: double∗ elem; int sz; }; Code snippet from : the c++...
I'm trying to design a web app with ability to scale but can't wrap my heads around few concepts. I want to design it right but im not a experienced programmer, i have more of a system engineering background. Basic architecture look like this: Web Server -> File processing server -> NoSQL DB -> Search server So the mai...
It's very common to see Javascript bound to certain selectors to find elements, store data, and listen for events. It's also common to see these same selectors used for styling. jQuery (and its selector engine Sizzle) support and promote this by referencing elements with CSS-type syntax. As such, this technique is part...
(Upfront, I'm not a test or agile expert, just trying to push us to be better. If I'm wrong on anything I'd love your guy's opinions). So I've been pushing for us to become a real agile shop and less of a "calling ad-hoc agile" shop. So I'm iteratively trying to improve our process. I've found that its been good to slo...
When I create PHP projects, is it better to put all database (e.g. MySql) queries in a single file (i.e. "queries.php")? Or is it better to place the respective queries in any "model" classes (i.e. User.php) that I may be creating? Is it bad practice to put database queries anywhere in any PHP file? In the queries.php ...
First, here are a couple of related, but not-quite-the-same questions: Should I include dependencies for which I have the source as projects in my solution? https://softwareengineering.stackexchange.com/questions/35052 Now on to my particular question: I'm building a small JavaScript library. If run within certain ol...
So I'm trying to push for more automated testing in my company, which focus a lot on prototype and proof of concept systems. We currently use Google Test for unit testing. This tests specific test cases for correctness, but a lot of the stuff we do the metrics for how the code is performing follow more of a "does it w...
In this database I have "accesses" - each access can have any number (usually less than 4, sometimes as many as 15) attributes. I also have "tickets" where N users are requesting M accesses, so I've got a sub-ticket table with the NxM "user access requests". Then for the sub-ticket, there is another table with the A at...
I’m doing a thought experiment about making a product on top of Linux. I’m wondering: If you make a custom window manager (akin to KDE, for example) on top of X and you release it, do you have to release it under the GPL (Linux) or MIT (X.org)? Or can you keep it closed source?
I'm not too experienced in the regard of configuring IIS/ASP.net. A client has asked me to extend the functionality of a custom web application I didn't develop. Unfortunately, they don't have the original Visual Studio project/source code. I'm trying to pull the application off of their production IIS server and confi...
Can a webservice be written in such a way that it can be called via just a browser url? For eg. if the webservice is called GetStockQuote, then it should be callable by the following url on the browser http://myserver.com/WebServices/GetStockQuote?sym=MSFT Likewise, if there are more params, they can be passed via the...
How to distribute, one virtual token to each person in this world, and make sure nobody gets more than one? In other words, how to prevent a user from creating more than one user account in a site? What's this problem called? Is there any specific name to this problem? What are the solutions? Thanks.
In a program I am writing, I have 3 different ways to store user generated data: (a) XML Files for each object (.Net Serialization) (b) SQL Database (MSSQL) (c) Massive terrifying blob of data in 1 file (I'm against this one) There is absolutely no theoretical difference in performance or file size in this (hypothetic...
We internally use GitHub Enterprise and Jenkins. If I push on the main repository it is automatically build without and the Commit is marked as correct (just as Travis does this). However, I want to be able to fork a repository and let the Jenkins build run. Is it possible to say Jenkins that he also runs any fork of t...
In his talk TDD, where did it all go wrong, Ian Cooper pushes Kent Beck's original intention behind unit testing in TDD (to test behaviours, not methods of classes specifically) and argues for avoiding coupling the tests to the implementation. In the case of behaviour like save X to some data source in a system with a ...
In Android source code, we see files like MODULE_LICENSE_APACHE2, MODULE_LICENSE_BSD_LIKE, MODULE_LICENSE_W3C. An outside observer would think that these specify the intended license that applies to the source code tree where this file resides. Take the JSON module, for instance. It has an empty file MODULE_LICENSE_BSD...
I am considering the creation of a fork to a small project licensed under GPLv2, and I have some very specific questions I did not manage to answer in my research on various sites and forums. When I fork the code, I am forced to release the new project under the same license (GPL) as I will do, but could I also decide ...
I always separate the user interface from other functionality in my programs - its the way I have been taught, and it has obvious advantages since you can change the interface but keep the same functionality. However, I've come across some programmers who strictly separate data, algorithms and interface. So the data o...
I'm working on an ASP.NET Webforms project, using the MVP Pattern (which the presenters as you may know use a Page Controller pattern). I'm given a rather complex inheritance chain for my controllers. Below I depict a small example of the structure I'm facing (it is way bigger structure in my app): A lot of code among...
In Java, the Swing library implements the Observer/Subscriber-Publisher design pattern to design the way the program responds to events on the GUI (button clicks, etc). The programmer registers ActionListener objects (the observers) to a GUI element (the subject/observable/publisher), and these objects get notified by ...
I have the following class with the following members: public class RegistrationPresenter : EPiPresenter<IRegistrationView, LoginPage>, IDisposable { private readonly static string[] DefaultUserRoles = { AppRoles.RegisteredRole, AppRoles.EveryoneRole, AppRoles.ManagerUserRole }; private readonly INavigator nav...
I am writing a C++ library (but prefer C style interface functions) and one of the function returns array of floats. I am not sure if I should pass pointer or fixed array to get this data? // in the library header file #define MAX_ITEMS_SIZE 1000 int getData(float * data, int &size ); or int getData(float (&data)[M...
I am making a game and have been following examples which use the MVC architecture pattern. I am now trying to get my head around how this would fit in with a 3-tier architecture. From what I have gathered so far: MVC and 3-tier are separate ideas and are compatible MVC has a triangular communication structure, wherea...
I have 3 classes: a JButton extension, FButton; a JTextField; and a JPanel extension, FPanel, that would contain one instance of both. The FButton is supposed to open a file, and make the file name and directory for the file available. The JTextField is meant to display the file name and directory provided by FButton. ...
Assume a simple SPA (Single-page application), maybe a dashboard and these basic conditions: The Model contains methods for accessing and displaying data; The View contains methods to load templates and apply model.data to template; The Controller manages the user commands; The Router handles the navigation; In ou...
A question similar to this has been asked before, and will be asked again I am sure. I have spent some time googling and trying to work this out for myself, but I am at an impasse. What I am trying to achieve is to implement a database search screen for an application I have been tasked with creating. What I am doing ...
It seems to me that the Boolean class is an ideal candidate to be implemented as an enum. Looking at the source code, most of the class is static methods which could be moved unchanged to an enum, the rest become much simpler as an enum. Compare original (comments and static methods removed): public final class Bo...
I am building a pair of components that communicates in a one-way fashion: [ JButton ] --> data...process...process...out --> [ JTextField ] The JButton allows the user to select a file and the JButton's ActionListener picks up the click and pulls out the file name and directory. I then need that information to be di...
Consider the following situation: One hardware device, two applications (1 C# application, 1 Firmware). The C# application sends frames to the firmware and the firmware executes scripts. C# -> transmit frame[x] FW -> receive frame[x] FW -> execute script relating to frame[x] FW -> before finished, a FW event is trig...
I have very little experience working in a big project. But I did work about 3 months in a small outsourcer (a company that do the coding for a bigger foreigner web development company). This is what I saw. The foreigner company did all the user analysis & all database designs. Then a group of the Project managers in t...
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...