instruction stringlengths 34 19.9k |
|---|
Say we take any C library such as libpng or libvorbis and convert it so that it compiles as C++ (only the minimum changes to make it compile as C++ code).
Can the compiler do extra optimizations when its C++ code? Is there any sort of benefit to be gained by porting the code to C++? What are the downsides that might ca... |
Please bear with me if the question looks not well structured.
To put you in the context of my issue:
I am building an application that invoices vehicles stay duration in a parking. In addition to the stay service there are some other services. Each service has its own calculation logic.
Here is an illustration (plea... |
Disclaimer On Absence of Code:
I have no code to post because I haven't started writing; was looking for more theoretical guidance as I doubt I'll have trouble coding it but am pretty befuddled on what approach(es) would yield best results. I'm not seeking any code, either, though; just direction.
Dilemma
I'm toying ... |
PROBLEM:
We have N physical machines(PMs) each with ram Ri, cpu Ci and a set of currently scheduled VMs each with ram requirement ri and ci respectively
Moving(Migrating) any VM from one PM to other has a cost associated which depends on its ram ri. A PM with no VMs is shut down to save power.
Our target is to mini... |
I'm looking for an algorithm that would be able to determine the optimal combination of two variables, but I'm not sure where to start looking.
For example, if I have 10,000 rows in a database and each row contains price, and square feet is there any algorithm out there that will be able to determine what combination ... |
I come across the following code with a lot of frequency:
if (myArray.length == Constants.ZERO_INT)
or
if (myString != null && !myString.equals(Constants.EMPTY_STRING))
Neither of these makes much sense to me. Isn't the point of having a constant pool for ease of code appearance and to allow for modularity? In bot... |
I'm fairly new to programming, and I've been working on many personal projects, which I'm concerned can come across as silly and unprofessional. The kind of projects I have are a Reddit Image Downloader and a tool for GMs to use in roleplaying games.
I want to start building up a GitHub account for projects in my chose... |
I have several files (nearly 1GB each) with data. Data is a string line.
I need to process each of these files with several hundreds of consumers. Each of these consumers does some processing that differs from others. Consumers do not write anywhere concurrently. They only need input string. After processing they upda... |
Wikipedia defines software orthogonality as:
orthogonality in a programming language means that a relatively small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the language. The term is most-frequently used regarding assembly instruction s... |
I have a RESTful API, one of the resource has a state that is determined collectively by multiple servers, not all of them belong to us. One of the operation on this resource will have to modify the state of multiple servers. The client sends a POST request to do this operation to our API server and our API server send... |
This question is about good design practice in programming.
Let see this example, we have 2 interrelated tables:
Table1
textID - text
1 - love..
2 - men...
...
Table2
rID - textID
1 - 1
2 - 2
...
Note:
In Table1:
textID is auto_increment primary key
In Table2:
rID is auto_increment primary key & te... |
Recently I made a question about Java classes implementing methods from two sources (kinda like multiple inheritance). However, it was pointed out that this sort of need may be a sign of a design flaw. Hence, it is probably better to address my current design rather than trying to simulate multiple inheritance.
Before... |
The actual GPL License (that is, the text that contains the words "The licenses for most software and other practical works are designed...") is a document; I would assume therefore that it is under some sort of copyright?
What license is this license licensed under?
That is, if I were to include the body of the GPL Li... |
Is it considered an overkill for console application to be design like MVC , MVP or N tier architecture? If not which is more common and if you can link me to simple example of it.
I want to implement a tic tac toe game in console application.
I have a solution which hold two projects: TicTacToeBusinessLogic (Class... |
How can one go about modelling highly specific business requirements, which have no precedent in the system? Take for example the following requirement:
When a purchase order contains N lines, is over X value in total and is being recorded against project Y, an email needs to be sent to persons A and B with the detai... |
Imagine a system where there are data sources which need to be kept in sync. A simple example is model - view data binding by MVC. Now I intend to describe these kind of systems with data sources and hubs. Data sources are publishing and subscribing for events and hubs are relaying events to data sources. By handling a... |
I have list of video files (loaded from database), each with start and end time of requested interval:
# file begin end
v1.mp4 1:01 2:01
v2.mp4 3:02 3:32
v3.mp4 2:03 5:23
And I need to create single video file containing these intervals:
[0:00]---v1---[2:00]---v2---[2:30]---v3---[5:50]
I preff... |
I am writing the documentation for a piece of software which I have made but I don't understand what it means in some aspects.
It asks me to write about backup procedures but what exactly does this mean? Does this mean like backing up the database on another hosting service or something else entirely?
I am dumbfounded ... |
I am following a textbook in which I have just come across method overloading. It briefly described method overloading as: when the same method name is used with different parameters its called method overloading.
From what I've learned so far in OOP is that if I want different behaviors from an object via methods, I ... |
I'm considering changing my GitHub username from the old alias I was using as a kid to my real name. I'm concerned about my repository URLs. GitHub will redirect the old URLs, but if someone creates a new account using my old username and creates a repository with the same name as one of my repositories, the URL redire... |
I have an application that has several dependencies, including a Matlab library and a Microsoft Windows Media Player ActiveX control. How would I graphically depict the internal architecture of this application for documentation purposes? Would a UML structure diagram be appropriate? If so, would it be as simple as the... |
Let's say that we have a small enterprise web (intranet) application for managing data for car dealers. It has screens for managing customers, inventory, orders, warranties and workshops.
This application is installed at 10 customer sites for different car dealers.
First version of this application was created without ... |
I design and implement languages, that can range from object notations to markup languages. In many cases I have considered restrictions in favor of sanity (common knowledge), like in the case of control characters in identifiers. There are two consequences to consider before doing this:
It takes extra computation
It ... |
I am building a turnbased game on nodejs using socket.io and redis as the datastore. I am planning on hosting the game on AWS opsworks with the ability to scale by adding more nodes.
How should I structure the application so that I can have setTimeout like behaviour to work correctly in the event that the node that tr... |
Say Alice and Peter each have a 4GB USB flash memory stick. They meet and save on both sticks two files named alice_to_peter.key (2GB) and peter_to_alice.key (2GB) which contain randomly generated bits. They never meet again, but communicate electronically. Alice also maintains a variable called alice_pointer and Peter... |
I'm about to use the 'strategy' pattern in my iOS app, but feel like my approach violates the somehow fundamental MVC pattern.
My app is displaying visual "stories", and a Story consists (i.e. has @properties) of one Photo and one or more VisualEvent objects to represent e.g. animated circles or moving arrows on the ph... |
I have some experience with OOP and RDBs, but very little exposure to web programming. I am trying to understand what non-trivial types of problems are solved by ORM. Of course, I am familiar with the need for data persistence, but I have never encountered a need for persisting relationships between objects, a situatio... |
is polymorphism only possible when there is a scenario of inheritance or is the implementation of polymorphism not dependent on inheritance.
Or is polymorphism mainly usefull when there is inheritance ?
|
I come from a C background and I'm now learning OOP with C++. As an exercise (so please don't just say "this already exists"), I want to implement a wrapper for BLAS that will let the user write matrix algebra in an intuitive way (e.g. similar to MATLAB) e.g.:
A = B*C*D.Inverse() + E.Transpose();
My problem is how to g... |
I have a question regarding the specifics of object creation and the usage of properties. A best practice is to put all the properties into a state such that the object is useful when its created. Object constructors help ensure that required dependencies are created.
I've found myself following a pattern lately, an... |
This question is going to be a little long. Please bear with me.
Something that happened in a project of mine made me think about how to safely copy objects. I'll present the situation I had and then ask a question.
There was a class SomeClass:
class SomeClass {
private Thing[] things;
public SomeClass(Thing[... |
I'm looking for a commonly used programming term to describe a software-engineering phenomenon, which (for lack of a better way to describe it) I'll illustrate first with a couple of examples-by-analogy:
Scenario 1: We want to build/extend a subway system on the outskirts of a small town in Wyoming. There are the usu... |
I have been given a huge task of migrating few functionalities from jQuery to AngularJS. I have been pretty good at Angular by now. But I want to dive deep and create futuristic, sound architecture. BAs are seating on my neck, wanting to get my tasks as quickly as possible. I prefer doing something once and right vs ke... |
I am working on geographical data which represents the road network of some city and I need to automatically fix inaccuracies in the data.
Data was manually produced by “drawing” the road network over some actual map overlay with a geographical system like qgis. As a result, many road portions which connect in reality... |
Xamarin 3 was released last week with a great new addition: Xamarin.Forms . This triggered our attention because we've been using such a system for a couple of years now. We've developed it by ourselves and used it for a bunch of projects.
We've been looking for a way to make this project open source but we didn't mana... |
In my company, before delivery of any project, my boss asks my seniors to review programs written by me or other team members or sometimes boss also sits with us for review.
I think it is a good way of getting knowledge, but sometimes when programs are working fine, they don't work same after review and I need to look ... |
Say, for example I published my code under GPL.
A month after release, I decide evil corporations (*cough*) are allowed to use my code after all, because it's so brilliant and bug-free. Can I just relicense my own code, or have I locked myself out of the right to do so?
|
This is not the usual "I don't want to write code during an interview", in this question the assumption is that
I need to write code during an interview (think about the level of rewriting the quicksort or mergesort from scratch)
I know how the algorithm work or I have a basic idea of how I should start working from t... |
I have a Rails model email_condition_string with a word column in it. Now I have another model called request_creation_email_config with the following columns
admin_filter_group:references
vendor_service:references
email_condition_string:references
email_condition_string has many request_creation_email_config and ... |
Assume we are getting some statistics from a customer which we analyse and we send our comments to the customer. Now, the customer tells us that the statistic they computed between January and March are based on a wrong methodology and sends us corrected series. We want perform analysis with the wrong and with the co... |
I have just completed an exercise from my textbook which wanted me to write a program to check if a number is prime or not.
I have tested it and seems to work fine, but how can I be certain that it will work for every prime number?
public boolean isPrime(int n)
{
int divisor = 2;
int limit = n-1 ;
... |
Which of the following two models makes more sense? I'm leaning towards the first one because there can only be one default child.
The examples are in C# but I think it can apply to other languages too.
Here DefaultChild holds one of the items in Children.
class Parent
{
int ID { get; set; }
Child DefaultChild... |
I've seen people talking about Free Monad with Interpreter, particularly in the context of data-access. What is this pattern? When might I want to use it? How does it work, and how would I implement it?
I understand (from posts such as this) that it's about separating model from data-access. How does it differ from the... |
URL is an URI which identifies a resource by location.
Resource representation is a view of resource's state. This view is encoded in one or more transferable formats, such as XHTML, Atom, XML, MP3 ...
URIs associate resource representations with their resources
a) So I assume URI identifies a resource and not resourc... |
I am designing a class Master that is composed from multiple other classes, A, Base, C and D. These four classes have absolutely no use outside of Master and are meant to split up its functionality into manageable and logically divided packages. They also provide extensible functionality as in the case of Base, which c... |
I used to analyse performance of programmers in my team by looking at the issues they have closed. Many of the issues are of course bugs. And here another important performance aspect comes - who introduced the bugs. I am wondering, if creating a custom field in the issue tracking system "Blamed" for reporting the pers... |
Please consider the following scenario:
We are working on a JavaEE project for which the scalability starts to become an issue. Up until now, we were able to scale up but this is no longer an option. Therefore we need to consider scaling out and preparing the App for a clustered environment.
Our main concern right now ... |
Apple launched its new programming language Swift at WWDC14. In the presentation, they made some performance comparisons between Objective-C and Python. The following is a picture of one of their slides, of a comparison of those three languages performing some complex object sort:
There was an even more incredible gra... |
I want to make a non-english programming language that is identical to what CoffeeScript is to JavaScript. What I mean is that I don't want to build my own design or syntax. Just want to have a non-english programming language that compiles to JavaScript. I want to follow everything CoffeeScript fellows so I don't real... |
I am a Java developer, and I rarely write GUI program in C. However, I noticed that many GNU's projects, such as PSPP, R, Dia, etc., are written in C, instead of Java or C++.
I personally don't mind this, but I am really curious why GNU favors C so much. My understanding is that C is the one that supports the least in ... |
Recently I have been developing my own API and with that invested interest in API design I have been keenly interested how I can improve my API design.
One aspect that has come up a couple times is (not by users of my API but in my observing discussion about the topic): one should know just by looking at the code calli... |
Background
The product i am working on has a very long lookup-table. the table contains static data and cannot be auto generated. there are about 500 rows and 10 columns. columns have mostly integers and strings. to complicate the matters, there are actually two such tables. every row in table-1 maps to zero-or-more ro... |
I have a few files that are ~64GB in size that I think I would like to convert to hdf5 format. I was wondering what the best approach for doing so would be? Reading line-by-line seems to take more than 4 hours, so I was thinking of using multiprocessing in sequence, but was hoping for some direction on what would be th... |
I'm looking for a design pattern that addresses the following situation:
There exists a list of tasks that must be processed.
Tasks may be added at any time.
Each task is wholly independent from all other tasks.
The order in which tasks are processed has no effect on the overall system or on the tasks themselves.
Ever... |
I am struggling with architecture on a new project. I am using the following patterns/technology.
CQRS - anything going in goes through a command
REST - using WebAPI
MVC - asp.net mvc
Angular - building a spa
nhibernate
I belive this provides some great separation and should help keep a very complex domain from growi... |
If I'm used to use ' for string literals in PHP, would it be better if I'll stick to it in any situation or can there be exceptions when it would increase readability?
example:
$foo = "bar'baz"; // this may be easier to read
$foo = 'bar\'baz'; // but this would stick to the convention
|
I am about to make two assumptions. Please correct me if they're wrong:
There isn't a recursive algorithm without an iterative equivalent.
Iteration is always cheaper performance-wise than recursion (at
least in general purpose languages such as Java, C++, Python etc.).
If it's true that recursion is always more cost... |
When writing a callback, when is best to have the callback return a value, and when is it best to have the callback modify a parameter? Is there a difference?
For example, if we wanted to grab a list of dependencies, when would you do this:
function GetDependencies(){
return [{"Dep1" : 1.1},
{"Dept2": ... |
I'm seeing some code like this in our code base, and want to refactor it:
(Typescript psuedocode follows):
class EntityManager{
private findEntityForServerObject(entityType:string, serverObject:any):IEntity {
var existingEntity:IEntity = null;
switch(entityType) {
case Types.UserSetting:
ex... |
I've read quite a few articles on the difference between POST and PUT and in when the two should be used. But there are still few things confusing me ( hopefully questions will make some sense ):
1) We should use PUT to create resources when we want clients to specify the URI of the newly created resources and we shoul... |
I ran into an unusual error while working on my project. To better learn from and remember it, I'd like to know if this type of error has a name or some definition. (The error itself OutOfMemoryError isn't unusual, I'm talking about what lead to this error).
My (simplified) situation was this:
I had a class Singleton:
... |
Many years ago when debugging real time systems (such as the ones used in telephone switches) we had to use logic analyzers (which read execution straight from the CPU) or emulators (which physically replaced the CPU itself).
Is there any situation where this type of instrumenting is still relevant?
|
I've been building web apps that add and remove lots of dynamic content and even structure within the page, and I'm not impressed by the method I'm using to do it.
When I want to add a section or module into a position in the interface, I'm storing the html in the code, and I don't like that:
if (rank == "moderator") {... |
I am trying to write a tail-recursive implementation of the function take-while in Scheme (but this exercise can be done in another language as well). My first attempt was
(define (take-while p xs)
(if (or (null? xs)
(not (p (car xs))))
'()
(cons (car xs) (take-while p (cdr xs)))))
which works ... |
I understand the concept of an object, and as a Java programmer I feel the OO paradigm comes rather naturally to me in practice.
However recently I found myself thinking:
Wait a second, what are actually the practical benefits of using an object over using a static class (with proper encapsulation and OO practices)?
I ... |
I have a rails app with a data model called 'jobs' and I'm faced with a critical design choice crossroads.
I don't know enough about Rails and its inner workings to be able to say for sure what I should do despite a complete read of the rails and ruby docs.
I want to be able to accurately display the age of a job recor... |
What does it generally mean when a programmer says his program/application was "coded in .Net"?
When I think of .Net I think of C# and Visual Basic. I don't usually think of any other language on this list: http://en.wikipedia.org/wiki/List_of_CLI_languages
|
I am having a problem learning how proper website structure should be. And by that I mean how to code the pages and how folder structure should be.
Currently I am navigating around my website using GET variables in PHP when you want go to another page, so I am always loading the index.php file. And I would load the pag... |
I will be honest I don't really know much about MVC other than the stuff you can read online in 5 minutes. Unfortunately this doesn't really tell me whether its suited to smaller projects or not.
I also read this related question and its chosen answer, but the business perspective is not a concern in this case for me ... |
I have a question about designing MVC app architecture.
Let's say our application has three main categories of views (items of type 1, items of type 2...). And we have three (or more in future) types of users - Admins, let's say Moderators and typical Users. And in the future there might be more of them. Admins have f... |
There is a design problem that I came upon while implementing an interface:
Let's say there is a Device interface that promises to provide functionalities PerformA() and GetB(). This interface will be implemented for multiple models of a device. What happens if one model has an additional functionality CheckC() which d... |
All, I have a WPF DataGrid. This DataGrid shows files ready for compilation and should also show the progress of my compiler as it compiles the files. The format of the DataGrid is
Image|File Path |State
-----|----------|-----
* |C:\AA\BB |Compiled
& |F:\PP\QQ |Failed
> |G:\HH\LL |Processing
....
The p... |
My question is about writing transaction-like functions that execute sequences of actions, some of which may fail. It is related to the general C++ principle "destructors can't throw," no-fail property, and maybe also with multi-phase transactions or exception safety. However, I'm thinking about it in language-neutral ... |
I was told that unittest is fast and the tests which touches DB, across network, and touches FileSystem are not unittest.
In one of my testcases, its input are the file names (amount about 300~400) under a specific folder. Although these input are part of file system, the execution time of this test is very fast.
Shoul... |
On the Wikipedia page on dependency injection, the disadvantages section tells us this:
Dependency injection increases coupling by requiring the user of a subsystem to provide for the needs of that subsystem.
with a link to an article against dependency injection.
Dependency injection makes a class use the interface ... |
I need to build a service that will call multiple API's at the same time and then output the results on the page (Think of how a price comparison site works for example).
The idea being that as each API call completes the results are sent to the browser immediately and the page would get progressively bigger until all ... |
What is the best practice to return a value for hashCode() method if custom field used in equals are null ?
I have a situation, where equals() override is implemented using custom fields. Usually it is recommented to override hashCode() using that custom fields used in equals(). But if all the custom fields used in equ... |
From REST in Practice: Hypermedia and Systems Architecture:
The current state of a resource is a combination of:
The values of information items belonging to that resource
Links to related resources
Links that represent a transition to a possible future state of the current resource
The results of evaluating any busi... |
Suppose I have a useful python function or class (or whatever) called useful_thing which exists in a single file. There are essentialy two ways to organize the source tree. The first way uses a single module:
- setup.py
- README.rst
- ...etc...
- foo.py
where useful_thing is defined in foo.py. The second strategy is t... |
I'm pretty new to programming and computer science, but I was wondering if there was any good way to approach the following problem: For a set of 2n points (not necessarily unique) in R^k (assume each entry is positive), I want an algorithm which will partition the set into n pairs such that the average Euclidean dista... |
I am using a proper binary tree to simulate a tournament bracket. It's preferred any competitors in the bracket that are teammates don't meet each other until the later rounds. What is an efficient method in which I can ensure that teammates in the bracket have as much distance as possible from each other? Are there ... |
I am transferring file from one server to another. So, to estimate the time it would take to transfer some GB's of file over the network, I am pinging to that IP and taking the average time.
For ex: i ping to 172.26.26.36 I get the average round trip time to be x ms, since ping send 32 bytes of data each time. I estima... |
In a WPF MVVM application, I exposed my model object into my viewModel by creating an instance of Model class (which cause dependency) into ViewModel. Instead of creating separate VM properties, I wrap the Model properties inside my ViewModel Property.
My model is just an entity framework generated proxy class:
public... |
Which approach is most popular in real-world examples: recursion or iteration?
For example, simple tree preorder traversal with recursion:
void preorderTraversal( Node root ){
if( root == null ) return;
root.printValue();
preorderTraversal( root.getLeft() );
preorderTraversal( root.getRight() );
}
and ... |
I need to code a signal-like mechanism and I was thinking of using the same "slot" and "signal" terms to indicate the signal and the function that needs to be called.
Since this is a commercial application I'd like to know if there might be any issue with using these names, e.g. if Qt has some sort of patent on them (I... |
When using Akka, CQRS style, is still there a place for Entities?
Or does everything now go to Aggregates, implemented as Actors + Value Objects.
I notice that most entities are written as mutable objects with side effects - this doesn't seem to jive well with Actor based style.
|
I'm working in a new version of an old project that I used to download and process user statuses from Twitter. The main problem of that project was its infrastructure. I used multiple instances of a java application (trackers) to download from Twitter given an specific task (basically terms to search for), connected wi... |
I am working on an application that displays choropleth maps. These maps are of all different types, some display state by county, country by state/province, or world by country.
How should I handle storing the map information in the database?
My Thoughts:
I won't need to do queries to find POI inside a region, so I ... |
I was thinking about a design for custom handles. The thought is to prevent clients from copying around large objects. Now a regular handle class would probably suffice for that, but it doesn't solve the "dangling reference problem";
If a client has multiple handles of the same object and deletes the object via one of ... |
The project I'm working on is to re-skin an existing website. The functionality will stay the same, it's just the styles that are changing. In other words, I'm not modifying the HTML, only the CSS files.
The site is pretty complex, with dozens of pages. Logged-in users can have a number of different roles, and dependi... |
I am in the process of developing an application that allows users to write C# scripts. These scripts allow users to call selected methods and to access and manipulate data in a document. This works well, however, in the development version, scripts access the document's (internal) data structures directly. This means ... |
recently I was tasked with implementing a way of adding support for versioning of hardware packet specifications to one of our libraries. First a bit of information about the project.
We have a hardware library which has classes for each of the various commands we support sending to our hardware. These hardware modules... |
(While this question has to do with a concrete coding dilemma, it's mostly about what's the best way to design a function.)
I'm writing a method that should take two Color objects, and gradually transform the first Color into the second one, creating an animation. The method will be in a utility class.
My problem is th... |
I'm currently writing a LISP parser that iterates through some AutoLISP code and does its best to make it a little easier to read (changing prefix notation to infix notation, changing setq assignments to "=" assignments, etc.) for those that aren't used to LISP code/only learned object oriented programming.
While writi... |
In chapter 2 of the book WPF4 Unleashed the author shows an example of how XAML processes type conversion. He states that
<SolidColorBrush>White</SolidColorBrush>
is equivalent to
<SolidColorBrush Color="White"/>
, because a string can be converted into a SolidColorBrush object.
But how is that enough? It doesn't mak... |
I am writing Java code to simulate a supply chain.
The supply chain can be simulated in either
an intermediate stocking or a cross-docking configuration.
So, I wrote two simulator objects IstockSimulator and XdockSimulator.
Since the two objects share certain behaviors
(e.g. making shipments, demand arriving),
I wrote ... |
I've been trying to think of a way of declaring strongly typed typedefs, to catch a certain class of bugs in the compilation stage. It's often the case that I'll typedef an int into several types of ids, or a vector to position or velocity:
typedef int EntityID;
typedef int ModelID;
typedef Vector3 Position;
typedef Ve... |
From REST in Practice: Hypermedia and Systems Architecture:
For computer-to-computer interactions, we advertise protocol
information by embedding links in representations, much as we do with
the human Web. To describe a link's purpose, we annotate it.
Annotations indicate what the linked resource means to the cu... |
I've been bitten for the n-th time now by a library mismatch between a build and deployment environment. The build environment had libruby.so.2.0 and the deployment environment had libruby.a. One ruby was built with RVM, the other was built with ruby-build. The reason I ran into a problem was because zookeeper was comp... |
Have a question on recursively populating JsTree using the .NET wrapper available via NuGet. Any help would be greatly appreciated.
the .NET class JsTree3Node has a property named Children which holds a list of JsTree3Nodes, and the pre-existing table which contains the node structure looks like this
NodeId ParentN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.