instruction
stringlengths
34
19.9k
I'm designing a pragmatic REST API and I'm a little stuck on how best to add existing entities to a collection. My domain model includes a Project that has a collection of Sites. This is a strict many-to-many relationship and I have no need to create an entity that explicitly models the relationship (i.e. ProjectSite)....
So, I've been reading the AGPL and here is my understanding (not being a lawyer and I'm not trying to look at it through the lens of "Since I WANT it to be ''free'', it therefore is.". In my case, I am considering the use of itext, an AGPL library, to crack open PDF files and extract the text - that's it. There will b...
I'm developing a site to monitor web services. The most basic type of check is sending a ping, storing the response time in a CheckLog object. By default, PingCheck objects are triggered every minute, so in one hour you get 60 CheckLogs and in one day you get 1440 CheckLogs. That's a lot of them, I don't need to store...
I'm trying to follow the single responsibility principle (SRP) in my applications. I have lots of CRUD classes I just name xxxxxManager. Following the SRP, I made 4 classes for each one : xxxxxCreator, xxxxxGetter, xxxxxDeleter, xxxxxUpdater They end up having only one static method : xxxxxCreator::create(Model $model)...
I really like programming simple things, like solutions for Project Euler, where you can concentrate, write an algorithm, instantly execute, test, verify and change the program until it works. Even for bigger projects I feel I can maintain flow and be very productive as long as I can stay in one IDE (e.g. Eclipse) and ...
The typical programming designing method that I've come to use goes like this: 1. ID the problem and what's required 2. Make your program do something simple 3. Test it 4. Make your program do a little bit more 5. Repeat 2 until all the micro problems are solved by the program as a whole Basically, incremental design....
Two common phrasings for the Single Responsibility Principle (SRP) are "each module should be responsible for a single feature or functionality in a system", and "each module should have only one reason to change". My questions is: is this something that we should absolutely strive for in every class of a system, or sh...
At the office we just got out of a long period where we released patches on a too-frequent basis. Near the end of that period we were doing almost three patches per week on average. Beside that this was very demotivating for the developers, I was wondering what the customer would think about this. I asked the question ...
Let's take a server-side WebServices app, we need to make sure that all function applies every security rules, and keep the code clean. In such a case, I usually prefer to place my security checks on the upper layers. As soon as the user call a function, I check if he has the rights to access it or not. But this strate...
When one says "a class' interface": Does he/she refer to all of the get and set methods - or do they refer only to the methods' signatures and return types, without the inner implementation of these methods? (Aka, the implementation of a 'get' method isn't considered part of the interface, but rather part of the inner ...
Context I am (part of team A) developing a piece of functionality which depends on new APIs provided by team B. Old APIs (also provided by Team B) are there and this is how they are being used in our code... int someFunction() { //-- lots of code here oldAPI.func1(); //-- lots of code again if (something) oldA...
Should I always use is as prefix for boolean variables? What about booleans that indicate something in past? Should I write isInitialized or wasInitialized? Should I write for properties IsManyMembers or HasManyMembers? Is there any best practices? Or I should just write in accordance with English rules?
When is recommended to use read-only properties -- if the language allows me? Are public read-only properties meant to replace getter methods or at least the Magic Methods like what is available as __get() in PHP for example? What is the use of a private read-only property?
Is it acceptable to model a very complex object graph using XML in the database, but leave the rest of a system in relational tables? I'd like to gauge opinion on this as I've hit a bit of a conundrum. Many thanks -------------------- Background I'm building a financial application which, although not at all large in t...
We are going to hold a meeting where everybody will speak in clockwise direction around a table. There are n people with n spots. Each person has a position preference (e.g. some want to go first, some last, etc). Everyone is seated randomly and cannot move from their position. How shall we compute the best starting po...
I'm reading about dependency injection (DI). To me, it is a very complicated thing to do, as I was reading it was referencing inversion of control (IoC) as well and such I felt I was going to be in for a journey. This is my understanding: Instead of creating a model in the class which also consumes it, you pass (inject...
In our company, we are only two IT staffs, and I'm the only developper. I'm developping rich intranet applications using plain php and extjs as javascript framework. Our development cycle is usually very fast, such that often people are using tomorrow what I develop today. This is possible through an automated build sc...
I currently have a test class with a setUp method for creating a temp file and a tearDown method for deleting a temp file. However, only some of the the test_ methods in that class require this functionality. Is possible to either ignore those 2 methods for the test cases which do not require it or to only call those 2...
I have multiple sets containing integers. An integer maybe present in one set or multiple sets. I would like to find/match the sets with the most common integers. Example s1 {1, 2, 3, 4} s2 {1, 3, 4, 5} s3 {6, 7, 8, 9} s4 {1, 6, 8, 10} In this case, I would like to "efficiently" group s1+s2 as they have the most overla...
I am working on project on which I need to open-source part of my code in order to simplify extension by the enduser. What I want, is to make an npm module, that will expose part of my code, so my users can build extensions for the product (in JavaScript), but I want a guarantee that this code will not be used for comm...
My scenario is as follows: Web application, run from the browser, designed for mobile devices. Uses WebSQL storage which may contain sensitive data. Uses Application Cache to enable offline use where there is no connectivity. Can connect to an API where even more sensitive data can be downloaded. Authentication is han...
Knowing that C# doesn't support multiple inheritance, is it considered bad form to write a utility base class? Some initial thoughts: I could create an interface and a concretion, but then the implementation isn't portable Should the developer need to extend the class in say, a decorator pattern, they could implement ...
As part of my workflow, I need to do all these steps in one transaction - I need to ftp files to 2 different FTP servers. - There is also a spreadsheet that gets generated which needs to be FTP'ed. Can this be streamed, instead of downloading and then pushed to FTP server. I am using Ruby Net::SFTP and Net::FTP libra...
I recently asked this question and this comment and made me ponder the whole process of releasing an update to the customers. The next update for our software is planned and the previous time it went horribly wrong because of regression, bad testing, etc... This time we want to prevent the scenario that we test via our...
I have been puzzled lately by an intruiging idea. I wonder if there is a (known) method to extract the executed source code from a large complex algorithm. I will try to elaborate this question: Scenario: There is this complex algorithm where a large amount of people have worked on for many years. The algorithm creates...
I am currently studying pathfinding and I came across A* algorithm from this site https://github.com/qiao/PathFinding.js I tried to test A* with bi-directional and it is working great. What I wanna do now is increase the path that it can make without adding more nodes in the openlist. For example is that the algorithm...
Is it generally, to a reasonable developer, considered morally acceptable, to take a branch of an open-source repository, and start making changes to it and calling your own? You would be taking this to another open-source. Assume that you will link to the original. Note that this is a question of what is considered ac...
Using Visual Studio 2012 with C#, when I write multi-line comments, VS automatically begins each line with an asterisk, like this: /* * * */ I was just curious if this was the case in programming languages other than C#, or if there was a specific reason for this template.
I am busy with a hobby OS and I am planning on making the project open-source and eventually have support for multiple platforms. With this in mind I have taken the approach of putting all hardware specific code in a separate Hardware Abstraction Layer (HAL) library so that the kernel does not need to know how the spec...
Commitment is a promise, and we all have been taught that you need to keep your promises. But is it realistic to keep the commitment for each Sprint? Sometimes people get sick, sometimes the technical approach is proven wrong and you have to rethink everything, sometimes during further discussions with the product own...
What is the best way to get data from server as fast as it gets to it? (Like instant message, or simple broadcast for example). I first thought about using miniature web server in android and get post requests to it with data. However with this approach I soon understood that I will get many problems with NAT and simil...
The premise is using a language (e.g. C#, javascript) which passes an object by reference into a method. Assume there is an object "Player" which has a property "Level" and there is a method takes Player as parameter and its function is to increase the player's level by 1. The method can be designed something like (c# ...
I have come across the term "programming to an interface instead of an implementation" a lot, and I think I kind of understand what it means. But I want to make sure I understand it's benefits and it's possible implementations. "Programming to an interface" means, that when possible, one should refer to a more abstract...
I've always used the repository pattern in my applications. But I have seen that many people use facades instead of the repository for naming convention, but the operation is the same, I Think. Why is there this difference? There are a real difference between them or not?
Scrum's great for new development and proactive tasks. But I've never been sure how to use it when the department's obligations also include analyzing/answering/fixing customer support questions, which come in unpredictably, typically have high enough priority to interrupt what we planned on doing, and whose complexity...
We have 10 separate projects that all access the same database. Initially, all 10 projects had database credentials hardcoded into them. I decided to move the credentials into a utility method and have all of the projects call that instead. For example public String getDBUser() { return "username"; } So instead of ...
I want to release an npm (NodeJS) module that will be a development dependency for extensions built for my product (will be used in testing). I don't want this module to be used in any released derivative work (commercial or free, open or closed source). Is there an existing suitable license that I can use?
Is there an anti pattern that describes a historically grown software system where multiple developers just added new features to the system but no one really kept an eye on the overall architecture nor were refactorings ever done? I think this happens when management/customer asks for new feature constantly and no one...
Are there conventions to follow when naming an application package for an Android application? I'm coding in Xamarin Studio, using .Net, so I feel far from this "com.myapp.etc" naming convention. Are there rules to follow when naming an Android package?
In our ASP.NET MVC application, we try really hard to separate concerns to each layer (we use DDD). Nevertheless, it seems that we can't avoid having at least some business logic in DAL. For instance, there are named objects, where business requirement is that each name must be unique (but the name isn't a key). If the...
In my company, we're working on adopting the Microsoft Secure Development Lifecycle, and part of the MSDL process involves establishing security and privacy bug bars at the onset of a project. I've heard the concept of a bug bar prior to MSDL, and I understand that it's essentially a definition of what level/amount of ...
I am pursuing object oriented design. So we don't want to use globals but yet sometime we have a module that most other modules use. This means we have to just pass it to all other modules and this can be literally all modules! class Logger { public: Logger(void); ~Logger(void); }; class Calculator { public:...
I am working on a survey-based feature in our application and the survey has branching points at any given question depending on the answer given. Each path that a branch can take may not have the same number of questions. So if we evaluated each possible path that can be taken, you may end up with a different number o...
Let's say I have a machine-readable description (such as in WADL, Swagger or RAML) of a REST API that provides interface to a database. My users submit queries about underlying database in form of SQL or similar query language. However, I cannot access the database directly, only through the REST API. What approach wou...
How can NSObject contain an NSString if NSString is an NSObject /* NSObject.h Copyright (c) 1994-2012, Apple Inc. All rights reserved. */ (NSString *)description; NSObject has a property named 'description' that is an NSString but isn't NSString an NSObject? How is it that this works?
I am learning how to work with XMLHttpRequests. I know that request.setRequestHeader() is an important factor. I just don't understand why. It took me a while but I have at least found a list of Headers here and here, but I still don't understand what each one of them does, and what value goes with each. Is there a res...
I have a basic web application where users can login and edit their profile. In the profile they can submit an username and a password for a different application. I'd like to take that password and encrypt it. Later, when I want to connect to that different application I need to decrypt the password. Is there a common...
Here's how my code works. I have an object that represents the current state of something akin to a shopping cart order, stored in a 3rd party shopping API. In my controller code, I want to be able to call: myOrder.updateQuantity(2); In order to actually send the message to the third party, the third party also needs ...
Context: I built an app which generates around 1000 domain names based on user input. I need to check if they are available or not by matching against a huge zone file of parsed domain names which is around 2 GB. I have an amazon micro instance and cannot store the text file in there due to space constraints. I am ex...
Let's say I was working on a Swing application. Most of it is run on the EDT using SwingUtilities.invokeLater() inside the main method, because I heard (please correct me if I'm wrong) that that's what you need to do with Swing. However, some parts of it shouldn't run on the EDT. These parts are parts that take long to...
I ran across yet another new term in development methodology, and I haven't been able to find a definition for it. Specifically, it's called "train based development." Here are some examples of where I have seen this term. Earlier this week, I asked our engineering leads and release managers to take the Windows Metro...
I wish to publish my program under Apache2 license. I have added the "APPENDIX" part of the license text to the top portion of my source.txt file and edited the copyright year and name. But when I add the license.txt file in the same archive with sourcecode, should I edit the copyright line wih my name and year? Or...
I am learning SQL Server 2012 along with C#. In the past, I took database class in college, and have good grasp on SQL language and can write queries. However, looking at SQL Server documentation (or Oracle), it appears that DB engine (along with all the technologies that comes with it) are highly complex and are requi...
I'm attempting to teach myself the basics of finite automata and have been exploring the differences between Deterministic Finite Automata and Non Deterministic Finite Automita. One thing that pops up quite often in the on-line examples, lectures slides and videos of various CS instructors is the epsilon transition. T...
Some apps, I've noticed that developers are able to update their software without submitting them to the App Store. For example, Game of War will occasionally tell you that an update is available and to restart your device. You can then watch the progress bar carefully and see that updates are being pushed to the app...
If I quote a paragraph from Wikipedia about Optimization: In computer science, program optimization or software optimization is the process of modifying a software system to make some aspect of it work more efficiently or use fewer resources. In general, a computer program may be optimized so that it executes mo...
Our UX designers usually have a story in Sprint X that the developers will implement in Sprint X+1 (The UX designers and the devs/testers are on one team). I think this makes sense because if you don't have screen mockups and clear specifications you can't really estimate the work during Sprint Planning. However in Scr...
I want to create an HTML scraper in Ruby on Rails and I want to implement a progress bar and an ability for it to pick up where it left off if it's interrupted while scraping. I think the best way to do this be to create a database table with a record for every single page, with a boolean column called 'scraped?' I'm t...
We are a small software team (as far as programmers go) and have a team of vendors on the other side of the world that program for us. We own the product, and simply dictate to them some of the tasks to work on. I am one of the lead programmers and also the project manager of this particular project, so I am a programm...
Say that you're doing a code review, and you find yourself faced with an orchestration pattern: class OrchestrationClass { private Configuration _configuration; private DataStore1 _dataStore1; private EfficientComputationService _service; private ResultPrettifier _formatter; public DoSomething () { with...
I'm learning and diving into Web API. I've used web services before but not specifically with web API. Below is how I am designing it so far and I was curious on the feedback. I have a ReturnMessages object. This basically is a standard object that gets returned from any of the API calls, correctly executed or an er...
Here is the problem, an enthusiastic man wants to build an app, however he only knows roughly how the app should work. There are a lot of details he didn't know. How does he design his app? -Option1: Do not design, but just code the most important first & test to see how it goes then modify gradually. After the highest...
I wanted to create a parser that can read a solidworks file and turn it into a protein data bank file. This has already been done in a program called DiamondCAD. http://www.zyvex.com/Research/DiamondCAD.html I waant to make a parser that can parse the data and then visualize it the same way as DiamondCAD. I have down...
I am following a tutorial. The guy keeps on adding different plug-ins such as subclipse, maven, spring source tool suite, etc after setting up jdk, eclipse, tomcat. While installing spring, he was saying that spring makes it difficult to debug the programme. That didn't make me happy. He also added, it's up to you if y...
I want to identify most matching sentence using some pattern. That means by using java algorithm I want to create identical value for each sentences.Each sentence when entering to that algorithm can be out some kind of identical value. How can I develop it? What can I refer any web sites do you know? What sort of sites...
I am refactoring an old Codeigniter library to be php framework agnostic. There are these core parts: the connection object - this will come from the "user"; ie, the framework's connection, or their own connection library. My library will not want to "know about it" except that (at first) it will be a PDO conn object ...
I'm looking at how I can change the representation of a payload at runtime for varied potential advantages, but I'm not sure how to do it. Specifically collections. Array of Pairs [{ <resource_uri> : { <entity> }, ...}] Array of Objects [<entity>,...] Array of Resources [<resource_uri>] Map of entities { <resource_u...
I would like to send a CSV file via POST in a XMLHttpRequest, but I am unsure of two things. First is there anything to distinguish a CSV file from a string split up by comma's? And what sort of Content-Type am I supposed to put in to the setRequestHeader?
Most popular applications nowadays require account activation by email. I've never done it with apps that I've developed so am I missing some crucial security feature? By email activation I mean when you register to a site they send you an email that contains a link that you have to click before your account gets activ...
I'm trying to calculate every possible selection from different categories. 1 choice must be made from every category and the categories are always in the same order. I save a string where each character is the number of that choice from that category. I have solved this with recursion and it works well when there a...
I would like to know what do you think about persisting an "autocomputed property" to the database. For example I have these properties decimal Price {get;set;} decimal Tax {get;set;} decimal PriceWithTax {get {return Price + Tax;}} I think I need persist PriceWithTax. I can use this column, for example, in DB views. ...
I'm thinking about building an Open Source, serverless, offline-replicated p2p CMS, but I'm concerned about it really working in a real environment. How would you go about doing that, reducing the exposition to risks/bugs? I've thought about this schema for now. On the local device we have a folder called "cmsfiles" co...
Only 1% of our clients use particular features or scenarios. Do you think we should spend as much time testing these features and scenarios as we spend on our central features and scenarios, or we should test mostly the "happy path" for these features? UPDATE Maybe I should have asked the question in a different way....
From Wikipedia: Quality Assurance refers to administrative and procedural activities implemented in a quality system so that requirements and goals for a product, service or activity will be fulfilled.[1] It is the systematic measurement, comparison with a standard, monitoring of processes and an associated feedback l...
I often see something like "uncompressed for development / minified for production" when reading blogs or downloading frameworks. What is the real difference between the two, and if minified is "good for production" why is it not recommended for development?
I'm writing an HTTP API to a publishing server, and I want resources with representations in multiple languages. A user whose client GETs a resource which has Korean, Japanese and Trad. Chinese representations, and sends Accept-Language: en, ja;q=0.7 should get the Japanese. One resource, identified by one URI, will t...
In a moderately old blog post, Conal Elliot makes an interesting (if less than serious) argument that C is a purely functional language, by drawing a parallel between the combination of the C preprocessor and C itself, and that of Haskell's pure expression language and its impure IO action values. It's observed further...
(I'm talking about HTML / CSS code (not programming languages) but I think we also face the same issue as with programmers.) I am the senior front-end designer in a team and I often have to re-work my juniors' output in tight deadlines. I am faced with 2 problems: Their coding style is a bit of a mess. The aestheti...
I am using a ternary operator in super () method of my code. While the code went for review, I got a reply that Strictly don’t use ternary operators in the Super() calls. Is there any problem if we use ternary operators in the super() method?
Do you delete nodes from the underlying graph representation? Or is there a more elegant way to do it?
I used to select the default warning level in C++ programming. For example, in VS, the default warning level is Level3 (/W3) and No (/WX-) (don't treat warnings as errors). I am wondering is it a good practice to choose highest warning level in C++ programming, e.g. EnableAllWarnings (/Wall) with Yes (/WX) (treat warni...
I have used the JDT Annotation library in my Java project as I am quite fond of what it offers. To be more exact, I used the @Nullable and @NonNullByDefault annotations as I can use the synergy with Eclipse to automatically analyse possible null values and what may lead to NullPointerException bugs. Unfortunately, JDT ...
Would it be considered acceptable to use word compounds instead of numbers for version iterations? For example in a pattern: "[Adjective] [Noun]" The first version could be something like: "Auspicious Armadillo" Thus on each sequential release the noun would change to the next letter of the alphabet and the version cou...
I'm trying to make a realtime multiplayer web-game in node.js with express framework and socket.io library. But I can't seem to make my server-side logic independent of client interactions. I want client to interact only when I (server side logic) want but I can't seem to be able to do that. For example: I want 2 use...
I was doing a code review and came across something odd which I've never seen before. The developer decided to create a sub-namespace just to contain all the assembly's exceptions. I thought I had read that this was explicitly not a good use of namespaces and that exceptions should be kept at the "lowest" namespace fr...
I currently have a planning tool using SQL tables that are sort of setup like this: Date table (Contains dates & indicates if that day is a weekend / holiday etc) Employee (Simple data) Project (Simple data) Assignments (Associates the three tables, key date + employee id + project id) I have one SQL query that, for ...
The burn down chart displays a clear deadline and the progress towards the deadline. When the progress is slow and the completion of the committed work is at risk, people start to get sloppy on design and code reviews and on the depth of testing. Quality suffers. The question is whether in your organization you were su...
On the 'Interfaces' trail on the Oracle website, we are presented with the following scenario: Imagine a futuristic society where computer-controlled robotic cars transport passengers through city streets without a human operator. Automobile manufacturers write software (Java, of course) that operates the autom...
For simplicity, my database has entities and transactions. Each transaction has a DateCreated and a foreign key to the entity. I'd like to have the ability to find entities that have had a recurring number of transactions within a close time proximity of other entities. Simply, if entity A has had a transaction withi...
I work for a university Digital Services team. Our university's main website uses the Ektron CMS (I have my own thoughts about this, but that's irrelevant). Because we maintain a university website, we need to make sure our website is extremely backwards compatible. We are trying to make a decision as to whether Twitte...
I maintain an open source Flickr app Glimmr for Android. There is currently an architectural issue around pagination that I've been trying to solve for quite a while, and would appreciate ideas. Here are the components involved: Tasks - various subclasses of AsyncTask that fetch photos from sources such as a users ph...
I assume that when a user registers at a site, the password and username are stored inside of a database. I've read that the password is often encrypted using a salt. So, is it safe to encrypt the passwords with a salt and to save it in the same schema with the username? Secondly, how does authentication work? Companie...
For the moment I'm strictly speaking in Pseudocode. I'd only like to see if i'm on the right track. The game I'm talking about is similar to a application called FLOW. In this game, you're given a nxn board(Always a square) and need to fill out each slot in the board. Similarly, when a board game is initialized, it wi...
In most OOP languages, objects are generally mutable with a limited set of exceptions (like e.g. tuples and strings in python). In most functional languages, data is immutable. Both mutable and immutable objects bring a whole list of advantages and disadvantages of their own. There are languages that try to marry both ...
Can the Jacquard loom, pictured below complete with its chains of paper cards be considered stateless? As far as I can tell I can tell, each operation is not dependant on the previous. Or did it have any concept of branching and/or looping?
I'm thinking to CSRF protect all public AJAX requests that return JSON, because what's to prevent another site from spoofing the AJAX header and using the JSON as if it were a public API? I think CSRF protection is the best solution for this, however I'm concerned with the way Laravel handles this: Using laravel's CSR...
Many years ago, I was talking with an Economics professor about design patterns, how they were establishing a common language for programmers and how they were solving well known problems in a nice manner, etc etc. Then he talked back to me that this is exactly the opposite approach he would use to his Economics studen...
In my project, on a security system, I was using a socket to get the details of the client and then store it in a database (his IP and port he connected from and service he accessed). I was wondering if the fetching of the details and storing them in a database should be done in separate threads or a single thread. Whi...
I'm building a user friendly XML editor in HTML/JS. Looking for some general advice on how to build the editor UI and which approach you'd recommend on mapping the data to the UI. Details about the problem: Basically I'll fetch a single object as XML from a sever. The XML objects in question will be a small set of org...
I have a project where I need to translate a lot of words and text fragments in different languages. In these texts, underscores are currently added in these text (fragment(s)) to be used as keyboard shortcuts (used in Visual Studio). However, I was wondering if this is the way to go, or if it would be better to remove...