instruction
stringlengths
34
19.9k
I'm looking for a very exotic thing and have no idea if it exists at all in SQL Server 2012. (Please forgive me - my background is in T-SQL, but not yet the fine details of SQL 'programming'.) So, whether this 'this' is a UDF or SP or something else - I don't know. The challenge is to have something so flexible that it...
Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags: class Entity { /** @var EntityFlags */ private $flags; ... } I have a repository for this entity. My goal is to modify flags in the DB. There are two ways I see: Get entity from the repository,...
When learning C# (and OO concepts more generally at the same time) something I found very distracting is exemplified by the following line: ExampleClass exampleObject = new ExampleClass(); It's the apparent redundant repetition that bothered me. Some light dawned when I grasped the difference between declaring a varia...
I have a web based project that allows users to work both online and offline and I'm looking for a way to generate unique ids for records on the client side. I'd like an approach that works while a user is offline (i.e. unable to talk to a server), is guaranteed to be unique, and is secure. By "secure", I'm specificall...
Let's say I am doing a 2D application with the following design: There is the Level object that manages the world, and there are world objects which are entities inside the Level object. A world object has a location and velocity, as well as size and a texture. However, a world object only exposes get properties. The...
Templates are nice for similar algorithms of different data types. Say I make a template stack of a basic data type... Stack<int> stck(10); stck.Push(5); I'd pop it... int x = stck.Pop(); x would be 5. If I call pop again, there are no items, so I have the method just return 0 for null. It could be something else, b...
I have a summary tool written in python that reads input files, and writes them into a summary file. I have the following stipulations: No duplicates. If it exists, add a count to it. Is it better / faster to write one GIANT output file THEN de-duplicate the entries or to dedupe as you go (ie, each write command ch...
Consider the following "if cast": class A { public void f1() { ... } } class B : A { public void f2() { ... } } A a = foo(); // might return A or B if ( a is B ) { // Inside block, implicitly "redeclare" a as type B // It's B, go for it a.f2(); // Wouldn't compile. a = new A(); } We don't ...
I have 5 user controls on the page and each control implements it's own interface that contains properties and events. In order to enable communication between user controls, I am creating a property of target user control inside other user control. Through this property, it's state can be altered and be able to regist...
I was wondering, if it makes sense to encrypt passwords for external services stored in my config file with an symmetric encryption algorithm? On the one hand I think, if someone gets access to the config file, he will probably also get access to the code and it will relatively easy to decrypt the passwords... on the o...
Can someone help me to find a easy way to parse XML? I have an iOS 7 Application using Google Map API. I tried to learn this on my own. I try to create an application that uses Web Services like Google Map. These web services use HTTP requests to specific URLs, passing URL parameters as arguments to the services. Gener...
In my RESTful API, I have Users, Applications, and Tokens. An application has an owner, which is a user. A token is linked to both an application, and a user. A user has both public and private representations: GET /user - Retrieve current authenticated user GET /users/:user - Retrieve given user An application has a...
I'm trying to make a number of data classes for my C#/XNA game, which would essentially be a wrapper around T[,]: public interface IGrid<T> where T : struct { Point Size { get; } T this[int x, int y] { get; set; } } For example, I might have a Heightmap object which is essentially an IGrid<float>, or I mig...
When I compile a C program, it is compiled first to assembly code, then assembled into machine code. I'm curious why it doesn't just convert straight to machine code in the first place.
I have a library implemented in C++ which has a C interface. This C interface is, for all intents and purposes, the only way to use this library. C++11 seems to discourage the use of raw pointers but neither shared_ptr or unique_ptr are suitable in this case. From what I understand, intrusive_ptr is an option, but I am...
Might be kind of an odd question. A guy writing a C++ compiler (or whatever non-VM language): Does he need to be able to read/write raw machine language? How does that work? EDIT: I am specifically referring to compilers that compile to machine code, not to some other programming language.
I connected iPod with Arduino using serial (UART) connection. Arduino sends 0-1023 number (so it's two bytes) as it's samples light sensor value. I'm asking about advice about simple and reliable communication protocol. Do I need magic constants to start/stop communication. Maybe I need sent data of small chunks. N...
I have singleton in Java and I have realized, that I could make its fields static and it would work same way as regular instance fields. Would there be a performance / optimization difference? If so, what would turned out better? Is there a preferred way to implement singleton fields? (again, I am talking fields, not ...
I am writing a static library for C/C++ (personal project). As my headers became rather large, I thought that splitting my headers would be a good idea. Right now a header looks like this: MainClass.hpp: namespace impl: implementation details enclosed in a namespace impl forward declarations of classes declared below...
Most BST examples show a sample of a BST with unique values; mainly to demonstrate the order of values. e.g. values in the left subtree are smaller than the root, and values in the right subtree are larger. Is this because BSTs are normally just used to represents SETs ? If I insert an element say 4 which already exist...
Problem: The Oscar Committee wants to decide which person should get the best actor award among the given N actors.For that they decided to use a random function random_bit() which returns either 0 or 1 with equal probablity. For the results to be fair,the committee was asked to generate a random number between 1 to N...
I was looking at the google coding guide [here] and they do not recommend that one use the using namespace or namespace::function - if I did not misinterpret it. Does this apply to std as well? cout<< does not work without it. This book, recommends the same. So how do I go about using cout<< without using namespace std...
Currently I am developing Multi-Branch Retail software. All branches have the same set of items. However, each one has its own stock quantity. My question is, what is the best practice to apply in branch quantity control for items? I am currently thinking about the following design: Item Table ======== -Id -Descri...
We are small start-up now, we don't have a DBA. if our project succeed, it will have a lot of data that will likely need to be distributed over several machines. So we want to make that step easier, so what we should take in consideration now to make it so? What we can think of now is using uuid instead of autoincremen...
I know absolutely nothing in low-level stuff, so this will be a very newbie question. Please excuse my ignorance. Is machine language - the series of numbers to that tell the physical computer exactly what to do - always binary? I.e. always composed of only zeros one ones? Or could it also be composed of numbers such a...
I have designed an management system for a medical practice and I am writing the design specification and I am kind of stumped by what to write for a section. It asks for me to write about the components of a system but I am perplexed. What exactly are components within a system? Is this generally considered as the fe...
I was reading the paper Out of the Tar Pit authored by Ben Moseley and Peter Marks when I came across the following section on page 25 regarding essential mutable derived data: Essential Derived Data — Mutable As with immutable essential derived data, this can be excluded (and the data re-derived on demand) and hence ...
I am creating , a site like gsmarena , can any one help me with database design to store mobile specifications like here "http://www.gsmarena.com/asus_padfone_infinity_lite-6120.php" as user can add more custom specification ,
Well known is the split of a whole application into several bounded contexts to emerge an Ubiquitous language. while practicing Domain-Driven Design. In general, 1 bounded context = 1 archive file ready to be deployed (JAR / EAR / DLL etc..) My question concerns the bounded contexts deployment regarding hardware optim...
I'm seeking vital naming of string filename parameter in parameter list used in various methods where filename with full path is expected. In many cases also UNC path can be actually supplied as full path because many libraries handle it natively. I usually call the parameter just filename, but it can be misleading in ...
I've been finding a lot of blog posts claiming JS encryption is unsafe, here's a couple of detailed ones: http://www.matasano.com/articles/javascript-cryptography/ http://rdist.root.org/2010/11/29/final-post-on-javascript-crypto/ My question is, if browsers truly are inherently unsafe then, by extension, entering any P...
I have a controller method like listed below whose argument is annotated with @Valid to validate PasswordChange object using a Hibernate validator @Constraint. Both PasswordChange and a sample constraint are listed below. As you can see, I am injecting up loginDao inside the constraint. Is this an anti-pattern ? The o...
Consider a basic js object: var obj={x:1,y:'2'}; Is this stored internally as a hashtable or does js use a different mechanism for key value pairs? If they are hash tables does anyone know how they handle collisions?
I'm a new app developer and after like 20 downloads of my app (free and ad-free) I already got two feature requests, and I'm not going to implement either. Should I respond to these feature requests and if so, how? I'd prefer not responding at all because I'd rather spend the time to work on my app, but being a new dev...
I'm starting to design a web application, and I'm evaluating some decisions regarding the general structure of it. My use case is as follows: I plan to have multiple customers on a single server. Initially there won't be many customers, probably two to start (but the system should be ready for more, of course). As I'm...
I am designing a HTTP-based REST API. Let's say I have an entity called Entity that has a bunch of properties. Some of its properties are files. Let's say Entity has following properties: name: string description: string photos: array of photos videos: array of videos API is designed to be used from mobile devices and...
Running Apache ZooKeeper (this applies to PAXOS style system just as well) with 2 members - which is not recommended - does not make sense, because if either member1 goes down member2 goes down there's a network partition between member1 and member2 , ZooKeeper will declare business hours to be over, as there's no s...
I've just been learning Unit Testing and I'm trying to understand how I could incorporate it with a project with existing code. Say I wanted to write tests for a specific class in that project, but that certain class requires an instance of another class for the the methods to be run and/or tested. How should I approac...
I am inheriting a legacy code. The legacy code has lot of web forms and each web form does not have much of functionality other than hosting a user control. My question is - Should we create a user control even if that control is not used in any other web form ? Are there any hard benefits in creating user controls ...
So I have been googling about this OpenSSL heart-bleed thing and somehow sees that it is caused by the heartbeat extension which requires client to ping the server to show its aliveness and it all comes to this memcpy function in C which is meant to copy from the source array to the destination array with the user spec...
I have an existing database app written in D7 with apollo databases. The client has given me a fast desktop with 24gb ram Can I somehow load the database files into ram to speed up processing? With millions of records some procedures take 1/2 hour or more, mostly due to disk read/write
I want to implement a parallel clustering algorithm "out-of-core" in CUDA. My CPU has 12GB of RAM and GPU has 4GB of it. What I want is that the entire dataset should be on the disk, and I can pick blocks of data from it, put the blocks on CPU memory, pass them to the GPU, process it there and store the result back on...
I was looking at the terms of use for CocoonJS and noticed this section License Grant. By uploading User Content via the Services, you expressly grant, and you represent and warrant that you have a right to grant, and do so grant, to Ludei, a royalty-free, non-exclusive, worldwide license to use, reproduce, modify, pu...
I am coding a program which has persistent data (the MELT monitor, related to GCC MELT). The data is persistent because it is expected to be read and overwritten by most executions. (That data is in particular made of abstract syntax trees) Currently, this persistent data is an Sqlite database. Of course, I am backing ...
Based on the same example for this question. Within the Pro ASP.Net MVC 4 by Adam Freeman, there is a discussion on aggregates and aggregate roots with a simple auction system. There are members who bid, items that are bidded upon, and bids. The author says that there would be an aggregate of Item and Bid with Item b...
Quick example: HM observes CM SM observes CM HSM observes HM and SM, but wants to be updated only after both have their new value derived from CM. More detail: (this is still a made-up example, but the closest and simplest I can come up with) class ColorModel: can store any RGB color. observable by a ColorObserverIn...
Suppose I have two or more UserControl implementations with vastly different implementations but near identical code-behind. One strategy to avoid code duplication is as follows: Change each UserControl to inherit from a new abstract class, AwesomeUserControl Move all of the codebehind from each UserControl into Awes...
Basically I am writing a MSMQ based multi-threaded messaging pattern utility library. It's like a set of components all inherited (directly or indirectly) one class that's called my base component class. Each of these messaging components have the ability to listen to multiple queues via multiple threads and to proces...
I'm working on an Open Source software project (LGPL) which uses another LGPL-licensed software. To make it easier for users and developers I'm delivering and linking against the compiled thirdparty. As far as I know I have to include the sources and license-statements of LGPL software if I'm delivering and using it in...
What is a web Application Programming Interface? Many common sites provide APIs. Why are they needed, and what function do they provide? How does one access a web API?
I'm trying to convince the designers of a language that multi-line comments with an arbitrary start and end are important, and should be included. Currently there is only a "comment-to-end-of-line" primitive. Their line of argumentation reminds me of what some say about why you should use spaces instead of tabs. Basi...
Or rather, practically applying PRIMES in P. I've heard a lot about "PRIMES in P", or the "AKS algorithm". It is, to oversimplify slightly, a very fast way of finding prime numbers. However, while I've tried reading the original paper (the revised "V3" seems to have vanished from the internet), it's a bit above my comp...
I have been using Entity Framework for a few years. I have flip-flopped between calling out to repositories in my business logic or using lazy loading to retrieve data as I work my way through the code. The problem with the first approach is that a single business object can end up relying on a lot of repositories (in ...
Just started learning about classes in C++ and I'm have trouble understanding why object orientated programming (OOP) is useful. I understand the syntax, how to use them etc. But I'm still confused as to why OOP is advantageous. Here are some specifics I'm having trouble with: Private variables. What is the use? Many ...
Consider an application that stores a set of records that contain: Description Cost Purchase Date I'd like to be able to allow users to utilize natural language to search the dataset. For example, the search expression: blue from last month less than $20 would translate into (Linq as an example only - correctness o...
I want to write a program in Java using RS-232. But I am unable to find the java.comm Package for the windows. Which library should I use for this purpose? http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-misc-419423.html The only package avaiable here are not for Windows. Can you ...
I'm building websites in ASP.NET MVC and I quickly figured out that my models are getting harder to organise as they grow. What I normally do is create one model to add and edit data. But in my add view I have 2 extra properties. So I'm re-using the same model with 2 extra properties but I don't use these my edit view....
I am trying to implement Golomb coding, but I don't understand how it's tuned to obtain optimal code. It is said that Golomb coding uses a tunable parameter M to divide an input value into two parts: q, the result of a division by M, and r, the remainder. The quotient is sent in unary coding, followed by the remainde...
I am about to start a new ASP.NET MVC5 project and I am planning the authentication / authorization requirements at present. The client wants Windows authentication, to prevent their users having to remember another new password. The site is web facing, so the downside would be an ugly pop up box asking for their crede...
For a long time I've tried to get my head wrapped around the visitor pattern, and somehow this thing keeps being rather fuzzy to me. I'm currently under the impression it is only useful to apply operations on objects that implement the Composite pattern. At least as far as PHP is concerned. Is that an accurate observat...
I use git for my personal projects, so I have never run into any issues with Git, however I had a discussion at work today and its something that I haven't thought about. In TFS you can store your changeset into a shelveset, this shelveset can be viewed by other developers, say for a peer review. From what I understand...
I was looking at Jcrop library code for scaled image size calculation, but I couldn't clearly understand algorithm used in following function: https://github.com/tapmodo/Jcrop/blob/master/js/jquery.Jcrop.js#L187 function presize($obj, w, h) { var nw = $obj.width(), nh = $obj.height(); if ((nw > w) && w > 0) {...
I have started building a charting library on top of d3js using javascript's inheritance. My goal is to develop reusable and fully customizable chart components. I read the article: Towards Reusable Charts. Then, I went through the source code of nvd3. NVD3 uses boiler plate code in each chart like: copying and pastin...
I am writing a MATLAB application that makes fairly heavy use of the MATLAB File Exchange. Most of the functions I use from here fall under the BSD license. My application is being deployed for internal use only and is not meant for public consumption. While my particular case uses code that falls under the BSD license...
I am using PHP and designing some abstract classes. I can declare properties with constant values within my abstract class and access/overwrite them from any class which extends this without re declaring them within any of the extending classes. A benefit to this is less repetitive typing but the downside that overtime...
Is there a good way to run a C# application on clientside in lieu of JavaScript? I have done some front end work with JavaScript and backend C# for web developing at an old job, but I am interested in hosting a website myself soon. I have a C# application I would like to be open source, but before people care to downlo...
I just came across this article, and in particular, this answer. Essentially they're talking about returning self from instance methods to allow for method chaining. That being said, one of the first thoughts that came to mind was, Why not always take instance methods with void return types and make them return this ...
I have heard/read mixed things on whether to start with an object model or a data model. And more people say to starting with an object model as it will ease your data modelling. My question is, Shouldn't an object model always drive the design of data model? Why and When would a data model design be different than an ...
For a typical if...else wrapped with exception handling, is something like the following example a recommended practice to avoid code duplication? try { if (GetDataFromServer()) { return ProcessData(); } else { throw new Exception(); } catch(Exception ex) { return null; } in...
Imagine a small local business (in my case a dog daycare) with a few dozen part-time employees . The goal is to automatically create weekly staff schedules. My question is about what algorithmic approaches to explore for this problem. There are many constraints to keep in mind, chiefly (1) the availability of the staff...
Recently we fitted a 4-Tier Architecture in our project composed by the following four main layers : User Interface Layer. Data Access Layer. Domain Layer. Business Layer. All the layers fulfill their usual roles in 4-Tier Architecture and interact which each one in the usual way. We use SVN to maintain our CVS. My p...
I need to implement a Cursor class to perform operations on a Document object, which is implemented internally as a simple list of rows. The Cursor class must have methods such as moving around the Document, add lines, remove lines, insert text in a given position etc. The problem I have is relative to the details of t...
In C# generics, we can declare a constraint for a type parameter T to have a default constructor, by saying where T : new(). However, no other kinds of constraints like this are valid - new(string) for example, etc. From a language design and/or implementation perspective, what is the reason for this? Is there somethin...
Sometimes I find myself wanting to run the same code from a few different spots in the same function. Say I have some function func1, and I want to do the same thing from a few different spots in func1. Normally the way to do this would be to write another function, call it "func2", and call func2 from several differen...
So lets say we are creating a simple "modular system" framework. The bare bones might be the user management. But we want things like the Page Manager, the Blog, the Image Gallery to all be "optional" components. So a developer could install the Page Manager to allow their client to add a static home page and about pag...
I've been working on a game in my spare time. I'm pretty much done defining the primitives and until today everything was pretty well segmented and encapsulated but now it's come time to implement path finding (and other ways for the objects to interact with each other). Here path finding requires at minimum a knowledg...
I have a Producer/Consumer implementation where the number of consumers is configurable (this is a form of configurable throttling). The producer and consumer are kicked off like this: var cts = new CancellationTokenSource(); var processCancelToken = cts.Token; Task.Run(() => Parallel.Invoke(new ParallelOptions() { Ca...
Is there any specific reason driving Python files to often be so large? Python files may contain several classes within one file, and some files go up over 10k lines in length. This seems to go against the idea of modularity and encapsulation. Also it doesn't seem "Pythonic" in the first place, considering IMO it can b...
We have a service to return messages. We want to limit the number returned, either allowing the caller to specify the max number to return, or else to use an internal hard limit. We also have thought it would be nice to include in the response whether more messages are available. The "best" way to go about this is not ...
If I have a polyline made up of any number of vertexes, what is an efficient algorithm for tracing around the boundary of this polyline? There are 4 situations to consider: The polyline does not intersect itself and has no colinear edges. The polyline does not intersect itself but has an interior or exterior loop. The...
I use an MVC web framework to create an application which contains a hierarchy: Location <1-N> Devices <N-M> Services I have a number of Locations. Each Locations can have several devices (represented by an 1-N relationship in the database). Each device runs services. The services (like http, ftp, etc) are defines in ...
Someone told me Session or HttpContext.Current.User will return different value when we are working with ajax postback, in case of when the are so many user are live to site. For example, suppose there are 1000 people are online in site, and from them 100 call ajax method/ wenmethod and on this we might get different v...
In most cases, it is possible to create both a native compiler and an interpreter for a programming language. The compiler would simply convert the source code to machine code, and the interpreter would simply execute the source code (or some IL produced by a compiler). However, I'm not sure about languages with garbag...
In a non-agile development team a lead developer generally: Sets the standard (coding and otherwise) Researches new technologies for the team Sets the technical direction for the team Has the final say on matters Designs the architecture of a system However an agile team works differently: An agile team will rely on...
I have an eCommerce platform that creates a basket as soon as the user lands on the site if they don't already have one (from session or cookies). It then stores the basket information in session and in cookies to remember what the user has added to their basket for a month. The problem is if they aren't capable of hav...
For a long time I worked almost exclusively with input/output streams in java. However a few years ago I started exploring async I/O as well (e.g. running on jboss netty). However when working in the async I/O world, I could not reuse any of my sync utilities. I also had to start on a rather large library of new I/O ut...
I want to produce maintainable code for configuring one or multiple classes differently depending whether in a production or development environment. For example, making a Paypal class/object that handles API calls to Paypal, using different settings depending on some sort of global switch set to either Dev or Live. Th...
Why did Microsoft choose to change the resources management system from .NET's RESX files? RESX had useful code generation, providing developers auto-completion for resources names and outputting IMHO very readable code. The new RESW format is as far as I know, the same bare XML files, but without any code generation, ...
I keep hearing people say Banking systems like ATM use Eventual consistency model for data synchronization, but I am wondering if it is true. Definitely the amount you withdraw might be delayed showing in your banking statement, but I assume they won't let the amount of your banking account inconsistent at any given t...
I'm in charge of defining an XML schema for some data; the plan is to have various systems (all under our control) upload XML files that match this schema to a central server for processing. I don't have much knowledge of the design of these other systems, so I'm working collaboratively with those system experts to mak...
I have designed and implemented, for my final year in college, an autonomous robot with Arduino board microcontroller. The robot wanders around an area, avoids obstacles and tries to detect intruders. I have to do some testing for this project . Could anyone help me by telling what test procedures I can perform in pro...
Generally speaking, RESTful API's are very good for representing resources and collections of resources. http://example.com/resources http://example.com/resources/item17 And we are good, if we work with resource. However, what should be done, when you need to expose API which does an action which doesn't create/upda...
I am writing an application in Java which use MVC pattern design. I have 4 major classes: Main, Controller, Model, View. Main initialize the other three and run launchMenu() in a infinite loop, a method included in Controller. This launchMenu from Controller runs a launchMenu method of another class: MenuHandler, which...
We want a simple tool to parse PDF forms, retrieving just the associated field names and user values. PDFSharp would be a good option for us, as it is under the MIT license, but it is a few versions of Acrobat behind - so not going to work. The most popular library (from what my searches have revealed) seems to be iT...
I have a website that allows for users to paste content (like snippets of code, etc) for sharing. Like Pastebin and Github, I also have a "raw" link that will display the raw contents of those posts. However, some users are posting up code and then using our service as a host for distributing content that violates our...
I have an app where I need to synchronize some entities (simply download latest versions of entities from server to client). Entity has bunch of text properties and bunch of resource links (referenced by ids, URLs, whatever). For example let Entity has three properties: id: integer, name: string, photos: array of photo...
"The Interface-Segregation Principle (ISP) states that no client should be forced to depend on methods it does not use." The decorator pattern is a design pattern to decorate a method of a class. For this, the decorator implements the same interface as the decorated object, so it can take its place. But doesn't this me...
I have a question about Thingiviews license. I have a site that has to do with 3D Printing, it is not done yet but I was wondering if I would be able to use it on my site, The big reason I am asking is because it will be used to show 3D models that will eventually be made and sold, like shapeways kinda, so I am not se...
I want a quick way to roll back our production build in the event of any mishaps - a one-click solution, if you will. My gut is telling me that this is important - and I believe that my gut is correct, but I want implementation advice. My current thought is to start a local repository on our production server, and simp...
I'm not even sure how to define this difficulty. It reminds me of the test a couple of prospective employees did on me before I got a job. They would pick an object in the room and then I'd be allowed to ask questions to help myself determine what that object is (much like 20 questions). I was ridiculously good at this...