instruction
stringlengths
34
19.9k
I'm a college student and I have homework in C++. My professor wants separate hpp and cpp files for each C++ class. And it just didn't feel good how much I had to type, and how much I had to click to create two new files for every class. I haphazardly put together a simple Python script that would read a single file an...
I had this crazy initialisation -- documentList = new ArrayList<Map<String,Integer>>(); which I intended to store a new map everytime in a loop but unfortunately put itself inside the loop. And you know the havoc. How do you detect such mistakes? I might be looking for suggestions on 'recommended debugging techniques' ...
We have a professional Scrum Master consultant [*] who recently joined our project. Unfortunately, we don't know her name (she never introduced herself to us, she just came in one day and said "we are having a daily stand-up"), and she doesn't seem to do much else except chair a daily stand up meeting - when I half-jo...
I have a custom designated initialiser like this: - (id)initWithLocation:(CLLocation *)location { if (location == nil) { return nil; } self = [super init]; if (self) { self.location = location; } return self; } My colleagues sometimes ask me to wrap everything (apart ...
My application has a rather non-trivial, yet standard, log configuration. It includes a console appender and a rolling size-based file appender. When I'm running the tests, thru the IDE or with maven, where is the least surprising place to save the log files?
I've been doing PHP for 4 years now. 2 years at school and 2 years at work. But I feel like I'm stagnating. Here are some things that I currently know about PHP: Basics (variables, control structures, arrays, loops, sessions, cookies, file manipulation) Database Integration (MySQL) OOP - I only know of the basics (cre...
What are the differences between string.c_str() and &string[0]? Regarding performance my guess is that &string[0] is a little faster than string.c_str() as it doesn't require a function call. Regarding safety and stability common sense tells me that string.c_str() should have some checks implemented, but I don't know, ...
I have been having this experience for sometime now, when a client needs a software product and contacts me, the client usually wants to know the time frame on which this product will be accomplished. Usually as a software developer I might not be able to fully determine how long it will take me to finish the job since...
I work on a company that have a payment system that runs under a executable kiosk instance of internet explorer 7. when the application is running the process name is not similar with iexplore.exe or something like that. The name of the windows process is the same as the executable.exe. We cannot run the system under ...
At my company we have some vendors that we transfer data to and from. Sometimes the data is pulled into our local SQL database for business reporting. Other times we pull data from one vendor, transform it, and then transfer it to another vendor's FTP server. The guy I replaced has a couple of generic SFTP Push/Pull c...
This post describes a new feature in Java 8 called virtual extension methods (formerly called default methods, or defender methods). In the example provided, an interface has one method, which is implemented by a class. Then a second method is added, but instead of forcing the class to immediately implement the interfa...
I see many job adds which require at least x years experience. The question is how do you know when a candidate has the required years of experience? What do you expect from a person with x years experience (edit: effectively how do you check if the CV isn't lying without relying to skill checking)? What can a person w...
I have been falling into a pattern lately where I have been defining routines that rely on an interface defined by a function that is specified as a parameter to the routine. (The language is C#, but this can be applied to any language with first-class functions.) For example, I have an API that exposes CRUD operations...
Several implementations of mixins (e.g. Ruby mixin, Scala trait) include support for storing data (e.g. variables, properties) between method calls in instance variables. There was a bit of debate in this question about whether or not a Java virtual extension method qualified as a mixin because they cannot store data i...
I'd like to have suggestions about the structure of my web application. What the app does: My app receives files from about 800 scanners around my country and the users see the scanned pages into this web application, then they can organize the pages in groups, choose which one keep and which one discard, and insert ...
I have a decision to make and I am wondering what would be the better solution. I am refactoring an older application and intend to really get into the nuts and bolts of it. There are 8 report types currently and one of the modifications are to allow different reports to be "saved" in different ways. My two thoughts on...
I understand that the dependency injection is something done by coding and its all done at compile time. And that Dependency injection coding is easily done now by helper tools like Ninject. However this is at compile time that the dependency injection occurs. Then what does it mean that dependency injection also occu...
My Situation I work for a company that builds software for many other companies. When I learned installers weren't built-in with VS2012, I was curious how to deploy. So far, I have just been dropping .exes on our clients servers using PowerShell scripts. Now I need a full-blown Windows service. I have seen many example...
I'm designing a schema table that will manage the auth tokens for integrations // app with social networks. At the moment only for Twitter and Facebook. I'm thinking in this mode id social tw_token tw_token_auth tw_secret tw_secret_key fb_token fb_secret 1 twitter aaa bbbb cccc ...
I am using JRuby. I have many classes implemented in Java, and I want to create objects off of them in my Ruby scripts. Suppose that I have a class Sprite in Java. In Ruby, to refer to it, I use the following: Java::ComMyWebsiteMyProjectName::Sprite Because Sprite is defined in the package com.myWebsite.myProjectName....
I usually write my software projects in Java, and I am still a bit confused as to when to document my classes, interfaces and methods. There are two ways: 1) Write documentation after declaring or coding a class/interface/method/constructor. This way I am sure documentation is handled immediately. Disadvantage: I might...
I am building an online social network. I have finished writing RESTful API service using Django. This will return only JSON response (No HTML will be generated from server side) so that this JSON response can be used to build native smartphone apps. API service being common to all clients. My question is, since there ...
This is probably something that should go to the legal department -- presuming they have any inklings about software licensing -- but what software license should I use against code developed for use at a publicly funded institution (in the UK)? Specifically, it's internal-use code for various university systems. I bel...
I have a Grails application with a number of services that are starting to get very large. The flow in the majority of my service methods is Database read (Returns DBCursor from MongoDB) Iterate through the cursor and perform some operations. Return results from operation. I'm beginning to consider moving the logic ...
Stack for different thread is different.but what about Heap. If Heap is different for different threads, then how they share objects?
As I understand in most security breach where the list of hashed password are compromised, attackers do use brute-force to try to find weak password and, invariably, they always find quite some (like in the recent Github breach). If I'm not mistaken in most cases when a user creates an account, the password is sent, en...
I am really confused about software linceses, I've read a lot of articles but I can't find an answer to my question, which is: Can I develop and sell applications that uses libraries under gpl license? Like for instance, I want to use agsXMPP library in a windows phone app, and sell it in the market, so is it legal?
Is there a naming convention for higher order functions? That is, functions which return other functions. An example in Javascript: function onlyDivisibleBy(div) { // <-- higher order function return function (n) { return n % div === 0; } } var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; arr.filter(onlyDivisibleBy(...
How do I make sure my REST API only responds to requests generated by trusted clients, in my case my own mobile applications? I want to prevent unwanted requests coming from other sources. I don't want users to fill in a serial key or whatever, it should happen behind the scenes, upon installation, and without any user...
I've a functional test using Junit which tests delivery of xml file to an end-point. XML file is sent by client, so I copied it to a test folder, read it from there in my test and do asserts. We have 10-20 such files with different data but same format, my architect wants me to copy all of them into same folder, loop ...
When Googled, many responses for this topic come up. However, I don't feel like any of them do a good job of illustrating the difference between these two features. So I'd like to try one more time, specifically... What is something that can be done with self-types and not with inheritance, and vice-versa? To me, there...
In some of my code, I have a static factory similar to this: public class SomeFactory { // Static class private SomeFactory() {...} public static Foo createFoo() {...} public static Foo createFooerFoo() {...} } During a code review, it was proposed that this should be a singleton and injected. So, ...
Doing some refactoring, I noticed an unusual pattern I'm not familiar with. Properties and variables that do not yet have a value are initiated with undefined declared explicitly, despite the fact that value-less variables and object properties would evaluate to undefined anyways: var foo = undefined; this.prop = undef...
I'm developing a multi-part solution that consists of an iOS application and OS X application which communicate over Bluetooth Low Energy. Everything works fine and I can send moderate amounts of text between the iPhone and my MacBook. I would like to be able to send larger amounts of data, such as an image, from the i...
Say you have a web service, which adds business logic on top of a data source. What each API of this service pretty much looks like is - given a set of constraints, give me the items from the data source that satisfy these constraints. You can say you get a "view" of the data source back from the API. Now, over time yo...
The current system I am working on goes through a set of documents & performs some logic using the metadata of the document. If the metadata of a document is fishy..it throws an exception. The system logs the exception, fail the job & let the developer fix the issue by looking at logs before moving on. I want to improv...
I have been tasked with teaching other teams a new codebase, but I keep running into an issue. Whenever I go to actually walk through the code with people, we don't get very far before the entire exercise devolves into a bikeshedding (members of an organisation giving disproportionate weight to trivial issues) exercise...
I am planning to post an article on codeproject.com where I will be sharing some code I feel worthy of the effort - so I went and read the posting guidelines. It appears that I will have to select a software license for my submission. I really do not care about my material and what people will do with the code that I w...
I'm studying OOP PHP and have watched two tutorials that implement user login\registration system as an example. But implementation varies. Which way will be more correct one to work with data such as this? Load all data retrieved from database as array into a property called something like _data on class creation and...
If you have different database per customer as there is no need to share any data between them does the same apply if a customer has multiple stores ? I believe that it is easier to do queries for statistics (some require 4-6 table join) if they are at a single schema rather than multiple schemas. But everyone (haven't...
I've been building a large web application for a company. Initially the project owner appointed a Graphic/Web designer to complete all design/front end works. Me and who ever I bring in to complete back end and all the view binding at the front. The initially front end/graphics guy dropped out and was replaced with a (...
I've been developing an application using the Laravel Framework & have been exposed to the idea of queues for the first time. There are a multitude of tutorials & articles about using queues & examples of what to use for, but I've never seen anyone writing about or highlighting when one does not need to actually use an...
New to OOP and trying to understand some basic fundamentals. Currently using PHP5 to build a basic web app. In using PHP's built in PDO as my database class and a separately created user class that handles, among other things, user log in and out, is it best to have the db class connect to the database in a log in situ...
I have a project on CodePlex that I have opened to basically anyone to join and help out on. I am mostly an enthusiast coder, although I have done some programming work as part of my job it has always been solo projects that my team uses for IT support. With my CodePlex project, I got my first new fork yesterday. I clo...
I want to implement loose coupling in a project. I know two examples of successful loose coupling designs: On a Unix workstation, shell scripts realise a loose coupling between basic utilities. The loose coupling relies on the shell's ability to blindly redirect data flows between utilities, without having any knowled...
I have a dictionary of Objects of a class Columns Dictionary<double, Columns> Columns is a class of columns, i.e. name, post code, etc, mobile phone. I would like to make Columns class as much open for extension as possible, so it will be no trouble to add more classes. I need to set few of the columns to be there alw...
I have some function names which are assigned to some nodes. I have to decide which functions to move to other nodes to increase speed. Why do I have to move the functions to other nodes? If communicating functions are on same nodes they take less time as compared to if communicating functions are on different nodes. A...
First time I make use of Code Review. At the moment I'm creating an Android application and the company I'm developing it for, has a specific file format that can be used to give text based data specific formatting rules. See it as an rich text format especially build and designed for their use. The File format to work...
When developing domain models, I can see two major ways of thinking about the user: The first one assumes that a program is a kind of "simulation" of what happens in the real world, and the user is an spectator. With that approach you would have a Customer class -for example- with perhaps methods that correspond to th...
I have a class that is 99% identical to its counter part. Sample code goes below: public abstract class BaseClass { void Method1() { } void Method2() { } void Method3() { } public void MainMethod(List<Object1> listObject) { Method1(); Method2(); Method3(); Method4(); ...
Are there any reliable strategies to implement a login mechanism that will allow access to an application for maintenance purposes? Kind of like how some routers have a list of default logins that technicians can use. But the way routers do it is insecure, and I was wondering if there are better ways to implement this ...
I'd like to know if there's a technical reason of why PHP's designers decided to invoke a static method using Class::static_method() instead of Class->static_method() (like any other method). Does the syntax change reflect any technical requirement? I'm asking this because the syntax for every single other language I k...
I'm working on an order system and implementing an audit log. Two main concerns are: 1) While auditing a line item , you should only see audits for the line item 2) While auditing an order, you should see audits pertaining to the header information AND line item. For example, a line item would have an audit trail for w...
I am using the MVC pattern. Lets say I want to create a new object and add it to my database. Where is it better to create the new object: View: Boo boo = new Boo("awesomness"); Controller.AddDB(boo); Controller: public void AddDB(string name) { Boo boo = new Boo(name); addtodb(boo); }
My P2P app needs to locate peers, but I don't want to hard-code a DNS address... One example I've seen is bootstrapping via IRC, but I'd like to do this over HTTP/s if possible. What are my options and techniques for bootstrapping a P2P app?
I'm working with some people are are used to making "associative arrays" in JavaScript like this: var arr = new Array(); arr.prop_1 = "asdf"; or arr['prop 2'] = "1234"; It works just like an object because it is. for...in loops can be used and accessing the properties is fine using a dot or a square brace. the lack ...
I will like to assist my group standardize to a reproducable Java tooling environment that aligns with some good practices to improve on our workflow. We are predominantly a .NET shop that has been doing quite a bit of Java development recently and have been burned too many times with our current Java development proc...
Let me start by saying that my GIT knowledge is fairly shallow, so I'm guessing that there might be something I'm missing. THE SETUP: As an example, we have a project which is being developed as a collection of plug-ins/modules. Some modules, such as contact management, depend on others, such as validation. Each module...
I am a novice JavaScripter and have no real knowledge of what goes on inside the V8 engine. Having said that, I am really enjoying my early forays into the node.js environment but I find that I am constantly using events.EventEmitter() as a means to emit global events so that I can structure my programs to fit a notifi...
I am working on a project and would like to expose some REST services. The technologies used are RestEasy, EJB and JPA/Hibernate. I have structured my app so that there is a clear delimitation between the service layer and model layer. A typical service that retrieves data from the database have a signature like this:...
I was signing up for a website last night, and once again was greeted with the fact that my username cannot contain certain characters (including spaces), and neither could my password. Is there a historic reason for this, or is there no particular reason? Passwords that are phrases have higher entropy and are harder ...
I'm trying to understand if a programming languages design is built on some a theoretical model. I came across few links that was describing Programming Language Theory, Lambda Calculus, Formal Languages and Turing machine. I got lost in all that theory, what I understood from all that is that (any ..?) programming lan...
In a recent project I was asked to implement an events system. An Event had to have a Location which was originally specced out as simply a physical location with some optional extra notes. Then the spec changed (as they have a habit of doing) and we needed to have "online" events too. These would not have a physical a...
Assume I'm using the following code to generate pseudo-random sessionID's: sessionID = SHA-512(GENERATE-GUID()) The GUIDs are pretty deterministic, i.e. I see lots of GUIDs with a lot of the same hexadecimals. My simple question is: How deterministic are my resulting sessionID's? The algorithms for SHA are supposed to...
Consider an application that contains a number of pages with a relatively large amount of javascript present, or a predominantly JS powered application. The script handles a number things, such as: Client side validation Showing/hiding entry sections when appropriate Autocomplete when filling text fields Date pickers...
Background: I'm working on an Adobe AIR app that has many facets. I'm looking for strategies to find memory leaks. Broadly speaking, the EXE contains an embedded JVM, and an AIR Native Extension for Windows (using C). So there are many moving parts. As one example, I'm using MonsterDebugger which traces either the AIR ...
I was trying to design a small C++ geometric API for learning purposes, but came across a problem when dealing with intersections of geometric entities. For example, the intersection of a line and a sphere can have three different types: a couple of points, a point or nothing at all. I found several ways to deal with t...
I am planning a database scheme and I hesitate between two designs, which one should I choose? For the purpose of the question, assume we want to prepare a database scheme for an application managing student information in a university. There is several modules in the application: Registry, dealing with general infor...
When a function has reached the end of its life, we add a @deprecated tag into its doc-comment to notify other developers that they should stop using this function, and then a couple years later it's removed. I was just thinking about an @beta tag to signify this method is brand new and hasn't been tested in a variety ...
I try to follow the Single Responsibility Principle (SRP) and also to omit Code Repetitions. However there are often places where there are code repetitions that are nothing more than code blocks of invocations that are resistant to extracting them into at least meaningfull named method: DoAction1(); DoAction2(); if (...
I was wondering if any design gurus out there could help me understand how large web companies design their services to be highly available. The scenario I'm thinking of is: Client A connects to Service A Client A sends N requests On the N+1 request, Service A blows up Client A reconnects to Service B Service B servic...
We have a requirement to be able to match people with locations based on availability and certain conditions. Let's say I have a group of people each with 3 types of things they may need to park. A car, a truck and a boat. Each person also indicates their preferred parking location (choices 1, 2 and 3). I also have a...
I have read this statement: "A parameter is used as a sort of temporary messenger, carrying data originating from outside the constructor or method and making it available inside it." So, does that mean that values of parameters are stored at first in the constructors and then passed to fields? I still didn't understan...
I need to compare two curves f(x) and g(x). They are in the same x range (say -30 to 30). f(x) may have some sharp peaks or smooth peaks and valleys. g(x) may have the same peaks and valleys. If so I want a measure on how well these features coincide without visual inspection. I have tried to solve this problem in the ...
I want to know what is exactly a method header and what is a method signature and is this the same among programming languages or just in C#? So, is it correct to say the following is a method header: public void SumNumbers(int firstNumber, int secondNumber) and the following is the method signature: public void SumN...
I am currently maintaining a Java web application that is initially designed to work only as a single instance (not in a cluster/farm). Now, the client is planning to upgrade their infrastructure and part of their plan is to place our web application behind a load balancer. I have already identified several serious de...
I would like to understand how a spreadsheet (a group of named or otherwise identified cells containing values or formulas referencing other cells) is solved. I have tried looking at existing projects, but there was so much going on with the GUI, serialization, events, etc. that I couldn't find the spreadsheet. At its...
I'm very new in using GIT as a versioning system and despite a lot of searches, I can't seem to really understand how to handle my scenario. I have this web project that needs to be developed in two versions: the first is a general version used for demos the second is a customized version for my client. As for now, t...
I would like to understand the impact of different resourcing models for software projects. First, I would like to identify the different resourcing approaches that are used to resource software projects. Here are some models that I can think of based in my own experiences: Product centred resourcing Planned resource...
I've written some code to manipulate sparse graphs for school work I'm doing, and I have an operation which requires me to loop over all the edges of a graph. The interface I need to implement is some function int gimme_some_edges(graph* g, int k, int* I, int* J) which puts the next k edges of the graph g into the arr...
I'm a computer engineer and all the courses we have had about programming and computer languages were an introduction to C/Java and OOP. Now I feel like reading Java language specification to learn a deep understanding on Java language but I understand that there are something like grammar description in the specificat...
The Setting I often have trouble determining when and how to use exceptions. Let's consider a simple example: suppose I am scraping a webpage, say "http://www.abevigoda.com/", to determine if Abe Vigoda is still alive. To do this, all we need to do is download the page and look for times that the phrase "Abe Vigoda" ap...
According to WikiPedia "Some languages do not support mixins on the language level, but can easily mimic them by copying methods from one object to another at runtime, thereby "borrowing" the mixin's methods. Note that this is also possible with statically typed languages, but it requires constructing a new object with...
Say I'm defining a directory and then including files from it. Is it better practice to do: define('PATH', 'C:/xampp/htdocs/includes/'); require PATH.'header.php; or: define('PATH', 'C:/xampp/htdocs/includes'); require PATH.'/header.php;
Consider the following case: there are two models Image and User. Users have associated images and they can pick one of them as their profile image. There are essentially two ways of modeling this: 1) User: id - primary key profile_image - nullable foreign key to Image Image: id - primary key user - foreig...
Reading code and discussions pertaining to code, I often see the words "state" and "status" used interchangeably, but the following tendencies seem to exist: When a variable holds a value intended to indicate that something is in a certain state, the name of that variable more often than not contains the word "state",...
Most code samples I see that demonstrate shell code preface each command with $. Having a prefix makes sense, but I'm confused as to why $ is used in particular. Some other symbol, like !, that can be copied and pasted into a prompt without affecting the command's execution makes far more sense to me. So where does thi...
I have been seeing two implementations for syncing data between the server and the client on majority of the apps. This assumes no GCM is set up:- Running an intent service periodically which downloads the data from the network and stores in the database. Implementing a Sync Adapter which runs periodically. Which of ...
I have a DAO method that utilizes Spring for JDBC access. It calculates a seller's success rate of selling an item. Here is the code: public BigDecimal getSellingSuccessRate(long seller_id) { String sql = "SELECT SUM(IF(sold_price IS NOT NULL, 1, 0))/SUM(1) FROM transaction WHERE seller_id = ?"; ...
I've been reading Joel Spolsky's old article about "Top Five (Wrong) Reasons You Don't Have Testers". it's an old article date back to 2000, but it's insightful as most of its content make sense after a decade. I cant agree more about the importance of test in order to produce qualify software. But there is one parag...
I initially started a project with Facades and Polymorphism as a way to create simple extensible design following SOLID Principles. Here is a sample code: public interface IInterface { void FillList(List<InputPocoObject> listOfInputObjects, out List<OutputPocoObject> ListOfOutputObjects); } public class SampleClas...
As the question states: When implementing "SOA", is it a concept intended for communication between systems over a network or is it intended as a concept that operates within the language as a pattern?
One of the greatest piece of documentation I ever read is the TeXbook by Donald Knuth—the manual of the TeX typesetting system, and I used it in my first analysis. As far as I can tell, the type of information conveyed by documentation falls in three categories: recipe, reference and expert knowledge that I describe he...
I have a WCF Service and a Main Lib1. Say, I have a Save Profile Service. WCF gets data (with predefined data contract) from client and pass the same to the Main Class Lib1, generate response and send it back to client. WCF Method : SaveProfile(ProfileDTO profile) Current Version 1.0 ProfileDTO have the following UserN...
I want to use LGPL for my project, can I use some source code which is apache licensed ? If I only use the apache licensed component as library in my project, how should I make the clarification in my project ? Do I need to put some information about apache license at the beginning of source code which uses the library...
I'm kind of new to PHP. I can create basic sites with login/registration, etc., but I always struggle to build complex sites with lots of features, because eventually the code becomes messy and I just run into more and more little bugs, and then fixing those produces another, and so on. I realise that that's partially ...
I have been trying to wrap my head around the finer points of this today. Essentially I have fallen in love with this format for booleans: Class { public static bool myBool {set; get;} private static void Method() { if (!myBool) { myBool = !myBool; // stuff that needs to...
I read an article online which I give the reference to below which compare between Native apps and web apps, in addition to standard website. It seems from that article that native apps are faster than web apps and websites. However, that was not clear for me. Could a native app be built to be used exactly as a web...
I've need an interface that assures me a certain method, including specific signature, is available. So far his is what I have: public interface Mappable<M> { M mapTo(M mappableEntity); } The problem arises when a class should be mappable to multiple other entities. The ideal case would be this (not java): public ...
For the sake of this question, let's agree on this definition of "good commit message" from here: Your comment should be brief and to the point, describing what was changed and possibly why. and accept that referencing a bug/issue in a commit message is a good thing. Now, there are a lot of tools that integrate with ...