instruction stringlengths 34 19.9k |
|---|
I'm bit of a novice to JavaScript so I've been wondering on positive and negative sides of using polling compared to using events in JavaScript? When does one use one or the other?
By polling I consider any effect that is triggered on something that repeats itself usually using setTimeout. But also for example:
functi... |
So it is generally accepted that top tier programmers can produce an order of magnitude more/better code than their more average peers.
It's also generally accepted that the rate of errors made in code is relatively constant for programmers.
Instead, it tends to be impacted by the processes used when writing the code a... |
I'm having serious doubts about the design for my Web application.
I wanted to separate the business logic from the interface so I made a Web API that handles all the requests to the database.
It's an ASP.NET Web API with Entity framework and a unit of work and generic repository pattern. So far, everything is good.
... |
I'm trying to collect different ways of managing configuration across multiple environments.
I have a requirement to document configuration changes for the deployment plan.
Dev values are defaults in the code and QA manages their own as well so the documenting and sharing of the info is a critical point.
Rather than co... |
I want to parse a multipart form twice: once to grab the incoming fields, and later to process the file upload.
I am trying to maintain a proper separation of concerns within my Node app:
Controller is responsible for handling the incoming fields.
Model is responsible for the upload file logic.
I need to pass the fie... |
The answer to why we put private member variables in C++ headers is that the size of the class must be known at points where instances are declared so that the compiler can generate code that appropriately moves about the stack.
Why do we need to put private members in headers?
But is there any reason to declare privat... |
I'm comparatively new to algorithm analysis and am taking a related course on coursera where I came accross k way merge sort.
The time complexity of 2 way merge sort is n log2 n, of 3 way merge sort is n log3 n and of 4 way merge sort is n log4 n.
But, in the case of k-way the complexity is nk^2. This is because we p... |
Right now I am working on my own small project of a WPF file back up application. I have come to a point where I want to create a method that will copy files recursively from one place to another.
This is not the first time that I ask myself the question:
Should this method be a part of an existing class, or should I ... |
I'm working on a set of automated tests that we use internally at work. Lately, we've been designing classes that implement interfaces in addition to inheritance.
As I understand it, interfaces in Java are used to fulfill a contract. A class that implements an interface must include implementations of any members of t... |
Some products can parse a special syntax in commit messages to extract additional data, such at time tracking information: https://confluence.atlassian.com/display/FISHEYE/Using+smart+commits
To me, this seems like the misuse of one tool to activate a feature on another, but I'm having trouble articulating my reasoning... |
Writing software for a client, and one of their requirements was that the user be able to specify where the application database is stored, be it on the local network or in an online repository.
I can let them choose where to put it, but how do I store that information in the application?
I guess I don't understand how... |
I have read lot of articles which state that code can't be bug-free, and they are talking about these theorems:
Halting problem
Gödel's incompleteness theorem
Rice's theorem
Actually Rice's theorem looks like an implication of the halting problem
and the halting problem is in close relationship with Gödel's incomplet... |
tl;dr
I've been told that in domain-driven design, an identifier for an entity could be a custom value object, i.e. something other than Guid, string, int, etc. Can this really be advisable in a distributed system?
Long version
I will invent an situation analogous to the one I am currently facing.
Say I have a distribu... |
I'm tidying up my company's Version Control Guidelines. One of my tasks is to determine how solutions should be organized in a very broad sense.
I have somewhat come to my own conclusion that one broad requirement to document is that, for the most part, CSProj/VBProj projects should live on their own all at the same l... |
I am fairly new to c# and trying to learn best practices. I've been faced with many situations over the last week in which I need to make a choice between longer+simpler code, or shorter code that combines several actions into a single statement. What are some standards you veteran coders use when trying to write clear... |
One day I was using Git (I'm still using it) and the electricity went down while I was committing.
When I (actually, the electricity) came back, the git repo was corrupt. I don't remember the exact name, but it was something like "invalid refs" or something like that.
It's easy to guess that the commit was broken in th... |
I understand that Agile team should be self organized and self driven,
but is there a provision that I can have someone who will allot tasks to developers and ensure that all user stories will be completed on time??
For example if there are two persons in an agile team who are not self motivated to take up tasks and th... |
Suppose I had a grammar like:
object
{ members }
members
pair
pair
string : value
value
number
string
string
" chars "
chars
char
char chars
number
digit
digit number
I could parse the following example: { "one" : 1234 }
As far as I understand, I should have the tokens ... |
I hope this isn't too off-topic and/or opinion based.
I'm looking for examples and reasons why Java is an acceptable language for education purposes.
Here's why: I learned programming on my own in C at the age of about 15. In school we used Pascal (which I think is quite OK, especially in educational context). In Unive... |
I have a winforms application that connects to a single sql server 2012 database and is executed in many PCs of a company.
I'm having several problems with some transactions inside the application, deadlocks and timeouts so the refactor idea comes to my head.
Actually the app is using DbConnection object (the app start... |
I am engaged in a project that works mainly in AutoCAD to design and manufacture prefabricated building components such as roofing trusses. One of our goals is to redesign a program that was written in LISP that functions in designing roofing trusses. We are to rewrite the LISP code in C# and incrementally implement ... |
I have a problem when designing any application that is either greenfield or a refactored brownfield due to often finding a potential flaw or an uncertainty with the design or architecture that I think up. I waste a lot of time trying to construct a design that I am confident in without a lot of time invested from the ... |
I understand completely how to implement the Decorator pattern, and I also understand what it's intent is.
The Decorator is used in one of two cases:
As an alternative to subclassing - when there are multiple characteristics that an object can have, one could use inheritance in order to create subclasses for all the po... |
Looking at making a GUI library for a game engine. I generally avoid pointers if I don't need them and in my below example I find that I don't and it works, but just curious if this design is generally considered good practice or if anyone has comments on it.
int main()
{
// all widgets are positioned and sized acc... |
So obviously NASA need programmers to develop applications for them, be it VOIP applications, applications for control of machines and AI, etc. But in what language do they actually use for this?
I am thinking of learning how to program an Arduino, or Engduino as we may be witnessing in my Computer Science classes, bu... |
I'm seeing a lot of people say you should never use raw pointers. What about in the case where you store the raw pointer in a class but how they get populated is from getting the pointer of an object that wasn't dynamically created? I'm curious about if this is bad practice and if so how to make it better. This seems i... |
I suspect this is something that many of you have dealt with, and I'm certain there's articles on how to do it, but I can't seem to find them.
My problem is that my various constant classes in Java (read: classes containing lists of static constant values) are too many and too big, and some of them have some annoying c... |
The Situation: I am building a custom PHP application framework. I have implemented a composite pattern so I can build a object tree representing the page to be rendered. Example:
abstract class \Block\BlockAbstract {
protected _blocks = array();
public function __construct($properties);
public function ... |
Despite the long title, my question is fairly simple. Let's say you have a cube in 3D-space and you want to rotate it along the three axes based on the set of instructions provided by a user or elsewhere in the program. How would you simplify, if you will, that set of rotations?
For simplicity's sake, we'll use the not... |
I'm attempting to build a Discrete Event Simulation library by following this tutorial and fleshing it out.
How should I handle logging metrics in my Discrete Event Simulation engine?
If you don't want/need background, skip to The Design or The Question section below...
Simulation
The goal of a simulation of the type i... |
Edit:
OK, so, people said it is unclear what I am asking. I am asking for feedback on this design. Here is an example user story:
As a group admin on the website I want to be notified when a user in my group uploads a file to the group.
Easiest solution would be that in the code handling the upload, we just directly cr... |
Let say you are building an app and you are using the latest library verion from a third party (say ver2.jar). Then you saw an example written 2 years ago, but that example uses the ver1.jar
Now in ver1.jar, there is web.method1(), but in ver2.jar there is no such method. Instead, in ver2.jar you have web.getOtherMetho... |
I have a use-case that can be repaired, but the logic for repairing it is best done in a higher level of abstraction. Just throwing exception/failure is ugly because it's hard to pass back up through the stack the information needed for the parent-layer to know how to fix it.
To explain the the specifics, I have a pro... |
I'm considering using SignalR to send data to a mobile app, but need to have a way to synchronize data while it's closed or pending updates.
Is it a good idea to use Backbone.js <--> SignalR to manage queued CRUD updates to the server? If not, what is?
|
I commonly see stories that have back-end and front-end development. For example, consider a large dialog with a few tables and some dynamic controls. We'll make several stories (maybe one for each table and another for the dynamic control system).
The dev team will then split with one person on the back-end and anot... |
Say a user could enter project data into my software. Each project has 2 variables "size" and "work" and they're related but the relationship is not known. Is there a way to programmatically determine the relationship between the variables based on previous data and forecast the amount of work provided if only given th... |
First ATMs performed tasks like a cash dispenser, they were offline machines which worked with punch cards impregnated with Carbon and a 6-digit PIN code.
Maximum withdrawal with a card was 10 pounds and each one was a one-time use card - ATM swallowed cards!
The first ATM was installed in London in the year 1967, as I... |
As a developer I am fan of static methods.
Recently I come across difference between OOP languages about this static methods.
All OOP language use static method to access any method without creating instance of than class. So we can call this kind of method with just class name.
But some language allow to access stat... |
When I was going through the project on which I am working, I came across a cpp file, which has only functions and static variables.I was wondering why they have not put everything into a class! Whenever the inside functions have to be called, the cpp file is included.
Is this a good design? what are the pros and cons ... |
Here are two ways to instantiate an object:
Option 1:
Thing thing = new Thing();
Option 2: (the factory is a Static Factory, but it could also be a Simple Factory).
Thing thing = ThingFactory.createThing();
Where:
class ThingFactory(){
public static Thing createThing(){
return new Thing();
}
}
Optio... |
In a game I'm making I was about to add a MovementEventHandler, with events like "pre-character-movement" and "post-character-movement". But this class will do exactly the same as a future CurrencyChangeEventHandler.
Should I just be creating a GameEventHandler, which just handles arbitrary event names?
One of the trad... |
Yesterday I read a tweet disparaging Jersey with JAX-RS due to run-time errors. Spray.io was mentioned in the tweet:
Not even 5 minutes using Jersey / JAX-RS and already a runtime error
due to a missing annotation. That's why I like @sprayio: type safety.
https://twitter.com/gbelrose/status/467295643053338626
How d... |
My client's web hosting company changed some web server security rules which made the site not work properly. I spent 4 hours diagnosing the problem and emailing their tech support back and forth.
I'm thinking of billing my client for this, but it could be counterproductive because it doesn't happen that often that I h... |
I have an MVC 5 application that will be used world wide. A number of the pages in the app will require users to enter dates. I'll be using the jQuery datetimepicker plug-in to allow the user to select dates. Or they can enter them manually.
I'm curious what the best practice is for cultures where dates are entered in ... |
Java is designed in a very OO approach, and somewhat even 'forces' programmers to program within the OO paradigm (which can be considered good or bad, a matter of opinion).
However while almost everything in Java is a class or an object, primitive data types (int, double, etc) are not.
While I see no advantages to this... |
I've been working for a while on an app that makes up melodies. Each melody is composed of several phrases (musical sentences, or 'sub-melodies').
Now, I want to improve on this:
The user can press a button to 'like' a melody.
The app saves the phrases (sequence of notes) composing the melody to storage.
These stored... |
I am trying to build a single page web application that will call multiple web services (both SOAP and RESTful) and aggregate the data in the UI.
Initially I though I could do it all client-side, with ajax requests, but I realize that
If there are many requests, and they are fired per user, the data can take a long ti... |
I'd like to write a simulation of Japanese Multiplication to get benchmarks on large calculations utilizing the shortcut vs traditional CPU multiplication. I'm curious as to whether it makes sense to try this.
My Question: I'd like to know whether or not a software math shortcut, as described above is actually a short... |
I am currently in the process of packing my first c# wpf app.
The app will be paid so it requires the user to agree to some terms and conditions.
Is it best to have these built into the installer? Or can I get away with having the user accept them on the website they buy them from during the purchase and before downl... |
Once in a while I encounter a C function in my colleagues' code.
Mostly it is in some helpful objective categories, and those functions are mostly an internal calculation of something or a comparison of values.
Since those guys are not part of the company anymore, I can't ask them why they decided to go with a C func... |
We are trying to create an online-shopping like application in which we have to store a huge amount of data,since the data that will be stored are mostly document like data, the suggestion was to store the data in mongodb and using elasticsearch to add the search functionality, but i also know that elasticsearch itself... |
Consider this piece of code from the PHPUnit manual(I'm using PHP only as an example):
class StubTest extends PHPUnit_Framework_TestCase
{
public function testStub()
{
// Create a stub for the SomeClass class that could be later injected into another class, but removed here for simplicity.
$stub... |
Let's say I use Semantic Versioning for a my project. I'm developing it under FooOS, but the language uses virtual machine(either interpreted language or bytecode based) so any operation system can run it. The thing is, the project interacts heavily with OS-managed things(e.g. pipes, processes, the file system) so if y... |
This is my situation: I have a search results page in PHP where most of the logic resides in a javascript file in order to avoid refreshing the page every time an action is performed. The first thing I do using PHP is filter out and save valid query string values to PHP variables and I make use of the htmlspecialchars ... |
I want to make a system, so that there are certain tasks. For example, let's talk about a game. I want to make it so there are 100+ tasks doing different things, but when the player's magic level is 5, it will do the magic task, if the player's fighting skill is level 5, it will fight. I have that already, however here... |
I'm currently making a game and want to use some textfiles (lists of names) that are covered under the GNU General Public License (or the Attribution-ShareAlike 3.0 Unported License). Do I have to release my whole game under one of these licenses if I only used these (relatively small) files in my game or is it just th... |
I'm developing a website (using Django) which will depend on an API for it's main functionality which is create/update/delete objects.
But the API also provides:
User sign up and login
User relations to their objects
User groups and permissions
This is great but I'm conserned about fully depending on the API for ever... |
In D I can create templates like this:
template Foo(A) {
A add(A a, A b) { ... }
A multiply(A a, A b) { ... }
A concatenate(A a, A b) { ... }
}
What should a template be named ideally? What conventions exist out there? I'm looking to something similar like 'function names must always start with a verb'.
|
C++11 features the new auto type declaration, allowing you to work with an object without ever knowing its actual type.
I use only strongly typed languages - C++, Delphi (Object Pascal), Go, etc and I feel uncomfortable (guilty?) using auto, (or for example the short variable declaration - x:=1- in Go.) It feels like a... |
I am going to develop a software that works with different databases and I'm considering whether to use .NET languages or C++. I've known that .NET features LINQ and ADO.NET but are there features like that in the native C++? Which one works better, faster with databases?
|
I am working on making a system for the automated testing of student assignments. The biggest hurdle I am facing right now is figuring out how to sandbox the testing of the code yet still get and process the results of the test. I need to run it on a VM as there is no guarantee the code will not be malicious.
I would l... |
I’m using the light-weight PHP Fat-Free Framework as a base to form a simple MVC based app with DDD philosophy for the Model layer. I’m aware that DDD is most suitable or enterprise solutions and that applying DDD to simple, mostly data-driven apps is kind of an overkill, but there are some concepts in DDD that I find ... |
I am currently attempting to make a Trading Card Game and I have got a whole array of features working already, yet I am stuck now at the portion where one player can attacker another player (more strictly: the monster cards of another player on the field). The game is designed primarely to be played with two players i... |
I'm using a variant of the MVC pattern. In my GUI code, often the need arises to synchronize "view data" (e.g., selected item) between different views.
For example, let's imagine a vector drawing program. We have two views: the image, and a listview of all objects (rectangles, squares, ...). The currently selected ite... |
I am preparing for interview and try to solve the exercise problems of the book.
3-6. [5] Describe how to modify any balanced tree data structure such that search,
insert, delete, minimum, and maximum still take O(log n) time each, but successor
and predecessor now take O(1) time each. Which operations have to be ... |
I just got done watching an informative Box tech talk by Nicholas Zakas on a javascript architecture for web development:
https://www.youtube.com/watch?v=mKouqShWI4o&feature=youtu.be
This image, which I acquired from http://alanlindsay.me/kerneljs/index.html#nav-what , will give you an overview of the architecture:
Ho... |
So one of my long-standing projects is an online fan-game that's been running for a good four years now, and is at least somewhat well-known among the related community. To give you an idea, Alexa ranks my online game higher than the official website for the franchise my game is based on.
One thing I've been wondering ... |
My Plan
Have a system that holds some objects
Have a winforms-form that displays some key values of these objects
When certain changes occur(object gets add / removed / datat change): Update GUI
My Idea
subscribe my form to events in the objects
update form when objects chamge (/raise events)
My Troubles
winforms... |
By accident I found that with a polymorphic type using dynamic_cast back to the derived class will throw a 'bad cast' error if the pointer is no longer valid. Is this undefined behavior or could this be a way to check for valid pointers without using smart pointers?
I'm not really against using smart pointers as they ... |
I work at a mid-sized company (150ish employees, ~10 size engineering team), and most of my projects involve interfacing with lab equipment (oscilloscopes, optical spectrum analyzers, etc) for the purpose of semi-automated test applications. I have run into a few different scenarios where I am unable to efficiently tr... |
I'm aware that it's not possible to load a 32-bit DLL into a 64-bit process.
The DLL in question is a ODBC driver which is no longer supported (although it works fine) and no 64-bit version of it exists. I don't have access to the source code either.
There doesn't seem to be an off-the-shelf way of "thunking" between ... |
Currently the structure of my application is as below
Web App --> WCF Service (just a facade) --> Business Logic Services --> Repository -> Entity Framework Datacontext
Now each of my Business logic service is dependent on more than 5 repositories ( I have interfaces defined for all the repos) and I am doing a Construc... |
I learned about local classes on the Oracle Java Tutorial page. Not nested classes.
I don't see myself using local classes. It makes the code look messy and you can easily do what local classes do with having a class declared separately.
But maybe I'm missing some use cases for it. Are there situations where you would ... |
Recently I learned that some teams have moved all their database manipulation to the actual database through the use of stored procedures. I thought that was pretty clever, since the database becomes a black box and any change to how the data is stored and manipulated won't affect application code. Is it accurate to co... |
I'm a web developer. I feel like I develop less resource-intensive functionality often times, because I have this feeling that if I ask too much of the web app (animation, calculation, connections, etc), it will get lagged for users with slower computers.
I've been curious for a while now about just how much differenc... |
I am looking to design an extremely modular game engine that allows for portable native plugins similar to the way PNaCl works with chrome. The biggest factors I need would be: cross platform, sandboxed, and the ability to launch an arbitrary number of these plugins based on what folder they reside in. I can't have any... |
I'm currently working on a wordpress plugin. My client gives me a specs doc (a powerpoint presentation, if you can call that a specs doc), and I code the requested functionality.
Every time I send him code every file containing code starts with these lines:
Author: My Name
Copyright: The_client's_company.com
License: M... |
Like having 1 be the most common number and 6 be the least common number. And everything else just leveling out.
|
I am working on the architecture for a new web application and I am pretty much a complete newbie when it comes to architecture. Working my way through .NET Application Architecture Guide, 2nd Edition and learning a lot. I have decided to go for the "standard" 3-layer architecture: Presentation layer, Business layer, D... |
From the Code Complete book comes the following quote:
"Put the normal case after the if rather than after the else"
Which means that exceptions/deviations from the standard path should be put in the else case.
But The Pragmatic Programmer teaches us to "crash early" (p. 120).
Which rule should I follow?
|
With JavaScript becoming one of the most widely used languages around, I began asking myself why people do not find ways to use it extensively on the JVM. As a programmer who spends half day writing Java, and the other half, writing JavaScript, I do see a lot of potential in this.
Was it just the timing that shot Scal... |
Instead of a one long flat commit history, why isn't there a hierarchy, so at the top level you might have pull requests, then you could go down a level and look at the commits in that PR. I realise that PR's are specific to github, but you get the idea. I just mean grouping a number of commits as a feature or bug-fix,... |
I have a MVVM app with DataServices (using mvvmlight).
Right now, i'm using it like
var answer = await myDataService.PullList(categoryId);
if (answer.Status == Ok)
ObservableListOfItems.ReplaceWith(answer.Collection); // Show results
if (answer.Status == ConnectionLost)
// Handle connection lost state, show msg... |
I am building an Integration Testing Solution using Selenium in VS2012, which will be run on a CI server in the near future. I need to provide some way to vary the values being used for testing. The easiest would be to provide the QA testers with a few template spreadsheets, which they can fill in to run tests with tho... |
I've developed for several web application projects for the last 3 years, both personal and at work, and I can't seem to figure out whether it's possible for at least some business logic not ending up in the view layer of the application.
In most cases there will be problems like "If the user has selected option x th... |
I recently listened to an episode of Software Engineering Radio in which Leslie Lamport was interviewed. One thing he discussed was his specification language, TLA+.
Essentially, he seemed to be arguing that, for programs where correctness is very important, we need to think carefully and specify carefully before writi... |
I have many models in my project, and some other classes just need the class declaration and pointer type aliasing. It does not need to know the class definition, so I don't want to include the model header file. I extract all the model's declaration into one file to let every classes reference one file.
model_forward.... |
Is it possible to fork a project (which I don't own) and change the license from BSD to for example LGPL / GPL / AGPL?
I read it would be possible to change fork's license to something compatible to BSD - is this just a rumor / urban legend?
|
Consider the following problem:
Description:
There are n jobs J1...Jn with cycle times C1....Cn. Find a time quantum and a scheduling table considering that:
any element of the table contains at most one job
the job handler will process an element at a time, i.e. execute the job (if any) then, after a time quantum pa... |
I am looking for a way to get the logic of retrying an operation in a single method while keeping the exception types of the operation.
I.e., the implementation to retry an operation could look like this:
public void retriedOperation(Operable operable, int maxAttempts) throws Exception {
for (int attempt = 0; attem... |
For example: an MIT-licensed project wishes to simplify the build process for its users by including part of the GNU toolchain (which is of course GPL) as a Submodule.
Could that be interpreted as making the MIT project a "derived work" of the GNU toolchain?
Does including a project as a Git Submodule (or some simil... |
I'm looking for insight from someone who has used at least AWS (if not also Parse.com). My iOS app currently uses Parse.com for these purposes:
1) to store user data (by translating between JSON and core data)
2) to run javascript functions to update my database with data from the web
3) for easy Facebook authenticati... |
Background
Test Driven Development was popularized after I already finished school and in the industry. I am trying to learn it, but some major things still escape me. TDD proponents say lots of things like (hereafter referred to as the "single assertion principle" or SAP):
For some time I've been thinking about how T... |
I am facing a problem in synchronizing my model and view threads
I have a view which is table. In it, user can select a few rows.
I update the view as soon as the user clicks on any row since I don't want the UI to be slow.
This updating is done by a logic which runs in the controller thread below.
At the same time, th... |
Whenever we implement a frontend framework in the likes of Backbone, AngularJS etc. there's an integration process involved with the backend technologies like NodeJS, Rails, Yii etc. (like setting up routes, generating views or adding libs etc.) which varies depending upon what you select at the front-end and what you ... |
A general question about open-source licenses: I know you can't modify them yourself (i.e. "GPL except you can't do this") and writing your own is generally a bad idea. However, is it feasible to add "Please do this" riders?
For example, say that I want to license something under the GPL. Can I add a clause which say... |
MVC is used a lot (not only in web apps) and it seems it's the 'go to' approach when designing software. There are also a lot of MVC versions.
My question is: what was before MVC? How did people structure large software systems?
Obviously 'separation of concerns' wasn't invented with MVC (even if it wasn't called that)... |
I'm playing with a mental model for distributed actor system that communicates using messages. In this, it is possible for an actor to create another actor. I've encountered one specific situation where I'm not really sure how to resolve. Consider this sequence of events:
Actor 1 requests creation Actor 2. As part of ... |
I have developed an application for android requiring no permissions, but the biggest downside of this is that I don't have error reporting. So, I was playing around for the past week with any alternative options which would allow error reporting without network permissions and without privacy risks. So I came up with ... |
In Vaughn Vernon's book Implementing domain driven design and the accompanying sample application I found that he implemented a CQRS approach to the iddd_collaboration bounded context.
He presents the following classes in the application service layer:
CalendarApplicationService.java
CalendarEntryApplicationServ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.