instruction
stringlengths
34
19.9k
Running the build can take a long time. Why run all the tests when a given change probably only has the potential to break some of them? You should be able to build a dependency graph of all the code that each test could possibly run, and then avoid running tests that couldn't possibly be affected. Is there anything th...
Fowler refers to the MVC, as a GUI architecture: There have been many different ways to organize the code for a rich client system. Here I discuss a selection of those that I feel have been the most influential and introduce how they relate to the patterns. If MVC is a GUI architecture, then say that the M in MVC ar...
I have a question about making a class diagram for an MVC based college senior project. If we have 2 actors of users in my system, lets say Undergrad and Graduate students are the children of abstract class called User. (Generalisation) Each actor has his own features. My question, in such case, do we need to have thes...
There is a piece of .net C# code which use Reflection to create an instance using Activator.CreateInstance(). This is an old piece of code and runs on the top of Enterprise Library. Is it a better idea to replace this with Dependency Injection to create objects? Is there any Pro's and Con's for either approach?
Suppose you have a parse tree, an abstract syntax tree, and a control flow graph, each one logically derived from the one before. In principle it is easy to construct each graph given the parse tree, but how can we manage the complexity of updating the graphs when the parse tree is modified? We know exactly how the tre...
Many languages seem to have structures that are very similar called iterable or enumerable. These are structures that can be iterated or enumerated over, which seem to me extremely similar things. Are these words synonymous or is there a subtle semantic difference between iterable and enumerable which justifies the ch...
I'm starting a new project soon, which is targeting mobile application for all major mobile platforms (iOS, Android, Windows). It will be a client-server architecture. The app is both informational and transactional. For the transactional part, they're required to have an account and log in before a transaction can be...
You maintain an existing application with an established user base. Over time it is decided that the current password hashing technique is outdated and needs to be upgraded. Furthermore, for UX reasons, you don't want existing users to be forced to update their password. The whole password hashing update needs to happe...
Context is one of the core classes of Android, and many functions it contains are useful in Android library projects, particularly accessing configuration. What are the trade offs involved in accessing the Context in a library, either by injection or by subclassing Application in the library, and subclassing that in t...
just getting started with composer and I have a couple of questions. When I use composer to add a dependency, the dependency gets added to my folder's Vendor directory. The newly added package not only comes with the source code for that package, but all packagist required files for the developer to test and add that ...
I'm taking a course on design patterns in software engineering and here I'm trying to understand the good and the bad way of design relating to "coupling" and "cohesion". I could not understand the concept described in the following image. The example of code shown in the image is ambiguous to me, so I can't quite cl...
Let's say, we have a simple digital clock. To "power" it, we use a routine executed every second. We update seconds part in it. But, what about minutes and hours part? What is better / more professional / offers better performance: Ignore all checking and update hour, minute and seconds part each time, every second. U...
Situation Earlier this evening I gave an answer to a question on StackOverflow. The question: Editing of an existing object should be done in repository layer or in service? For example if I have a User that has debt. I want to change his debt. Should I do it in UserRepository or in service for example BuyingService...
So this is my second ASP.NET MVC 4 project. It's decided that for this one we will use this template and it was said in a way that I felt really stupid for not knowing how exactly this template will help us and what exactly we gain by using it. I'm used to using HTML/CSS for the UI combined with jQuery. Now it seems th...
I know it might be a silly question to ask, but I didn't quite get an a absolute clear answer on this matter, so I thought I'd put it here. Does c++ support the subtyping in the sense that it fulfills Liskov's principle fully? I understand how parametric polymorphism, inclusion polymorphism(subclassing and overriding) ...
We've all heard of salesforce and sugarcrm and the likes of systems like this. Unfortunately at my workplace we have been asked to write a similiar system (rather then license or purchase). Basically the database is fairly large. Think of modules such as: Corporate groups, customers, programs, projects, sub projects,...
My colleague developed an internal web application. This app works only in Internet Explorer, which means that I can't access it from my smartphone. Is there any way to develop an application which will serve as a bridge between my smartphone and this web app, enabling me to use the web app from any other browser/mobil...
Let's say I wanted to create a Java List<String> (see spec) implementation that uses a complex subsystem, such as a database or file system, for its store so that it acts as a persistent collection rather than an in-memory one. So here's a skeleton implementation: class DbBackedList implements List<String> { private ...
Currently I'm coding a Vector class in C# and I'm coming to the point, where I've to figure out, how I want to implement a function/method to interpolate between two vectors. The (obvious) and also my first solution was to simply implement it as a method in the vector class itself: public class Vector3D { public st...
I have an User entity that has a Set of Address where Address is a value object: class User{ ... private Set<Address> addresses; ... public setAddresses(Set<Address> addresses){ //set all addresses as a batch } ... } A User can have a home address and a work address, so I should have so...
I know this may be a dumb question, but I'm only 15 so I don't really know how the legal part of it works. When I choose a .dll to be included in my project, Visual Studio only includes the .dll file with my project (of course) so I just copy the license and stick it in a folder called licenses. But now, I'm going to b...
I've just built a self-balancing tree (red-black) in Java (language should be irrelevant for this question though), and I'm trying to come up with a good means of testing that it's properly balanced. I've tested all the basic tree operations, but I can't think of a way to test that it is indeed well and truly balanced...
I'm currently implementing an HTTP API, my first ever. I've been spending a lot of time looking at the Wikipedia page for HTTP status codes, because I'm determined to implement the right codes for the right situations. Listed on that page is a code with number 420, which is a custom code that Twitter used to use for r...
Is curl something that's not expected to be installed on servers? I'm working for a small development shop and 99% of the problems that I'm having is regarding curl. Most of the projects that I'm working on involves calling a web API. Most web API's suggests using curl by default since you have to pass in a POST data i...
My question: Is there a benefit to NOT assigning a Bug to a particular developer? Leaving it to the team as-a-whole? Our department has decided to be more Agile by not assigning Bugs/Defects to individuals. Using Team Foundation Server 2012, we'll place all Bugs in a development team's "Area" but leave the "Assigned T...
I know I might get downvoted for this, but I'm really curious. I was taught that inheritance is a very powerful polymorphism tool, but I can't seem to use it well in real cases. So far, I can only use inheritance when the base class is an abstract class. Examples : If we're talking about Product and Inventory, I quic...
I need to write some algorithms for a PIC micro controller. AFAIK, the official tools support either assembler or a subset of C. My goal is to write the algorithms in a generic and reusable way without losing any runtime or memory performance. And if possible, I would like to do this without increasing the development ...
I'm studying OOP PHP and working on a small personal project but I have hard time grasping some concepts. Let's say I have a list of items, each item belongs to subcategory, and each subcategory belongs to category. So should I make separate classes for category (with methods to list all categories, add new category, d...
In my design, I have multiple models and each model has a controller. I need to use all the models to process some operation. Most examples I see are pretty simple with 1 view, 1 controller, and 1 model. How would you get all these models together? Only ways I can think of are 1) Have a top-level controller which has a...
NPM's docs say that anyone can call npm-publish and add his own NPM package to the "official" registry. Who controls this registry? How reliable is it for production deployment scenarios? What's preventing people from spamming this registry? Is there any moderation/QA process?
I am currently struggling with memory handling. I have an if statement and each case instantiate a new object from a class. Does this affect the memory allocation in java? switch() { case 1: test t1 = new test(); case 2: test t2 = new test(); case 3: test t3 = new test(); case 4: test t4 = new test(); case 5: test ...
Let's start from this principle: quality is a feature that you can't add to a project in the middle of the development process. This is the scenario: two weeks to go live with my project and, one of the developers added a specific method used only for one web application to our framework (Our framework is a bounce of ...
There's a class with a parametrized constructor that initializes a member variable. All public methods of the class then use this member variable to do something. I want to ensure that the caller always creates an object using the parametrized constructor (there is also a setter for this member variable) and then call ...
The best idea I have so far is to rotate first array by {0, 90, 180, 270} degrees and reflect it horizontally or/and vertically. We basically get 16 variations [1] of first array and compare them with second array. if none of them matches the two arrays are rotationally and reflectively distinct. I am wondering if ther...
Lately we've been looking at ways to improve automated testing and related tooling of our enterprise-level GWT web app. I've realized that in some ways, GWT is a bit hostile to automated testing, mainly because of the nature of the long GWT compile times from Java to JS. This makes unit testing somewhat challenging, bu...
If I declare in a header file, for example, extern unsigned long * Ptr; and the value of this pointer Ptr in the linker file. Will this adrress be 'constant'? Can I change its value ?
I believe the scenario is common mostly in business workflows - for example: loan management the process starts with a loan application, then there's the loan offer, the 'live' loan, and maybe also finished loans. all these objects are related, and share many fields all these objects have also many fields that are uni...
I'm writing an open source library which handles hexagonal grids. It mainly revolves around the HexagonalGrid and the Hexagon class. There is a HexagonalGridBuilder class which builds the grid which contains Hexagon objects. What I'm trying to achieve is to enable the user to add arbitrary data to each Hexagon. The int...
This is in the scope of a web application. I have a database which has a few nested relations. There is a feature which depicts the history of a large chain of relations. It is essentially a data analysis feature. The issue is that in order to search, a large object graph must be loaded - the loading time for this obje...
When considering the disk space of a storage medium, normally the computer or operating system will represent it in terms of powers of 1024 - a kilobyte is 1,024 bytes, a megabyte is 1,048,576 bytes, a gigabyte is 1,073,741,824 bytes, and so on. But I don't see any practical reason why this convention was adopted. Usua...
I've been studying the use of exceptions in various php projects (such as Doctrine and Zend Framework). Exceptions seem to be thrown when unordinary input/state occurs. A perfect example is Doctrine throwing an exception when you try to use a invalid query string. I think the creators of the doctrine api understood th...
I am designing an application with intention into making it a product line. I would like to extend the functionality across all layers and first struggle is with domain models. For example, core functionality would have entity named Invoice with few standard fields and then customer requirements will add some new field...
According to the Liskov principle, a construction like the one below is invalid, as it strengthens a pre-condition. I know the example is pointless/nonsense, but when I last asked a question like this, and used a more elaborate code sample, it seemed to distract people too much from the actual question. //Data models a...
When and how did this process of prefixing css with vendor specific prefix begin. Which browser/org start this and why was this started. I searched the web but found no details on this.
I have a fairly complex search problem that I've managed to reduce to the following description. I've been googling but haven't been able to find an algorithm that seems to fit my problem cleanly. In particular the need to skip arbitrary integers. Maybe someone here can point me to something? Take a sequence of integer...
I am creating an application from legacy code using AngularJS. I wonder what parts of my code should be moved into a directive. For example, iI had thought of moving a table which is used multiple times across the application into a directive. The tables alter from headings and size. Is it worth the effort or even a g...
My office has a suite of web reporting engines written in VB. All in all there's about 300 reports with varying displays depending on the data being input into them. I'm trying to establish an efficient way to deal with such a major diversity, but am struggling with creating a system that won't be a nightmare to code...
To randomly shuffle an array, with no bias towards any particular permutation, there is the Knuth Fischer-Yeats algorithm. In Python: #!/usr/bin/env python import sys from random import randrange def KFYShuffle(items): i = len(items) - 1 while i > 0: j = randrange(i+1) # 0 <= j <= i items[j], ...
Well, the thing is that I am just about to create a Desktop App (with .NET windows forms) And now I just wonder if it would be really a wise choise to use any IoC (StructureMap,Ninject,Spring .Net), I have used them before for Asp.Net web applications but what makes me doubt now is the fact that working with windows fo...
I've got two lists: List<Integer, ZooEntity> zoos; List<Integer, List<ZooEntity>> groupOfZoos; These operations will return collections of values: Collection<ZooEntity> cz = zoos.values(); Collection<List<ZooEntity>> czList = groupOfZoos.values(); What I want to achieve is to get list of all zoo ids. List<Integer> zo...
Background Tony Hoare's billion dollar mistake was the invention of null. Subsequently, a lot of code has become riddled with null pointer exceptions (segfaults) when software developers try to use (dereference) uninitialized variables. In 1989, Wirfs-Brock and Wikerson wrote: Direct references to variables severely l...
A colleague of mine came up with a rule-of-thumb for choosing between creating a base class or an interface. He says: Imagine every new method that you are about to implement. For each of them, consider this: will this method be implemented by more than one class in exactly this form, without any change? If the answer...
I'm learning some graphics programming, and am in the midst of my first such project of any substance. But, I am really struggling at the moment with how to architect it cleanly. Let me explain. To display complicated graphics in my current language of choice (JavaScript -- have you heard of it?), you have to draw grap...
Pretty simple question. Should package structure closely resemble class hierarchy? If so, how closely? Why or why not? For instance, let's say you've got class A and class B, plus class AFactory and class BFactory. You put class A and class B in the package com.something.elements, and you put AFactory and BFactory ...
I am using git as a version control system, and using git-flow as the branching model. I started a feature branch some weeks ago in order to maintain the system in a clean state while developping that feature. The main development continued on the develop branch, and changes from develop were merged periodically into t...
After learning functional programming in Haskell and F#, the OOP paradigm seems ass-backwards with classes, interfaces, objects. Which aspects of FP can I bring to work that my co-workers can understand? Are any FP styles worth talking to my boss about retraining my team so that we can use them? Possible aspects of F...
I have been asked to create a web service that communicates with Auth.NET CIM and Shipsurance API. My web service will be used by multiple applications (one a desktop and another a web application). I am confused whether I should build a WCF or an asmx web service. Auth.NET CIM and Shipsurance API have asmx web serv...
In my education I have been told that it is a flawed idea to expose actual primary keys (not only DB keys, but all primary accessors) to the user. I always thought it to be a security problem (because an attacker could attempt to read stuff not their own). Now I have to check if the user is allowed to access anyway, so...
choosealicense.com claims that the MIT license is “A permissive license that is short and to the point. It lets people do anything with your code with proper attribution and without warranty” (emphasis mine). Reading the license, though, I don’t see anything claiming that attribution to the original author has to be an...
maybe you are thinking that this is another dump question about language in URL, but I hope it is not! I've red many articles on this, but non of them was dealing with "sections of site" (described bellow). I am programming a new application platform in laravel/php and I am still not 100% convinced where to put languag...
In essence, I'm wondering how licenses affect the legality of using source code as data. By that I mean literally storing code in a database as strings and using it e.g. for some syntax highlighting experiments, or other such pursuits. I can think of a couple of scenarios: My project is closed-source, and I want to us...
I am trying to find an appropriate data structure for representing available navigations between a game's screens. Using a linked list, a node can only have one node after it : inappropriate. Using a tree seems up to the job as nodes can have many children nodes but it's inconsistent in the sense that a supposedly chi...
I've heard a lot about requirement gathering and use cases in theory, but in practice often happens that we ask ourselves "should we include this? should this be a use case? in which language should we write this particular requirement" and so on. These questions are mainly because of lack of practice, and since we can...
I am a software engineer at a medium sized company. We have a fairly robust testing platform running on TeamCity. It does unit tests on every checkin, and a daily unit test/BVT run. The problem is - we have a great deal of broken unit tests. Quite often, I bring up the pointlessness of unit tests if they are constant...
I am wondering, in view templates, what would contribute to me choosing between using arrays or objects for getting things printed out in arrays {{$user->zip_code}} vs {{$user['zip_code']}} I'm working in blade templates in Laravel/PHP fwiw. My feeling is that it makes sense to use objects: we can use methods if we nee...
Is it feasible or even possible to use relational algebra and/or relational calculus in the form of proofs to test/verify the correctness of SQL statements, functions, and stored procedures? It seems to me like it should be at least possible, but I don't know if there's a detail I'm missing that makes a 1:1 mapping bet...
Assuming the only tool for generating random numbers I have available is generating a uniformly distributed variable u on U(0,1). I want to generate a Nakagami Random Variable from it. I know I could just plug u into the inverse CDF of the Nakagami distribution, but unfortunately, the inverse CDF isn't trivial to compu...
How to update web application deployed on intranet? There is a Java Spring application that will be deployed on intranet of multiple customers. In case when there is a major update what should the developer do in order to ensure that all the customers have the latest version of his software? There is an option that an ...
The code I've inherited has a design that I'm not familiar with (I'm still new to the world of programming). It is a .net project and there are 3 classes in question here. public Class1 { public void DoSomething() { Class2 class2 = new Class2(); string myValue = class2.GetSomeValuePlease(); ...
I'm doing a project that uses svg-edit(JS drawing tool) and the page grows big. By now there are about 20 JS file in a page - plug-ins and so on. One of the editor's files breaks in some kind of 'Uncaught TypeError' but it's compressed and can not understand anything. I used several jquery plug-ins that are important ...
Which of the below is a preferred coding style (in c# .net) public void DoWork(Employee employee) { if(employee == null) return; if(!string.IsNullOrEmpty(employee.Name)) return; // Do Work } or public void DoWork(Employee employee) { if(employee != null && !string.IsNullOrEmpty(employee.Name)) { ...
I am trying to understand the difference a little better as it seem like they are the same thing. I have work in projects with no use of the requirements and everything is an acceptance criteria, and on projects that have both.
I'm looking at creating an implementation of Daugman's iris recognition algorithm, which is covered in his seminal paper on the topic. What I don't know is, if I implement his algorithm, do I need a license?
I can be completely wrong but I vaguely remember hearing from a podcast that according to Visual Studio's license, a developer who works with Visual Studio professionally at their work place automatically has the license to use it in their personal life. That means a developer may not have to pay for Visual Studio to l...
I've always liked the idea of having multiple inheritance supported in a language. Most often though it's intentionally forgone, and the supposed "replacement" is interfaces. Interfaces simply do not cover all the same ground multiple inheritance does, and this restriction can occasionally lead to more boilerplate co...
I have a good amount of experience working with objective-C and making iOS apps that work locally and with BaaS providers (Parse.com). However, I'd like to take my mobile development to the next level and I'd like tips on the order in which to do things and tips on which services/technologies to use. So, I need a datab...
I need some best practices or experiences of developer teams who had to treat the same issues I have at the moment =) Our company is developing a client software for years. The one and only dependency was to have an appropriate database. With each release (update) we also update (incremental) the database if necessary....
I'm still in the design phase of my REST API, and I'm a bit stuck on how to configure the resources. The API will be consumed by mobile devices (Android, iOS, and Windows). Communication through HTTPS. These are the features the API will support: View a list of previous reservations View a previous reservation Create...
I'm an extremely novice web programmer working at a 2 person shop building websites, and we're in the process of writing a simple website template system in PHP from scratch. My manager is entirely self taught. He has been insisting that we put our HTML directly quoted in variables, mixing our back end code with the fr...
So let’s say I make a script/small app that has a ton of my own code, and only a small section of it is comprised of a utility from someone else (let’s say a simple operation like sending files to the trash, or sending a notification), which uses a license, like MIT. Now, I want my script/app to be public domain (or MI...
I have a question about the efficiency of an algorithm: You have a list of x,y points Now I want to get all the points that are up to 5 units away from a reference x,y point How do you calculate it in the most efficient way? I just go over each point and calculate distance, and if that distance is less than 5, I add it...
When I do my code layout, I like to start with a rather high level view, and then start to delegate actual computation to class or functions that have a bit more detail. Then in these classes of functions, I do the same, layer by layer, until I get to the bottom where I have to do the 'real' action. Example: def build_...
We are trying to create an ASP.NET MVC 4 application using entity framework with domain driven development style pattern approach. As you can see in our part of domain layer, we have a complex design. We need to load entity with lazy as well as eager methods. Unfortunately we have big problem with these methods in enti...
If I wrote this in MySQL SELECT * FROM foo ORDER BY bar LIMIT 1 it would first order the result and limit it afterwards. I always get the lowest bar. I wonder if this is specified like this in SQL-standards and how to check that? All I found are some BNF's which do not explain how something should work, but only what ...
I have a project which will have basic and professional edition. The professional edition will have all the features of the basic edition. I am using git to manage the project's codebase. I consider that I will fork repo of the basic edition after I completed it. Then, I will start to code the professional edition on t...
I had the following DB schema: Customer Car Rental ------- ---- ------ Name Name Car_ID ID ID Customer_ID Date This is said to be non normalized as the date can repeat (multiple customers can rent a car at the same day). So the teacher said it should be like: Custom...
I am a new PHP developer (coming from .NET). The experienced php dev that I work with said that calling a static get method on a PHP class with an ID as a parameter is common in PHP. Is there a name for this idiom? Is there a reason why developers do this? Can someone point to a link to an example class? I would like t...
link : http://download.java.net/jdk8/docs/api/java/lang/annotation/Native.html In Java 8, there will be @Native annotations. Indicates that a field defining a constant value may be referenced from native code. The annotation may be used as a hint by tools that generate native header files to determine whether a header...
I would like to develop iOS apps but due to budgetary issues I can only afford an iPad mini gen1 or iPod touch 5th gen. Is it possible for me to make apps for all iPhones and iPads/iPods using just a single device? Another question is how does the latest iOS7 work on ipad mini gen 1/iPod touch and what are the limitati...
Why does the modifier access for the properties need to be public with Unity? I'm very interested in a detailed explanation for my question. I read about tips to do it in other ways, but not a detailed explanation about why this can't be declared explicitly in my code.
I work for a large company, which dictates the use of agile processes. For example, for our projects, we use cloud-based services that are specifically targeted at managing agile development. The specific engineering group I work for has not traditionally developed software (instead we help drive projects from a much m...
Today I lost a method that I was using since my co-worker redefined it to take its superclass instead. So after synchronizing with the repository I had trouble. Would it had been better in this case to use some annotation like @Deprecated instead of removing the method so that I would get an error message telling my th...
Is there a general term to describe a keyword followed by a statement block? E.G. if() {statement block} while() {statement block} try{statement block} finally{statement block} Or even something made up: controlScope{statement block}
I'm implementing a system that's basically a pipeline of XML documents: XML documents are retrieved over the Internet, validated, further processed etc. until they are ingested in a relational (non-XML) database. After the ingestion in the database they can be discarded. Since the various components of the pipeline are...
I am trying to understand object oriented code better and I decided to start at abstraction. If I am not incorrect, abstraction means that you hide information that isn't relevant to what task you want to perform, i.e. If I turn on the TV I would not need to know the internal that is going on. Or If I have a class that...
I am currently working on software for layered manufacturing (3D printing), and have come to a point where I no longer know what to do. I am at the stage where I must take a bunch of lines, and order them to create a seamless contour of a model. I have some basic ideas on how I am going to do this, but since I am using...
This is purely a design question and the example is simple to illustrate what I am asking and there are too many permutations of more complex code to provide examples that would cover the topic. I am not referring specifically to this example, just using the example to illustrate what I am referring to. In an if statem...
It's clear that the effectiveness of a neural network depends strongly on the format you give it to work with. You want to pre-process it into the most convenient form you can algorithmically get to, so that the neural network doesn't have to account for that itself. I'm working on a little project that is going to be...
I am wondering how to interpret the velocity update in a Binary Particle Swarm Optimization (PSO). To recap the velocity update : V(t+1) = V(t) + c1 * r1 * (XlocalBest - X(t)) + c2 * r2 * (XglobalBest - X(t)) I understand that the binary position vector maps to values in the discrete domain. However, ...
The developers of the Dart language tell that there is a virtual machine that executes statements written in Dart language. What is the difference between an interpreter and a virtual machine that executes a language? Until now the virtual machines that I knew, like Java Virtual Machine, Common Language Runtime, and Da...