instruction
stringlengths
34
19.9k
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...
Ruby normally makes things easy. However, it doesn't allow implicitely converting a number to a string: 2.0.0p247 :010 > "a"+1 TypeError: no implicit conversion of Fixnum into String Why is this when nearly every other language allows it, including Perl, PHP, Java and VBA?
I'm comparing 2 different approaches of J2EE application architecture: Divide independent parts as modules of one big web app. Divide independent parts as different web apps running on same server. Between these approaches I prefer the second one because it allows me to make changes without redeploying the whole appl...
I'm developing a push-notifications system for my ASP.NET MVC app. The idea is to use Redis for queueing, ServiceStack for queue processing and SignalR for push-notifications to implement a system that's able to distribute different types of notifications. I've put together a quick prototype where I have a ServiceStack...
When I set a variable to an object in VBA / VBScript, I always need to prefix the statement with "Set" such as: Set Dict = CreateObject("Scripting.Dictionary") If I set a variable to a primitive or array value, I have to omit the "Set" such as: Num = 123 This is different from languages such as JavaScript, PHP, Python ...
So, for the first big project that I'm getting paid for, I decided I'd do things right. To that end, I've created several projects in my Solution. Some of these projects are generic and handle common elements that can be used in any project (stuff like logging and such), but that's not where the focus of my question is...
I wasn't sure how to formulate the title, but there's something that's made little sense to me in OOP I understand the idea of encapsulation, which is to create a layer of protection, and abstraction, so that there's no direct access to a given variable. However, there are cases where encapsulation doesn't make any sen...
I'm facing a very real problem and, sadly, I cannot find the answer on my own: I'm hitting my limit as a programmer because my hardware knowledge is not sufficiently advanced at all. It's an issue I'm encountering during the development of the system (I need to find safe parameters value which depends on the answer to ...
I'm using an offline application's javascript API and I'd like to know if I can use deferred objects to handle the callbacks. The API calls do not use HTTP, the calls are to and from the applications local database. The only way I've been able to display information is by using 'setTimeout' on subsequent calls, which I...
We have a database that stores the process/history of particular machines. What I mean by that is that we have "started", "updating", "shutdown", and so on for all the computers in the company. The requirement is to have the history available in the right order. Simple enough. My approach was to have a simple database ...
I understand that for normal websites you'd want to share scripts and css and therefore liking to them means that each page shares them from the cache. But this question is not about "normal multipage websites", it's about WebApps. Pages where only one page is ever served. Examples include gmail, new google maps, faceb...
Here's a programming/language problem I'd like to hear your thoughts on. We have developed conventions that most programmers (should) follow that aren't a part of the languages syntax but serve to make code more readable. These are of course always a matter of debate but there's at least some core concepts that most pr...
I'm currently working on a project that the client wants to deliver to different countries. The application is a website. We started out using resource files to change the text the user sees when visiting pages based on their locations. But this isn't enough. In the English version of the site we have a page that state...
I am attempting to learn more about C and it's descendants(C++ mainly). I have decided that I would like to create a "file system" of sorts. Not a particularly advanced one mind you but something to play with. I have no intentions of making it mountable, securable or even recoverable. At the moment I am stuck in con...
I am constructing a UML 2.0 activity diagram. The activity is to evaluate data from a usability study of a prototype. It can optionally end with just getting the user satisfaction results. But if the company wants to choose which features to implement in the final version, which ones to change and which ones to leave o...
I have a series of hardware devices that I'm connecting to create paths through. I have some sanity checking to make sure if potential paths are valid and will do what is intended, but to do it properly I need to know what device is the source of the path, and other information from that soruce. Once everything is set...
These days it's possible to hash a file client-side, send the hash to the server, and have the server check whether or not that file is already uploaded. If it is, we can skip the file upload and make it appear to upload almost instantly to the user. This can also save have oodles of bandwidth for a large site. This ha...
I am currently writing an application that isn't huge but will be used through-out my company of 200+ people and external customers about projects we are working on (not software projects), but there are a fair amount of business rules, along with the implied ones that go with creating, verifying, and maintaining user ...
I understand and enjoy the benefits of the Garbage Collection in Java. However I don't understand why there is no way in Java to explicitly (and quickly) destroy an object. Surely this could be useful in some cases, I assume performance-critical software. It's true that in Java the GC will delete an object with no exis...
I think voice recognition is cool, and I might start studying it soon, but one big question that I've always wondered about is "How do the programmers separate the noise from the voice?" I mean, if you've watched "Her", you'll notice the main character uses voice commands commonly in quiet places, but today, voice reco...
I am interested in finding out who introduced code indentation, as well as when and where it was introduced. It seems so critical to code comprehension, but it was not universal. Most Fortran and Basic code was (is?) unindented, and the same goes for Cobol. I am pretty sure I have even seen old Lisp code written as con...
Just to get this out of the way, I have seen this, and it is not what I'm looking for. So, let's say you are programming a Rubik's Cube. (I know, very unoriginal, but bored programmers have to do something..) This Rubik's Cube is defined by an array of six 2-D arrays (one for each face,) and these 2-D arrays' sizes var...
In my team we have a multiple projects, some short term and some long term. The team is required to deliver these projects on different dates and the effort to deliver these is run in parallel with the team working on stories for more than one project during each sprint. When trying to compute our burndown we aren't su...
Context: I am making a learning project in XNA. What I would like to be able to do is allow the game to be moddable by allowing the users to place arbitrary values into a JSON data file which is read into the game. The thing is that I want to avoid hardcoding if possible and have it automagically work for whatever the ...
I have recently joined a startup as CTO/co-founder. The startup and I have been thinking about moving the existing codebase (which is in PHP5.5, laravel framework) to node.js . Main reason for this being that at the stage we are in right now, I'll need to hire talented, but inexperienced developers and train them to wo...
Context I have Specification class with several properties including: StartDate, EndDate, DaysToComplete, DateToComplete. A specification contains a list of required courses (i.e. a company requires employees to take training... perhaps a technical, diversity, or an ethics class). Based on a specification, courses will...
We're currently upgrading some components of our application to new technologies such as C# using WPF and MVVM. Since we try to avoid past mistakes that have been made in our now legacy applications, a question came up in our team how we should ship external resources that are likely to change, such as icons or images....
So I have my application consisting of a number of modules in a module hierarchy. Furthermore let's also assume each module is a class and we have a tree of classes where the classes at the top are using the classes below, to make it more simple. A class A1 at the very bottom may depend on some input parameters. class ...
I have a 3-layered app structured as follows. Presentation Layer (ASP.NET MVC project) Business Logic Layer (Services for controllers in PL) Data Access Layer (Repositories) Each Controller in PL interacts with its service in BLL, which in turn has access to Repositories in DAL. Is it a good practice to do a "global"...
I learned at school as well as I read everywhere else that a good development methodology needs conception and design before coding properly. That is not a new information even for a beginner programmer. However, I wonder if this a good advice because since I started developing in several programming languages I never ...
While studying the features of XML, I got to know that XML is software and hardware independent. Can anyone explain me why it is meant like that?
I'm a programmer and I'm looking to play around with translating one language to another. Say C# to Lua. I'm curious as to how translating languages like that works? I would think there is some kind of standard methodology that I could perhaps look into for this or is it pretty raw?
"Code review" (aka "peer review") seems like a really great idea, so my team started practicing it. For a little while it worked well, but then a co-worker merged a branch in, and asked for a review of the code. When I went to review her code, the Github diff page was about 420k pixels in height. Given that my screen...
I code in Python and I'm starting to use the Mock library. Although I've read through all of the documentation, something that I'm finding hard to understand is 'What makes a good mock'. For example, say I've got a function that makes a HTTP request: def fetch_url(url, method=urlfetch.GET, data=''): """Send a HTTP ...
My team has all agreed that writing a company development blog is a good idea. There are a lot of documented benefits to blogging, both for the individuals and the company. However, while everyone agrees that a blog is a good idea in theory, no one seems to want to actually sit down and write an entry. Between having a...
(Building on this question) If you have a static code analyser such as Checkstyle, is it possible to to relate any of the stuff that it checks for to actual robustness? Some of the things that Checkstyle checks for are e.g.: Class design: Visibility of class members, enforcing public only static final members, no pub...
Lately I started studying about different interesting concepts that exist in languages other than Java. Since the only language I've ever programmed with is Java, a lot of these concepts are very new to me. So this question may be very naive :) . I learned recently about first class functions and function pointers. Why...
I have been away from computers for about 3 years and starting to get back into programming. Lots has changed in resources and help sites available on the web especially the evolving StackExchange community. I come from the IRC #javascript, #html, #php days with php.net and a bit of google search finds here and there. ...
Coming from Java, I've never used a language with dynamic typing. I'm very used to the static-typing way of thinking. My question is, how much does the use of dynamic typing as opposed to static typing influence the overall design of programs written using languages with that kind of typing? Does the kind of typing (st...
I will immediately confess that I do very little multithreading, so questions of style and organization in this domain a little fresh to me. I've written a data structure (in Python, if that matters) which implements a special kind of a queue. I'd like to use this queue to pass messages between threads. Currently, the ...
Let's say we're writing a simple JSON parser and we've fully covered the code with unit tests: it can parse primitives "0", "123", "-456", '""', '"asd"', true, false it can parse arrays "[]", "[1, 2, 3]" it can parse nested arrays "[[]]" it can parse objects "{}", '{ "a": 1, "b": 2 }' it can parse nested objects '{ "a...
Why the c# allows project not to be strongly signed when they are build? They may be signed by some automatic name file if programmer do not choose his(hers) own sign file. Where is the advantage of not signed .dll file? What the strong names are? I am working on project which uses C# .dll files in Microsoft Dynamics A...
Sometimes while I'm editing something I see some useless code added by other developers, probably due to habit. Editing this code will not make any difference, so is it appropriate? In my specific case I'm talking about Java private fields like this: private int aSimpleInt = 0; private boolean myBool = false; private M...
I'm designing an object dependency graph of my program and one ambiguity between design variants appears from time to time. Imagine two objects having a reference to each other. Obviously, at least one reference should be assigned after object's initialization (for example, through a subscription method) and another on...
I have dataset that is contain 150 data that is actually divided into 3 group. Each group has it’s own label. I do clustering process with K-means algorithm to group the data. I need to assign the label of each group that is created by K-means process. So I could compare the result of K-means with the data training. An...
Setup Many years ago I took to a style of unit testing that I have come to like a lot. In short, it uses a base class to separate out the Arrangement, Action and Assertion of the test into separate method calls. You do this by defining method calls in [Setup]/[TestInitialize] that will be called before each test run. ...
I check Open Source Compliance for commercial code. I have recently found a few examples where the commercial source is matched against quite a few OSS projects. The matches are very similar, but not exact, say about 30 lines of code with about 4 methods, a few variables names differ, some extra lines in the commercia...
Recently, I started reading the book Specification by Example, which relates to automated functional testing and BDD (from what I've understood till now). I've tried using Concordion (.Net), and seems very interesting. I've been having issues with keeping any form of useful documentation for any designed system, and t...
I have a resource that can be represented in one of two ways: Big Serial Number, or Small Serial Number Is it closer adherence to REST principles to: A: have a query string specify the type (https://acme.org/api/widget/aaa-111-aaa?type=big vs https://acme.org/api/widget/aaa?type=small), or B: have query strings spec...
I write many a PowerShell script for the organization I currently work for. Most recently I have been co-writing a tool that, in the end, will have a lot of functionality (beyond a single purpose), will be configurable, and will have both a CLI and GUI, all in PowerShell. So when does a script stop being a script and w...
I have a project that requires a client app to communicate with a server. I was wondering if there is a way for the client app to detect available servers and "know" by some method or another which server is the one it needs. The client is built with .net and c#, the server is a simple SQL database.They are on the same...
It seems to be a very common thing to have to tell whether some list or set contains at least one object matching a given condition, yet my prior searching and reading have never found a satisfactory best practice or design pattern to speak of. In the situations I am thinking of, merely using "contains" is not suffici...
I primarily work with .Net WPF MVVM applications. I've used several frameworks, MVVM Light, Prism, etc, and I've been able to break the implementation of CRUD MVVM into three scenarios. Scenario 1: A web service returns a paged collection of small objects with no navigation properties, I whirl through these wrapping t...
I'm working on a project that, when all boiled down, is essentially a raffle. The twist is that due to the way we've set the ticket value, a user may be casting 10,000+ tickets. Essentially, a user can chose to cast a certain number of tickets for any given raffle. At the end of a period of time, a winning ticket is ch...
I was just reading this slightly older post on choosing a good source control system when I started thinking about how different projects use source control. Where I work we've essentially moved completely to Git and things have been mostly good. I have wondered about high security projects such as military software pr...
As our team is growing I've noticed that different developers put their class methods in different orders. For instance: var Foo = Backbone.Model.extend({ someVar: {}, initialize: function() {...}, fetch: function() {...}, handleFetchRepsonse: function() {...}, getFoo: function() {...}, ren...
All my projects share the same base library that I have build up over quite some time. It contains utilities and static helper classes to assist them where .NET doesn't exactly offer what I want. Originally all the helpers were written mainly to serve an internal purpose and it has to stay that way, but sometimes they ...
Please consider the following implementation of the Decorator design pattern: WordBank objects store strings and return them to the client through the method getWords(). The decorator class, WordSorter, is a subclass of WordBank (as in the Decorator pattern). However it's implementation of getWords() sorts some of the...
Almost everywhere you can read that you should use EL instead of scriptles in JSP. And I agree that you should not use any JAVA code in JSP except for calling getter methods on model objects. This is quite obvious for me and I don't need any clarification here. But there is this one thing that I really cannot understan...
Lets say you've got a list l = [0, 2..] and you want to get the nth number when n is pretty large, say n=123456789. So you call l !! 123456789. On my machine, this results in out of memory. So why aren't Haskell capable of realizing that the number at index n is 2n, and making a call such as l !! 1230981237 trivial?...
I'm new to NoSQL and have been playing around with a personal project on the MEAN stack (Mongo ExpressJs AngularJs NodeJs). I'm building a document editor of sorts that manages nodes of data. Each document is actually a tree. I have a CRUD api for documents, to create new trees and a CRUD api for nodes in a given docu...
I'm developing a desktop application with a GUI. To do so, I'm using the MVC design pattern for the GUI part. For now the application consists of a single window (view) with one controller interacting with the backend (model). The interaction is becoming more complex day by day with the controller getting more and mor...
I'm currently scratching my head over how to refactor a method that basically only builds the UI. The method is more than 1500 lines of code (LOC) long - and counting. It has grown, there was no plan how to approach this. You might find this familiar. Anyway, it's basically just one large method that goes a little some...
I'm really struggling to find a concrete, easy to grasp, explanation of Atomicity. My understanding thus far is that to ensure an operation is atomic you wrap the critical code in a locker. But that's about as much as I actually understand. Definitions such as the one below make no sense to me at all. An operation dur...
I'm a hobbyist programmer, so no professional experience. People here often talk about doing maintenance of software at work. The author of this question talks about doing 90% maintenance and 10% development at his job. My question is: what is 'software maintenance' anyway? Is it mainly about fixing bugs? If so, does t...
When you want to have continuous delivery any data schemas that you have must support multiple versions of your application at the same time (as you may have multiple version deployed when new versions are rolling out) In my specific case I have entities stored in Azure table storage. When I am making changes to my ent...
A few months ago I started a project, which will have two parts – business client overview panel (AngularJS SPA) and public front-end (dynamic HTML with progressive enchancements via XHR). I'd really like to stop and throw away dynamic HTML and switch to AngularJS + API + static HTML combo (like in "panel") to avoid du...
I am implementing a binary search tree in java. Inside the BST class I have a protected class Node (in case I want to extend to an AVL tree). The code is below. I had a problem, both conceptually and aesthetically, implementing empty nodes as null pointers. So instead I opted for the null object pattern and created an ...
I was wondering why the default select tag of HTML, for example: <select name="company_name"> <option value=""></option> <option value="1">Company 1</option> <option value="2">Company 2</option> <option value="3">Company 3</option> <option value="4">Company 4</option> <option value="5">Company 5...