instruction stringlengths 34 19.9k |
|---|
Assume an interface that allows queries on a spatial tree
public ISpatialTree
{
int FindChildIndex(Vector point);
bool IsLeaf { get; }
ICollection<ISpatialTree> Children { get; }
}
and another one that allows changing the tree:
public ISpatialTreeWriter : ISpatialTree
{
void Add(Vector point);
bool... |
I was watching this video on the maximum and minimum values of signed integers.
Take an example of a positive signed value - 0000 0001
The first bit denotes that the number is positive and the last 7 bits are the number itself. So it is easily interpreted as +1.
Now take an example of a negative signed value - 1000 00... |
I have been searching for a good online course in data structures but have found that Google also returns results for algorithms courses, which say stuff like:
In this course you will learn several fundamental principles of
algorithm design: divide-and-conquer methods, graph algorithms,
practical data structures (... |
What strategy would you use to manage the releasing of versioned software to Azure cloud services (web and worker roles)? We are not looking for continuous integration. We are using Visual Studio 2013 and Visual Studio Online (Cloud TFS).
At one point, we were releasing straight from Visual Studio using the Azure Clo... |
In domain model of my web application I've an entity Foo which can be created only by a pojo FooBean: Foo.newInstance(FooBean fooBean) (Might have been better a Builder-pattern.)
In the factory methode newInstance() the pojo FooBean is validated and throws NullPointerExceptions and IllegalArgumentExceptions if needed. ... |
I've read How Do You Pull Something from a Release?, but it doesn't solve our problems, as our case is more complex.
Our situation is as follows. We're developing an application for an internal customer. We're doing Scrum with four more or less aligned teams (i.e. sprints end on the same day), one of which is off site.... |
The blogosphere has a number of articles on the topic of AngularJS app structuring guidelines such as these (and others):
http://www.johnpapa.net/angular-app-structuring-guidelines/
http://codingsmackdown.tv/blog/2013/04/19/angularjs-modules-for-great-justice/
http://danorlando.com/angularjs-architecture-understanding... |
I consider myself to be a 'mockist' on the 'mockist' vs 'classicist' debate, but I am trying to understand the other point of view.
Imagine I have this class, where a concrete instance of IDependency is injected by an IoC container.
IDependency does not access a remote resource like a database or web service (in which... |
In a centralized web service we break down the components into various small Git repos by software modules, e.g. authentication module, authorization module, data access module etc. (around 15 repos at the moment)
The good thing is it is easy to manage the smaller code base, however, our productivity has decreased a lo... |
I'm using Codeigniter PHP Framework for developing a web application, and when developing an admin zone, I've ended building a generic parent class called AdminController which is extended by the child classes to develop my Admin zones.
I've shortened my code to show what I really want to show, my code is something lik... |
from semver.org:
Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. However it is done, it should be precise and comprehensive.
Why are we forced to declare a public API? Why can't I use it for my own website that has no API?... |
I am mapping Field1 to Field2. The map object instantiates the field object and vice versa, creating an infinite loop.
This is in PHP.
class field {
protected $maps; // mapCollection object. all the mappings of this field to others
}
class map {
protected $field1; // field object
protected $field2; // field obj... |
I have four thread instances and they are executing run() code given below:
public void run (){
System.out.println("1st line :"+Thread.CurrentThread().getName());
System.out.println("2nd line :"+Thread.CurrentThread().getName());
System.out.println("3rd line :"+Thread.CurrentThread().getName());
System.out.... |
I started using TDD for the first time on a project I started recently.
I have a few objects with dependencies and structures that look something like this:
public class MyClass
{
private readonly IDependency1 _dependency1;
private readonly IDependency2 _dependency2;
public MyClass(IDependency1 d1, IDepend... |
We are going to track user engagement (i.e. time spent on website, most viewed part/page of the system, etc).
I don't see Google Analytics / MixPanel being able to do this, since we have to analyze based on factors only present in OUR backend (such as users who go to specific school, users who are a specific type, etc)... |
EDIT: Updated flow diagram to better explain the (likely unnecessary) complexity of what I'm doing.
We at the company I work for are attempting to create complex PDF files using Java iText (the free version 2.1 line). The documents are built piece-by-piece from individual "template" files, which are added to the fin... |
Given a data structure, I want to provide an API method Size which returns the number of items.
I am vacillating between 2 approaches:
Maintain a count and increment/decrement it in response to Add/Delete calls respectively
Perform a traversal to calculate the count when Size is called.
Approach #2 will take O(n) vs... |
I have a huge collection of different moduli and associated with each modulus a fairly large list of remainders. I want to store these values so that I can efficiently determine whether an integer is equivalent to any one of the remainders with respect to any of the moduli (it doesn't matter which, I just want a true/f... |
Sometimes I see people writing variable names like this:
int _variable;
IMO That's really ugly. What's that about?
|
I have the concept of a SlowLoading thing:
public interface SlowLoading {
boolean hasLoaded();
}
I also have a component MyComponent:
public interface myComponent{
void doSomething();
}
My implementation covers both:
public class MyComponentImpl implements SlowLoading, MyComponent {
// omitted for brevity
}
I... |
I'm new to the programming world and also a little bit confused. My brother would like to work with me on some program. I'm a graphic designer so he asked me for UI and all it's elements. I would really help him as much as it's possible so I have found Expression Blend for Visual Studio. At first it looked great but af... |
Given a (intersecting) polygon, I'd like find out which tiles are being covered by the polygon.
Example:
Details:
Tiles are square, 1 unit wide/high
The grid begins in (0,0)
The corners of the polygon can have floating point coordinates (i.e. 3.433, 5.234)
In general, an edge of the polygon might be as long as 1000 -... |
I am using Spring for a web application. To validate a user's input in a form such as for creating a Person entity I use JSR 303 validation to check for not null/empty or valid patterns etc.. Some things however I check in the service layer such as making sure a field is unique in the database and if not throwing an ex... |
How can I deal with situations when multiple clients might edit same object at the same time?
For example, I have a web app with admin console, which lets you edit profile data. Several users want to open the same profile and edit it.
If I just let the things go as they do, I`ll get "the last who saves wins" situation ... |
I work for a company that uses XML for storing a bunch of serialized Java classes. The framework we use is Apache Betwixt (abandonded in 2008) and it's kind of pain to maintain and extend (it seemed like a good choice back in the day).
Crash course in Betwixt along with the detailed problem:
Only supports public gette... |
My Android app contains some Apache-2.0 licensed code from Google (in-app billing example) and links to com.android.vending.billing library in the form of a InAppBillingFile.aidl file (same license?).
I would like to know what I have to do for my app to be license compliant, i.e. what to show in the About section, what... |
In Core Data, we can put transient properties in our entity objects (or categories on our entities). These transient properties can calculate transient data based on actual entity properties.
Is putting code that does NSFetchRequests in transient properties over the top and to be avoided? I feel this use is beyond the ... |
I was working with a HashSet the other day, which has this written in the spec:
[add()] adds the specified element e to this set if this set contains no element e2 such that (e==null ? e2==null : e.equals(e2))
I was using char[] in the HashSet until I realized that, based on this contract, it was no better than an Ar... |
From this answer about latencies, we have some numbers (yes, caveat caveat) for latencies when coding (slightly edited):
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Main memory reference 100 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Disk s... |
My code is given below.
In the for loop I am getting unexpected output i.e.
before completing the execution of for loop by 1st thread the 2nd thread comes in for loop and shows incremented value.
public class ThreadSafe {
public static void main(String[] args) throws InterruptedException {
System.out.printl... |
So far as I know, there are two forms of the Adapter Pattern: the class adapter and the object adapter. Could someone please explain to me the following limitation of the class adapter and why it is not a limitation of the object adapter:
a class adapter is not suitable when we want to adapt a class and all of its su... |
I'm modeling an Online Classified System where, naturally, who sells also can buy and vice-versa.
The question is: should I have two different Actors, Buyer and Seller or I could have, say, an actor Client capable either buy and sell?
How do you approach this Model?
Cheers,
|
I'm bit of a novice to JavaScript so I've been wondering on positive and negative sides of using polling compared to using events in JavaScript? When does one use one or the other?
By polling I consider any effect that is triggered on something that repeats itself usually using setTimeout. But also for example:
functi... |
So it is generally accepted that top tier programmers can produce an order of magnitude more/better code than their more average peers.
It's also generally accepted that the rate of errors made in code is relatively constant for programmers.
Instead, it tends to be impacted by the processes used when writing the code a... |
I'm having serious doubts about the design for my Web application.
I wanted to separate the business logic from the interface so I made a Web API that handles all the requests to the database.
It's an ASP.NET Web API with Entity framework and a unit of work and generic repository pattern. So far, everything is good.
... |
I'm trying to collect different ways of managing configuration across multiple environments.
I have a requirement to document configuration changes for the deployment plan.
Dev values are defaults in the code and QA manages their own as well so the documenting and sharing of the info is a critical point.
Rather than co... |
I want to parse a multipart form twice: once to grab the incoming fields, and later to process the file upload.
I am trying to maintain a proper separation of concerns within my Node app:
Controller is responsible for handling the incoming fields.
Model is responsible for the upload file logic.
I need to pass the fie... |
The answer to why we put private member variables in C++ headers is that the size of the class must be known at points where instances are declared so that the compiler can generate code that appropriately moves about the stack.
Why do we need to put private members in headers?
But is there any reason to declare privat... |
I'm comparatively new to algorithm analysis and am taking a related course on coursera where I came accross k way merge sort.
The time complexity of 2 way merge sort is n log2 n, of 3 way merge sort is n log3 n and of 4 way merge sort is n log4 n.
But, in the case of k-way the complexity is nk^2. This is because we p... |
Right now I am working on my own small project of a WPF file back up application. I have come to a point where I want to create a method that will copy files recursively from one place to another.
This is not the first time that I ask myself the question:
Should this method be a part of an existing class, or should I ... |
I'm working on a set of automated tests that we use internally at work. Lately, we've been designing classes that implement interfaces in addition to inheritance.
As I understand it, interfaces in Java are used to fulfill a contract. A class that implements an interface must include implementations of any members of t... |
Some products can parse a special syntax in commit messages to extract additional data, such at time tracking information: https://confluence.atlassian.com/display/FISHEYE/Using+smart+commits
To me, this seems like the misuse of one tool to activate a feature on another, but I'm having trouble articulating my reasoning... |
Writing software for a client, and one of their requirements was that the user be able to specify where the application database is stored, be it on the local network or in an online repository.
I can let them choose where to put it, but how do I store that information in the application?
I guess I don't understand how... |
I have read lot of articles which state that code can't be bug-free, and they are talking about these theorems:
Halting problem
Gödel's incompleteness theorem
Rice's theorem
Actually Rice's theorem looks like an implication of the halting problem
and the halting problem is in close relationship with Gödel's incomplet... |
tl;dr
I've been told that in domain-driven design, an identifier for an entity could be a custom value object, i.e. something other than Guid, string, int, etc. Can this really be advisable in a distributed system?
Long version
I will invent an situation analogous to the one I am currently facing.
Say I have a distribu... |
I'm tidying up my company's Version Control Guidelines. One of my tasks is to determine how solutions should be organized in a very broad sense.
I have somewhat come to my own conclusion that one broad requirement to document is that, for the most part, CSProj/VBProj projects should live on their own all at the same l... |
I am fairly new to c# and trying to learn best practices. I've been faced with many situations over the last week in which I need to make a choice between longer+simpler code, or shorter code that combines several actions into a single statement. What are some standards you veteran coders use when trying to write clear... |
One day I was using Git (I'm still using it) and the electricity went down while I was committing.
When I (actually, the electricity) came back, the git repo was corrupt. I don't remember the exact name, but it was something like "invalid refs" or something like that.
It's easy to guess that the commit was broken in th... |
I understand that Agile team should be self organized and self driven,
but is there a provision that I can have someone who will allot tasks to developers and ensure that all user stories will be completed on time??
For example if there are two persons in an agile team who are not self motivated to take up tasks and th... |
Suppose I had a grammar like:
object
{ members }
members
pair
pair
string : value
value
number
string
string
" chars "
chars
char
char chars
number
digit
digit number
I could parse the following example: { "one" : 1234 }
As far as I understand, I should have the tokens ... |
I hope this isn't too off-topic and/or opinion based.
I'm looking for examples and reasons why Java is an acceptable language for education purposes.
Here's why: I learned programming on my own in C at the age of about 15. In school we used Pascal (which I think is quite OK, especially in educational context). In Unive... |
I have a winforms application that connects to a single sql server 2012 database and is executed in many PCs of a company.
I'm having several problems with some transactions inside the application, deadlocks and timeouts so the refactor idea comes to my head.
Actually the app is using DbConnection object (the app start... |
I am engaged in a project that works mainly in AutoCAD to design and manufacture prefabricated building components such as roofing trusses. One of our goals is to redesign a program that was written in LISP that functions in designing roofing trusses. We are to rewrite the LISP code in C# and incrementally implement ... |
I have a problem when designing any application that is either greenfield or a refactored brownfield due to often finding a potential flaw or an uncertainty with the design or architecture that I think up. I waste a lot of time trying to construct a design that I am confident in without a lot of time invested from the ... |
I understand completely how to implement the Decorator pattern, and I also understand what it's intent is.
The Decorator is used in one of two cases:
As an alternative to subclassing - when there are multiple characteristics that an object can have, one could use inheritance in order to create subclasses for all the po... |
Looking at making a GUI library for a game engine. I generally avoid pointers if I don't need them and in my below example I find that I don't and it works, but just curious if this design is generally considered good practice or if anyone has comments on it.
int main()
{
// all widgets are positioned and sized acc... |
So obviously NASA need programmers to develop applications for them, be it VOIP applications, applications for control of machines and AI, etc. But in what language do they actually use for this?
I am thinking of learning how to program an Arduino, or Engduino as we may be witnessing in my Computer Science classes, bu... |
I'm seeing a lot of people say you should never use raw pointers. What about in the case where you store the raw pointer in a class but how they get populated is from getting the pointer of an object that wasn't dynamically created? I'm curious about if this is bad practice and if so how to make it better. This seems i... |
I suspect this is something that many of you have dealt with, and I'm certain there's articles on how to do it, but I can't seem to find them.
My problem is that my various constant classes in Java (read: classes containing lists of static constant values) are too many and too big, and some of them have some annoying c... |
The Situation: I am building a custom PHP application framework. I have implemented a composite pattern so I can build a object tree representing the page to be rendered. Example:
abstract class \Block\BlockAbstract {
protected _blocks = array();
public function __construct($properties);
public function ... |
Despite the long title, my question is fairly simple. Let's say you have a cube in 3D-space and you want to rotate it along the three axes based on the set of instructions provided by a user or elsewhere in the program. How would you simplify, if you will, that set of rotations?
For simplicity's sake, we'll use the not... |
I'm attempting to build a Discrete Event Simulation library by following this tutorial and fleshing it out.
How should I handle logging metrics in my Discrete Event Simulation engine?
If you don't want/need background, skip to The Design or The Question section below...
Simulation
The goal of a simulation of the type i... |
Edit:
OK, so, people said it is unclear what I am asking. I am asking for feedback on this design. Here is an example user story:
As a group admin on the website I want to be notified when a user in my group uploads a file to the group.
Easiest solution would be that in the code handling the upload, we just directly cr... |
Let say you are building an app and you are using the latest library verion from a third party (say ver2.jar). Then you saw an example written 2 years ago, but that example uses the ver1.jar
Now in ver1.jar, there is web.method1(), but in ver2.jar there is no such method. Instead, in ver2.jar you have web.getOtherMetho... |
I have a use-case that can be repaired, but the logic for repairing it is best done in a higher level of abstraction. Just throwing exception/failure is ugly because it's hard to pass back up through the stack the information needed for the parent-layer to know how to fix it.
To explain the the specifics, I have a pro... |
I'm considering using SignalR to send data to a mobile app, but need to have a way to synchronize data while it's closed or pending updates.
Is it a good idea to use Backbone.js <--> SignalR to manage queued CRUD updates to the server? If not, what is?
|
I commonly see stories that have back-end and front-end development. For example, consider a large dialog with a few tables and some dynamic controls. We'll make several stories (maybe one for each table and another for the dynamic control system).
The dev team will then split with one person on the back-end and anot... |
Say a user could enter project data into my software. Each project has 2 variables "size" and "work" and they're related but the relationship is not known. Is there a way to programmatically determine the relationship between the variables based on previous data and forecast the amount of work provided if only given th... |
First ATMs performed tasks like a cash dispenser, they were offline machines which worked with punch cards impregnated with Carbon and a 6-digit PIN code.
Maximum withdrawal with a card was 10 pounds and each one was a one-time use card - ATM swallowed cards!
The first ATM was installed in London in the year 1967, as I... |
As a developer I am fan of static methods.
Recently I come across difference between OOP languages about this static methods.
All OOP language use static method to access any method without creating instance of than class. So we can call this kind of method with just class name.
But some language allow to access stat... |
When I was going through the project on which I am working, I came across a cpp file, which has only functions and static variables.I was wondering why they have not put everything into a class! Whenever the inside functions have to be called, the cpp file is included.
Is this a good design? what are the pros and cons ... |
Here are two ways to instantiate an object:
Option 1:
Thing thing = new Thing();
Option 2: (the factory is a Static Factory, but it could also be a Simple Factory).
Thing thing = ThingFactory.createThing();
Where:
class ThingFactory(){
public static Thing createThing(){
return new Thing();
}
}
Optio... |
In a game I'm making I was about to add a MovementEventHandler, with events like "pre-character-movement" and "post-character-movement". But this class will do exactly the same as a future CurrencyChangeEventHandler.
Should I just be creating a GameEventHandler, which just handles arbitrary event names?
One of the trad... |
Yesterday I read a tweet disparaging Jersey with JAX-RS due to run-time errors. Spray.io was mentioned in the tweet:
Not even 5 minutes using Jersey / JAX-RS and already a runtime error
due to a missing annotation. That's why I like @sprayio: type safety.
https://twitter.com/gbelrose/status/467295643053338626
How d... |
My client's web hosting company changed some web server security rules which made the site not work properly. I spent 4 hours diagnosing the problem and emailing their tech support back and forth.
I'm thinking of billing my client for this, but it could be counterproductive because it doesn't happen that often that I h... |
I have an MVC 5 application that will be used world wide. A number of the pages in the app will require users to enter dates. I'll be using the jQuery datetimepicker plug-in to allow the user to select dates. Or they can enter them manually.
I'm curious what the best practice is for cultures where dates are entered in ... |
Java is designed in a very OO approach, and somewhat even 'forces' programmers to program within the OO paradigm (which can be considered good or bad, a matter of opinion).
However while almost everything in Java is a class or an object, primitive data types (int, double, etc) are not.
While I see no advantages to this... |
I've been working for a while on an app that makes up melodies. Each melody is composed of several phrases (musical sentences, or 'sub-melodies').
Now, I want to improve on this:
The user can press a button to 'like' a melody.
The app saves the phrases (sequence of notes) composing the melody to storage.
These stored... |
I am trying to build a single page web application that will call multiple web services (both SOAP and RESTful) and aggregate the data in the UI.
Initially I though I could do it all client-side, with ajax requests, but I realize that
If there are many requests, and they are fired per user, the data can take a long ti... |
I'd like to write a simulation of Japanese Multiplication to get benchmarks on large calculations utilizing the shortcut vs traditional CPU multiplication. I'm curious as to whether it makes sense to try this.
My Question: I'd like to know whether or not a software math shortcut, as described above is actually a short... |
I am currently in the process of packing my first c# wpf app.
The app will be paid so it requires the user to agree to some terms and conditions.
Is it best to have these built into the installer? Or can I get away with having the user accept them on the website they buy them from during the purchase and before downl... |
Once in a while I encounter a C function in my colleagues' code.
Mostly it is in some helpful objective categories, and those functions are mostly an internal calculation of something or a comparison of values.
Since those guys are not part of the company anymore, I can't ask them why they decided to go with a C func... |
We are trying to create an online-shopping like application in which we have to store a huge amount of data,since the data that will be stored are mostly document like data, the suggestion was to store the data in mongodb and using elasticsearch to add the search functionality, but i also know that elasticsearch itself... |
Consider this piece of code from the PHPUnit manual(I'm using PHP only as an example):
class StubTest extends PHPUnit_Framework_TestCase
{
public function testStub()
{
// Create a stub for the SomeClass class that could be later injected into another class, but removed here for simplicity.
$stub... |
Let's say I use Semantic Versioning for a my project. I'm developing it under FooOS, but the language uses virtual machine(either interpreted language or bytecode based) so any operation system can run it. The thing is, the project interacts heavily with OS-managed things(e.g. pipes, processes, the file system) so if y... |
This is my situation: I have a search results page in PHP where most of the logic resides in a javascript file in order to avoid refreshing the page every time an action is performed. The first thing I do using PHP is filter out and save valid query string values to PHP variables and I make use of the htmlspecialchars ... |
I want to make a system, so that there are certain tasks. For example, let's talk about a game. I want to make it so there are 100+ tasks doing different things, but when the player's magic level is 5, it will do the magic task, if the player's fighting skill is level 5, it will fight. I have that already, however here... |
I'm currently making a game and want to use some textfiles (lists of names) that are covered under the GNU General Public License (or the Attribution-ShareAlike 3.0 Unported License). Do I have to release my whole game under one of these licenses if I only used these (relatively small) files in my game or is it just th... |
I'm developing a website (using Django) which will depend on an API for it's main functionality which is create/update/delete objects.
But the API also provides:
User sign up and login
User relations to their objects
User groups and permissions
This is great but I'm conserned about fully depending on the API for ever... |
In D I can create templates like this:
template Foo(A) {
A add(A a, A b) { ... }
A multiply(A a, A b) { ... }
A concatenate(A a, A b) { ... }
}
What should a template be named ideally? What conventions exist out there? I'm looking to something similar like 'function names must always start with a verb'.
|
C++11 features the new auto type declaration, allowing you to work with an object without ever knowing its actual type.
I use only strongly typed languages - C++, Delphi (Object Pascal), Go, etc and I feel uncomfortable (guilty?) using auto, (or for example the short variable declaration - x:=1- in Go.) It feels like a... |
I am going to develop a software that works with different databases and I'm considering whether to use .NET languages or C++. I've known that .NET features LINQ and ADO.NET but are there features like that in the native C++? Which one works better, faster with databases?
|
I am working on making a system for the automated testing of student assignments. The biggest hurdle I am facing right now is figuring out how to sandbox the testing of the code yet still get and process the results of the test. I need to run it on a VM as there is no guarantee the code will not be malicious.
I would l... |
I’m using the light-weight PHP Fat-Free Framework as a base to form a simple MVC based app with DDD philosophy for the Model layer. I’m aware that DDD is most suitable or enterprise solutions and that applying DDD to simple, mostly data-driven apps is kind of an overkill, but there are some concepts in DDD that I find ... |
I am currently attempting to make a Trading Card Game and I have got a whole array of features working already, yet I am stuck now at the portion where one player can attacker another player (more strictly: the monster cards of another player on the field). The game is designed primarely to be played with two players i... |
I'm using a variant of the MVC pattern. In my GUI code, often the need arises to synchronize "view data" (e.g., selected item) between different views.
For example, let's imagine a vector drawing program. We have two views: the image, and a listview of all objects (rectangles, squares, ...). The currently selected ite... |
I am preparing for interview and try to solve the exercise problems of the book.
3-6. [5] Describe how to modify any balanced tree data structure such that search,
insert, delete, minimum, and maximum still take O(log n) time each, but successor
and predecessor now take O(1) time each. Which operations have to be ... |
I just got done watching an informative Box tech talk by Nicholas Zakas on a javascript architecture for web development:
https://www.youtube.com/watch?v=mKouqShWI4o&feature=youtu.be
This image, which I acquired from http://alanlindsay.me/kerneljs/index.html#nav-what , will give you an overview of the architecture:
Ho... |
So one of my long-standing projects is an online fan-game that's been running for a good four years now, and is at least somewhat well-known among the related community. To give you an idea, Alexa ranks my online game higher than the official website for the franchise my game is based on.
One thing I've been wondering ... |
My Plan
Have a system that holds some objects
Have a winforms-form that displays some key values of these objects
When certain changes occur(object gets add / removed / datat change): Update GUI
My Idea
subscribe my form to events in the objects
update form when objects chamge (/raise events)
My Troubles
winforms... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.