instruction stringlengths 34 19.9k |
|---|
I have encountered two ways of doing it:
void foo(int from, int to); /* 'from' inclusive, 'to' exclusive */
void foo(int startIndex, int rangelength);
Has one style historically been preferred over the other? If so, was it just a matter of convention or was it due to some deeper underlying reason?
I'm currently progr... |
We have a "typical" SCRUM team and we commit to work for a sprint, and also maintain a backlog. Recently we have run into a problem of trying to integrate/handle the work of an overachieving developer doing out of band work (choosing to work outside of the normal working hours/sprint).
To give an example, if the team t... |
In the page at http://pear.php.net/manual/en/standards.indenting.php, it is advised to use space instead of tab as it causes issue with diff, patches. Here is the excerpt from the page.
Use an indent of 4 spaces, with no tabs. This helps to avoid problems with diffs, patches, SVN history and annotations.
So, my quest... |
We recently added a relatively large feature to our product that involved the entire R&D department (with all the different teams within it).
This feature included UI development, server side development, and huge migrations of SQL schemes (and other stuff that I myself was not involved in at all).
The development proc... |
I'm working on an event processor framework for a simple game I'm writing, in which multiple types of events are handled in a loop. Since these events carry distinct pieces of data (i.e. one carries a player and position, another carries a message and timestamp), I ended up creating different classes for them (though t... |
Why does the operator -- not exist for bool whereas it does for operator ++?
I tried in C++, and I do not know if my question apply to another language. I will be glad to know also.
I know, I can use the operator ++ with a bool. It makes any bool equal to true.
bool b = false;
b++;
// Now b == true.
Why can't we use t... |
I'm currently programming Java, I have played around with C++ before, but I have never touched GUI as I feel "cheat-like" when using its drag and drop system. I feel good and enjoy programming my own GUI like I do in Java, it feels much more rewarding.
Is there any way I can program the GUI for C#/C++ like in Java, wit... |
Currently I have a binary tree template setup where my main is using it with strings to make a question/answer game. I'm using a knowledge base that works as an interface to the binary tree that main uses (main has no access to node or binary tree classes). My code seems to work fine inserting/rearranging nodes as nece... |
Say your company has some closely-guarded internal software that happens to have an MIT License. Maybe it was based on MIT Licensed software but has been heavily modified over the years. Your company does not want to share it with the outside world. However, one day an employee decides to post the software up on GitHub... |
So, the last 2 weeks I have been fighting with indexedDB and one of two recurring questions that keep popping up is why indexedDB has to use/present it's entire versioning system? I do understand that in certain very specific cases it's a nice thing to have, but in those cases an if(localstorage.dbversion <= ...) would... |
I've been a front-end developer for about two years now, and I'm attempting to break into the server side of things. Ideally I'd like to work for a startup social network on the back-end side so I want to try and be as marketable as possible.
In my quest to learn a new scripting language I've dug myself into the PHP vs... |
Hello some programmers might know about the lean philosophy,
building a minimal viable product Lean Startup MVP.
I ask myself (when building Webapps):
"Should I put effort into writing good reusable code, testing etc."
or
"Write quick and dirty code. It just works. The customer does not care
what kind of progra... |
I'm programming in Java, in a very OO style, by myself. Never had the chance to work with other programmers (I'm not a professional, at least yet).
Out of curiosity, I wanted to ask: How does working with a team on a project work, especially when working on an OO project?
How does splitting tasks work? How do you devel... |
I got a java-ee application, where I collect informations about movies. Im my backend I provide data like the name, description, genre and a random uuid.
I also got lots of related files, which are stored on a file server. Including some screenshots, the dvd or bluRay cover and video trailers.
My current approach is:
W... |
I have implemented a LL1 parser in a non recursive approach with a explicit stack.
The following algorithm is from the Dragon Book:
set zp to point to the first symbol of w;
set X to the top stack symbol;
while ( X != $ ) { /* stack is not empty */
if ( X is a )
pop the stack and advance zp;
else if ( X... |
I have a service that needs information implemented by another service in the same layer. Is it good practice for one service to take a dependency on another service in the same layer?
|
I am currently working on a project that is fairly small for the time being. There was a recent change to implement 3-tier architecture, such that the code is now split up appropriately to data access, business logic and user interface tiers. However, there is no use of objects outside of creating them to ultimately ... |
Clarification: the rule is meant to prevent accessing variables that are not declared yet.
Clarification 2: the rule mandates that the compiler follows calls to functions which are defined in the same scope as the call and happen before the actual definition (forward referencing) - making the compiler much alike an in... |
I would like to write a web system that can capture and parse incoming emails, traditionally the web system I write are asp.net-mvc, running in a cloud hosted environment like AppHarbour or Azure.
How can I leverage those (and potentially my DNS) to acheive this?
|
I recently took a software processes course and this is my first time attempting OO design on my own. I am trying to follow OO design principles and C++ conventions. I attempted and gave up on MVC for this application, but I am trying to "decouple" my classes such that they can be easily unit-tested and so that I can e... |
My application has a few high level configuration options such as directories which will be used for various things, database connection information and a few other settings which are required for the application to run.
I'm debating with myself whether or not constants are better than variables for this purpose and wo... |
Say you are developing a desktop application that extensively uses a database, should you have one handle for the database that the entire app references? Or should you open a connection when you need data, get the data, and then close the connection when data isn't necessary.
|
I am trying to determine an objective way for a self-interested agent to calculate the optimal buying/selling price for goods in a multi-agent simulation not dissimilar to Sugarscape (http://en.wikipedia.org/wiki/Sugarscape). The simulation is as follows:
Each agent has a stock of food F, a stock of money G, a certain ... |
For decimal numbers, obviously I want to localise everything. Whatever programming language I'm working in, there will tend to be tools for this, so it's also easy to do.
In my application, I happen to be formatting numbers as hexadecimal quite often. This leads me to wonder:
Are there locales which group hexadecimal ... |
I've already read this question on CodeReview. I was hoping for general advice.
I'm writing a service which will go to numerous data sources. Each source requires getting copious amounts of data and changing it to a single format. What is the best pattern for a task like this?
I currently have a "base" class which e... |
I am working on a Chat Server Application in Asp.Net with C#.
Suppose there are 5 users online say User A,B,C,D,E. Suppose A sends a message in chatbox to user B, so how the chatbox (Textbox/Textarea of chat) of User B will load the new content?
One Option is to refresh the chatbox every 10Seconds or 15 seconds but it'... |
I'm developing a CMS, inside it I use many various plugins/addons wich licenses mostly like MIT, GNU, GPL (such as jQuery, nivoSlider, DataTables and so on..). After reading those licenses I believe I can use them inside my CMS and charge users for my CMS.
In my project I have a specific folder where I store all these... |
During Sprint Planning there are a lot of decisions to be made:
How many PBIs should the team commit to?
Which tasks should constitute each PBI?
How much time should each task take?
With no team leader it is not always easy to make all these decisions, since there will be some decision points (sometimes more than a f... |
I want to try and create my own very basic language, with it's very basic compiler. All using Java.
For now, it will only need to enable to 'programmer' to print things to the screen.
I had an idea for how to do this, and what I wanted to know is: Will this be considered an actual 'compiler', an actual 'language', and ... |
I want to work on a very simple compiler for a very simple language. The compiler will compile the code to some basic bytecode. Later, a virtual machine program will run the bytecode, and execute the program.
I have several questions about what bytecode actually is:
Does bytecode have to be of binary form, aka compose... |
There are many well-known best practices about exception handling in isolation. I know the "do's and don'ts" well enough, but things get complicated when it comes to best practices or patterns in larger environments. "Throw early, catch late" - I've heard many times and it still confuses me.
Why should I throw early an... |
Delphi RAD libraries implement many thread friendly objects in a way which forces one to declare another object for storing the reference returned by that object's locking method. The object thus essentially encapsulates the prime object which is returned on locking. For example;
List := ThreadList.Unlocklist;
// do so... |
So let's say I have a 'Transformer' interface that can transform one file-type to another. Let's say I also wish to use streams to provide the data to the Transformer. Which is the approach that is considered 'best practise';
public InputStream transform(InputStream data);
OR
public void transform(InputStream original... |
From Martin Fowler's Mocks Aren't Stubs he states that Stubs provide canned answers to calls made during the test while Mocks objects pre-programmed with expectations which form a specification of the calls they are expected to receive.
In addition several sources state that Stubs shouldn't fail tests, but Mock could.
... |
I have several classes that all behave according to one interface. But in each class there are additional functions defined that give each class slightly different behavior. What I want to do is have th programmer using this API to simply create one instance based on some parameter which generates the correct class ... |
I am building a small website, in PHP and I am using MVC design pattern for the UI.
In the future I will need to add mobile support for my website. It will be in the sub domain "m" like everyone.
All the web is new for me, and I am new with MVC too. I did for each page View, Model and Controller. The Views and the Mode... |
It seems like F# code often pattern matches against types. Certainly
match opt with
| Some val -> Something(val)
| None -> Different()
seems common.
But from an OOP perspective, that looks an awful lot like control-flow based on a runtime type check, which would typically be frowned on. To spell it out, in OOP you'... |
I have tried looking for an answer to this question, but I couldn't find anything related.
To put it in a nutshell, I want to fork the existing Komodo Edit project, which is licensed under MPL Version 1.1, and create a new derived project/software. I would like to remove certain features from the current project, inclu... |
In the company I work at, developers also serve as internal tech support. This means we have to do three types of things:
Development: writing actual code to implement new features and new products
Maintenance: handle bugs and minor changes with existing customer-facing software
Tech support: handle internal issues ot... |
I'm developing a REST application and I allow my clients to authenticate in several ways (typically using Authorization: Token ... as in OAuth 2.0, but also there's session-based auth option for the web-browsable API). The application allows the client to provide their endpoint to which my application would later POST ... |
My game is a top down 2D shmup programmed in a functional style. I'm struggling with abstracting the code that is responsible for animating the projectiles. There are many types of guns with many types of projectiles. Here are a few that are very different:
A standard gun that shoots a bullet that travels a distanc... |
I recently wrote a little CLI Hangman game in Python; it's not anything huge, but I did write it all myself. I would like to keep the program open and free (GPL ver.3), but it's so small I don't know if I need to/can license it.
Is there a certain point where a program becomes "license-able", or can I license any progr... |
This is partly genuine curiosity, and partly a check on my understanding. I'm probably missing the point.
In Haskell, why does a monad use operations called return or unit to describe putting a type into the container -- lifting it into the monadic space? It seems more intuitive to call the operation lift.
Right now, i... |
TL;DR
Is there a data structure that'd quickly let me match words at any point (e.g., 'foo' matches 'foobar' and 'zoofoo'), and, ideally, returns a list of "characters that show up after the needle" (e.g., 'foo' should return ['b', $]).
I'm implementing an algorithm that generates random words from a training set of ... |
Learning how to develop a small embedded HTTP server for a class assignment, and the examples given on how to use com.sun.net.httpserver.HttpServer use an InetSocketAddress which extends SocketAddress as the link between client and server. However, all of my previous network programming assignments used Socket and Serv... |
I'm going to start developing an application in near future. This application consists of :
Back-end system. This system provides API to be used by client. This
system connects to data store and 3rd party API.
Data Store : Can be relational or nosql data store.
Client : Client will be a website and mobile application... |
I am a first-time azure developer and I am taking over a single-tenant cloud system and have been tasked with converting the system to multi-tenant. What is the correct practice to separate each tenant's sql server data?
Its a data collection & reporting system. Each tenant will want to build and run their own custom r... |
I'm working on Ruby on Rails. There is a feature in our app where doctors can "claim" cases for themselves.
I can either have the doctor perform the action and update the plate, or I can have the doctor send itself to the plate and have the plate update itself.
Should objects update itself? It just seems cleaner to me,... |
In my test environment we are running the same set of integration (and sometimes unit) tests against different systems that have different capabilities.
Some of the tests cannot be executed against some of the systems because a feature that enables this scenario is missing or we need completely different behavior.
Curr... |
I was looking for some answers in SO or here, but without any results, that's why I would ask you.
Let's assume I have a two different projects - for example server part and client part of an app. I'm developing my own part, while my friend is making the second one. But both of us should use some common interfaces like... |
According to the slides given by my lecturer, one of the disadvantages of MVC model is
additional code and complexity when data model and interaction are simple
Why is this so, I would assume it would make no difference since data model and interaction are on two different components of the MVC model?
|
As far as I know, there aren't a lot of differences between JDK 6 and JDK 7. At least, I haven't yet come across a difference (I coded with JDK 7 and with JDK 6).
A lot of computers run JRE 6 or JRE 7. Compiling my program using JDK 7 will narrow the number of potential computers that can run my application.
Is it gene... |
According to the Pragmatic Programmers, code should be for abstractions, while configuration and details should live in metadata. Rails seems to diverge dramatically from this pattern. Much config is done in code files such as application.rb, routes.rb and the various environment.rb files, while other types of config i... |
I just wrote the following piece of code (in delphi):
procedure Update(Value: Integer);
begin
// If the last update was yesterday, replace yesterday value
if CompareDate(FLastUpdate,Now) <> 0 then
begin
FYesterdayValue := FTodayValue;
end;
FTodayValue := Value;
FLastUpdate := Now;
end;
And I realized t... |
I have a lot of small projects, and while their source code is backed up and tracked with git, I don't know what to do with the rest of the files associated with a project.
These consist of small text files, some images, maybe a prototype or proof of concept, etc. They're not necessary to build or deploy, but I need th... |
This is a function in the d3.v3.js file (the graph library D3.js):
function d3_geo_areaRingStart() {
var λ00, φ00, λ0, cosφ0, sinφ0;
d3_geo_area.point = function(λ, φ) {
d3_geo_area.point = nextPoint;
λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4),
sin... |
I am a bit stuck with a design of a project, where many objects has to have access to the same piece of information. It could be some data, to construct a global-like object for themselves or the object itself (essentially a config object).
Essentialy these object are in a tree: On a top is a 'Router' object, which has... |
I have a class that runs as a service and returns html code of a website when supplied with a URL.
The code:
public interface IHtmlDownloader
{
IWebProxy Proxy { get; set; }
string UserAgent { get; set; }
string GetHtml(string url)
}
public class HtmlDownloader : IHtmlDownloader
{
WebClient _client;
... |
Context:
I have historical data about property (house) sales collected from various sources in a centralized/cloud data source (assume info collection is handled by a third party)
Planning to develop an application to query and retrieve data from this centralized data source
Example Queries:
Simple : for given XYZ pos... |
I've been making MVC programs for work (I'm an intern) and I feel like I'm doing a pretty good job at abstraction, single responsibility, etc. But I have this feeling about how I keep making objects properties of other objects and I'm not sure if it's a bad thing.
Example:
User
{
String Username;
Int32 UserID... |
We have a set of Java tools that are built and run locally. Whenever one of the devs commits a change, everyone else (including non-developers) need to do an update and build the tools.
Everyone uses windows machines so whoever designed the build processes decided to place everything in a folder called C:\build and dum... |
I am planning to make a simple rest service application, and I am currently deciding the architecture. I have decided that I want to write the middle layer in multiple languages, so that it is easy to deploy/integrate with as wide a range of systems as possible.
Due to the necessity of porting the code to multiple lang... |
I am running a zoo application.
My zoo includes an abstract class of 'animal', and several deriving classes - 'zebra', 'elephant', 'orangutan', 'baboon' and so on. Of each class I have several instances.
My question is: I want to check out if two animal instances can mate.
The business logic is divided to two parts:
I... |
gccand clang are both known to be compiler drivers. As such, the gcc executable does not compile anything itself. Rather, it calls the compiler (cc1), assembler (as) and linker (ld) with the right flags as needed.
Is this setup true also for the Microsoft C compiler, cl.exe? Is there actually some other executable that... |
I am interested in the idea of C++-like const not that particular execution (like casting away const).
Take for example C# -- it lacks C++-like const, and the reason for it is the the usual -- people and time. Here additionally
it seems the C# team looked at the C++ execution of const, marketing CLR and had enough at ... |
PHP's SplQueue does not include a clear() or reset() function to wipe data out of the data structure. My application requires that functionality. This leaves two options:
A) Create a subclass of SplQueue. Example:
class UserQueue extends SplQueue
{
public function clear() {
//dequeue everything
}
}
The problem... |
I work at a company that wants to be agile, but the business analysts often provide us "user stories" that are more solution than problem statement. This makes it difficult to make good design decisions, or in more extreme cases, leaves few design decisions to be made. It does not help the programmers understand the us... |
Could anybody, please, explain what is a Property Container or at least where can I get information about that pattern on the Internet?
I've found that it exists as one of the Fundamental patterns in this article.
Unfortunately, it is not described in the corresponding English article.
The only thing is a short descrip... |
We're trying to come up with a way to handle code that builds dynamic SQL for our application, which is very database centric. Things like Linq to SQL and Entity Framework are out of the question, so please no suggestions of that sort, our path has been defined for us.
Our main goal is seperation of the SQL from the re... |
I'm in development of a sample project in Android for a friend's phone that keeps track of his sales. At first, one of the requirements was to create yearly reports of this sales data. This would be stuff like most profitable week, total per quarter, total per month, and even yearly total, as well as compares for previ... |
If we are updating a field in SQL and ALTER the row also. After giving the COMMIT command, the system is crashed.
What will happen to the commands given, whether it will UPDATE and ALTER the table or not?
|
I have few CS textbooks with me which discuss languages, well actually 2 plus old course notes supplied a few years ago. I have been searching the web too any only seem to come up with vague responses just like the text books I have.
My question is about language recognisers verses generators.
I get the overriding prin... |
I have seen Exception Handling blocks that they were throwing the recently caught Exception in the catch block. Something like:
} catch ( Exception $e ) {
// Do some recovery here
callSomeFunction();
throw $e;
}
To me it doesn't make that much sense to throw the exact same Exception like this, but I'm not... |
I have two jee web apps that are going to be published on the same physical server, but on different network addresses.
APP A: Listens to a port on a public IP address and makes synchronous invocations to app B if necessary.
APP B: Listens to a port on a private IP address and makes synchronous invocations to app A if ... |
Let's say we have some class structure:
public interface IA { public void doA(); }
public class A implements IA { public void doA(){ System.out.println("A class doA");}
public class B extends A { public void doA(){ System.out.println("B class doA"); }
And now in a main I state this:
//in a main
... |
I would like to display some events in 'real-time'. However, I must fetch the data from another source. I can request the last X minutes, though the source is updated approximately every 5 minutes. This means that there will be a delay between the most recent data retrieved and the point in time that I make the request... |
I have been advocating lately that all string fields should be ntext / nvarchar(max) - we're using MS SQL Server. The objections seem to be either "it's not a good idea" (without any reason) or "that would allow the customer to send a lot of crap". Since I believe in filtering out the crap before it hits the database, ... |
There are many useful functions in <algorithm>, but all of them operate on "sequences" - pairs of iterators. E.g., if I have a container and like to run std::accumulate on it, I need to write:
std::vector<int> myContainer = ...;
int sum = std::accumulate(myContainer.begin(), myContainer.end(), 0);
When all I intend to... |
Being aware of the direct benefits of libraries having things wrapped in a package, making daily work easier, my question is leaning more towards the fact that many features not implemented in HTML/DOM/CSS, has become available using these libraries.
There is everything, from visual effects (13 a dozen) to more functio... |
I am writing an application for my graduation coursework, in C, using GTK+ UI library. Sometimes I ask for user input, which I need to save for later use.
The doubt comes on how to store this data. I didn't want to create global variables because I was told countless times not to use them. However, I need to interchang... |
Lately I've been studying a lot of javascript samples, both with/without libraries, jQuery to mention one.
As an old JavaScript developer, I learned early to make use of unobtrusive javascript where one were adding mouse click events to a global handler using document.onclick = mylib.document_onclick;
Then, by tagging ... |
Take for example this input array:
[2,7,1,4,9]
For this input, I need to produce an array of total 23 elements which contains two elements of 2, seven elements of 7, one element of 1, four elements of 4 and nine elements of 9.
Example of output array:
[2,2,7,7,7,7,7,7,7,1,4,4,4,4,9,...]
However, this array needs to b... |
Lets say I have the following code
// JS
$(function(){
$('[data-mc=logout]').click(function(){
if (!confirm(myconfig.msg['asklogout'])) {
return false;
}
});
$('[data-mc=ajax]').click(function(){
var target=$(this).data('targe... |
Python widely uses built-ins (or module function) and not class methods.
So
len([]) instead of [].length()
filter(f, []) instead of [].filter(f)
str(2) instead of 2.to_str
same for map, foreach etc
These prevent you from doing nice chaining which is possible in other languages like Ruby or Scala:
(sorry very artifici... |
I am completely new to using VCS and haven't settled on Git or Hg, but I do know that I will be using it soon. My old project folder has versions of files labeled v1, v2, etc. How easily can I fold this into a new [local] repo? There are only a few sets of files with version counters (so commit, then copy paste, then c... |
I like to raise a NotImplementedError for any method that I want to implement, but where I haven't gotten around to doing it yet. I might already have a partial implementation, but prepend it with raise NotImplementedError() because I don't like it yet. On the other hand, I also like to stick to conventions, because ... |
I've just read this article, and I'm confused.
Let's imagine 1 webapp and 1 distinct application acting as "worker", both sharing the same database.
Oh, I said "sharing"..but what does the article warns about? :
Fourthly, sharing a database between applications (or services) is a
bad thing. It’s just too tempting to... |
This problem feels rather basic, yet I've never known a great solution. I'm looking for a way for components in an application to notify each other while being as decoupled as possible (both at build/compile and run time), but also avoiding circular notifications in a way that components do not need to self-mitigate ag... |
I'm trying to adopt TDD in my daily programming practice. I use it at work very effectively, but I'm having trouble with my personal projects where I'm using some complex algorithms.
The particular algorithm that makes me ask this question is the Extended Kalman Filter. It's complex enough that I'm not confident in t... |
The following Scala code works and can be passed to a Java method expecting a function. Is there a cleaner way to do this? Here's my first pass:
val plusOne = new java.util.function.Function[Int,Int] {
override def apply(t:Int):Int = t + 1
override def andThen[V](after:function.Function[_ >: Int, _ <: V]):
f... |
I'm part of a 7 person software development team which supports a company with a few thousand staff. Our team is putting together a quick review process for measuring the success of a software project. Projects are mostly internal, which means our "customers" are more often than not other staff. Projects are reasonably... |
I just wrote a function that spans approximately 100 lines. Hearing that, you are probably tempted to tell me about single responsibilities and urge me to refactor. This is my gut instinct as well, but here is the issue: The function does one thing. It performs a complex string manipulation, and the function body consi... |
I'm in the need of widen my perspective on the framework libraries, to be able to make well aware choices of if/which/when to add a framework to a website.
One thing that got my attention was event handlers, as they seems to be somewhat more complex structured.
For me, in the early days, an event handler were added inl... |
I'm developing a java application to visualize time series. I need (at least) three linked views, meaning that interaction with one of them updates the others.
The views are:
A list represents the available and currently selected time series. The selected time series are used as input for subsequent computations. Chan... |
I'm writing some tests for a NodeJS module, but this question can apply for any language / platform. I've got the following situation:
// in moduleA.js
exports.foo = function (var1, var2) {
// do something to var1 and var2 here
baz(var1, var2);
};
exports.bar = function (var1, var2) {
// do something com... |
I totally believe in not repeating yourself in production code. I've accepted the idea that you shouldn't repeat yourself within test code. But what happens when you have production services that would simplify test code?
Let me pose an example. We have a service that accesses the Doohickey API. The Doohickey API is co... |
If this is tl;dr, scroll down to "The Question"
Why this is not a duplicate:
The linked question talks about version control (which I have), a one step build script (which I have) and to "have an issue tracker at all" (which I have, but I'm having trouble optimizing), none of the answers to that question answer any of ... |
I been reading a few things about using libraries and stuff but they all talk about not using it for commercial purposes.
Does commercial mean when you earn money by putting a ad to support you or is it something else like for a big company?
|
I'd like to validate I'm not in the wrong way.
My team project is using Visual Studio Scrum 2.x. Since each area/product has a lot of kind of requirements (security, user interface, HTTP/REST services...), I tried to manage this creating "parent backlogs" which are "open forever" and they contain generic requirements.
... |
I have a simple question: Slugify via helper or store the slug on database?
I mean, let's suppose that I have Guilherme Oderdenge on database and I want to transform it into a human-readable URL such as http://myapp.com/guilherme-oderdenge/, what's the best way to perform this? Storing guilherme-oderdenge in the datab... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.