instruction
stringlengths
34
19.9k
I am a novice c++ programmer who kept an idea that function pointers are a thing of C and OOP in C++ does not recommend its usage. I know what I write here is vague/broad. But it will be great if somebody could comment whether my idea is completely wrong or something sensible. Thanks.
I'm currently writing a medium sized web-application and find myself asking this question many times. For example, let's say there are users, which have files (one-to-many). How should the UI access the data? One "extreme" would be to let the service layer "only" take care of the lazy loading, i.e. public interface Use...
I am building a new SPA front end to replace an existing enterprise's legacy hodgepodge of systems that are outdated and in need of updating. I am new to angular, and wanted to see if the community could give me some perspective. I'll state my problem, and then ask my question. I have to generate several series of chec...
I have a project written using Swing, and I want to make it more smoothly (like JavaFX is) by adding animation to some components(JButton, JScrollPane, JSplitPane) using javax.swing.Timer. UPD: That is not a game. I want to use the Timer for short animations like mouseHover events or dropdown, or scroll. But the probl...
AS3's got some awkward rules about variable scope, due to its use of hoisting. I don't like pointlessly leaving a bunch of compiler warnings lying around, but it's more important to me for my code to readable and properly written, regardless. This produces a couple of duplicate variable definition warnings: priva...
I'm pretty new to programming, and I've just started using GitHub to store and hold my source code (I keep losing stuff stored locally). As it stands all that's in there right now are source code files, nothing more, but I expect that to change as time goes on and I get better at this. Given that all the repositories i...
I'm wondering what the best practice is for my git repository structure where I have an Android application + a web service backend. In general, I'd like to release these two independently (e.g., perf fixes to the backend with no changes to the front-end), but I am worried that if I keep these in two separate repos I'l...
Currently I'm working on system that works with database, and I would like to have it done elegant way. So I have abstracted DBConnection into one class, DBCommands into another class. (DBCommands : DBConnection) There is also a class SQLUsage in which I'm creating new thread that works in a loop, it checks all the tim...
I have developed a small scripting language and I've just started writing the very first native library bindings. This is practically the first time I'm writing a native extension to a script language, so I've run into a conceptual issue. I'd like to write glue code for popular libraries so that they can be used from t...
When converting a string to a boolean, what are the advantages of having a programming language evaluate an empty string as true and what are the advantages of having it evaluate it to false?
I have a PHP script example1.php. How would the control flow be when I call another PHP script example2.php from example1.php? For e.g.: example1.php looks like this .... ... .... example2.php (calling example2.php from example1.php) ..... ..... How does the control flow work for this? Does example1.php wait un...
I had an interesting discussion with my boss today regarding exiting a loop before the terminal condition is met. He had a construct in some of his VB6 code that looked something like this: Dim Termination As Int Termination = 10 For Iterator1 = 1 To Termination If Iterator1 = 5 Then Iterator1 = Terminatio...
We are starting to build a new app and I would like to explore the idea of doing a thick JS client (backbone / angular) with only RESTful API exposed by our application layer. What are some of the best practices and potential pitfalls for doing this kind of web app?
It bothers me to see commented out code and it seems often-times a symptom of developers not being proficient in advanced source control features, but on the other hand source control does not really go all the way in solving the problem that commenting out is intended for. I've occasionally seen requirements flip-flo...
I wrote a cross platform application and I distributed it successfully for Windows and Linux (and tested them on "clean" virtual systems, with no other additional software and/or libraries installed). I have already compiled my application on my Mac computer, but I don't know if my application will work on other Mac co...
So I'm reading a book on Design Patterns (Design Patterns Explained 2nd Edition), and all throughout the book it says to "favor aggregation over inheritance". I'm trying to wrap my head around trying to design something, and I feel so stupid. So conceptually, I have Recruiters. I figured these recruiters can be an abst...
This has been troubling me for some time, and I'd really appreciate the input of other professionals. Short background: I started programming when my parents bought me my first computer in 1988 (at age 14, I'm 39 now). I followed a couple of other career paths before finally becoming a professional programmer in 1997. ...
I think this code: if(file_exists("amodule.inc.php")) require_once("amodule.inc.php"); is misleading because of the use of the require_once. I think that - to keep the logic and "wording" in line - "include_once" would be appropriate (where there are a number of arguments to not use the "if" at all but I would ...
I have .NET 2.5 installed in my computer unit, as a beginner I used VB.net As I went along I've also installed new .dlls that would help me with my VB.net programming Now, I want to study java as well, leading to Android programming. If I install the JDK 7.0, can I still be able to program in VB.net? Will installing JD...
An interviewer asked me this question: Tables are created with appropriate normalization rules, However the database is performing slow. [Ie.: The select, insert statements are taking time to do his operation.] What are areas we need to look to improve the database performance. Obviously this is a vague question. Wha...
I cant find plugins written in other languages other than javascript. There is browser support only for Javascript. Why didn't they use other scripting languages other than Javascript when people started using scripts on their web pages? Why javascript was given priority?
I have written an Android application. The application requires a Bluetooth connection to a very specific piece of hardware, currently a prototype. The only way I can test the app at present is to drive hundreds of miles to see if it works. If I end up with an ANR it can be very embarrassing in front of my client. The ...
I am working against an API where I can add and update items in a list that is ordered by a priority field I can set (which need not be contiguous but must be a positive integer). Updating a list member is an expensive operation, so I want to minimise the number of updates. What I want is an algorithm that will minimis...
To someone who knows database internals this may be an easy question, but can someone explain in a clear way why storing large blobs (say 400 MB movies) in the database is supposed to decrease performance and what exactly does that mean? This is a claim often found throughout the internet, but I've never seen it really...
I have a few FOSS projects that I want to release under the BSD license, since I only wish to maintain the intellectual property of the code, that others will know I've been writing it. I suppose all I need to do is: Have a file called LICENSE only in the main folder of the software. Write at the top of each source fi...
I work on a team that does frequent code reviews. But it seems like more of a formality than anything. No one really points out problems in the code for fear of offending other developers. The few times I've tried to ask for changes were met with very defensive and reluctant attitudes. This is of course not good. Not o...
For example a new research paper comes out and it describes some algorithm, say this is a cutting edge algorithm and came out last week, is there anything stopping me from using that algorithm in my codebase that is for commercial purposes? What if the paper includes some code and I use that code? There does not seem t...
This question relates to software-licensing. Someone familiar with open-source licensing may be able to answer this question. I am facing an issue in trying to interpret/understand some Licenses, due to a language barrier (English is not my first language). My situation is that I am using three products inside a distri...
I have a database containing just simple URLs. It is as simple as it sounds for now and URL can link to a website or a document(i.e. anything parseable to text). Now I have a simple code which inserts records to database. The problem is that website/document may be actually the same, just: Hosted somewhere else Not av...
I have a function, which looks something like this: ClassA& ClassB::Check(int x){ //some calculations in a loop, if a condition is met, a reference to a ClassA object is given } I'm getting the "control reaches end of non-void function" error. As far as I understand, this is because, the function wont always retur...
I'm developing a small system with two components: one polls data from an internet resource and translates it into sql data to persist it locally; the second one reads that sql data from the local instance and serves it via json and a restful api. I was originally planning to persist the data with postgresql, but beca...
I believe I have a fundamental misunderstanding when it comes to workflow engines which I would appreciate if you could help me sort out. I'm not sure if my misunderstanding is specific to the workflow engine I'm using, or if it's a general misunderstanding. I happen to use Windows Workflow Foundation (WWF). TLDR-versi...
Is it accurate to say that dependency injection manually using java (without spring) is nothing but implementing the strategy pattern (as per this example)? Furthermore, is it correct to say that Spring just provides a declarative way of specifying the dependency as opposed to manual method whereby the dependency need ...
I'm looking for an algorithm to infer a hierarchy from a set of tagged items. E.g. if the following items have the tags: 1 a 2 a,b 3 a,c 4 a,c,e 5 a,b 6 a,c 7 d 8 d,f Then I can construct an undirected graph (or graphs) by tallying the node weights and edge weights: node weights edge weights a 6 a-b 2 b...
I'm starting to develop a new program. It's basically a database interface, run a few queries, show the data in a nice way and be able to easy input new data (like this website). Thinking about which programs I use daily I realise that only my web-browser is a GUI program, the rest is TUI (in this case TUI is Text User...
I have a custom MVC framework that is in a constant state of evolution. There's a long standing debate with a co-worker how the routing should work. Considering the following directory structure: /core/Router.php /mvc/Controllers/{Public controllers} /mvc/Controllers/Private/{Controllers requiring valid user} /mvc/Cont...
We will be starting a new project this month. The project will be 1 year and production deployment will only occur towards the end of the project. We will be doing iterative development (1 month per iteration), so this means we will drop features to Test environment at the end of each iteration for QA testing. Our bran...
I have been preparing to do my first technical interview in a month, and I have a question about implementing common data structures like stacks or linked lists. I plan to do the interview in either Python or Java but I am not sure which one to use yet. I was practicing and tried to implement a stack in Python, using a...
On http://python.org there are two download pages, http://python.org/download/ for international users and http://python.org/getit/ for Chinese users. When accessed from a country other than china, the second link redirects to the normal download page. Why is that so?
When looking Python decorators someone made the statement, that they are as powerful as Lisp macros (particularly Clojure). Looking at the examples given in PEP 318 it looks to me as if they are just a fancy way of using plain old higher-order functions in Lisp: def attrs(**kwds): def decorate(f): for k in ...
My repository has a branch production and is filled with countless tags of the format production-20130101-1234 that point to what has been actually shipped on the given datetime. I think this solution is somewhat messy and unwieldy and I wonder if reflogs would skip in here better. The objective is "make sure you can a...
I’m trying to develop an AI for a card game and I’m a bit stuck about the technique/algorithm I should use. Here are a few assumptions about the game: After the cards are distributed to players, there is no randomness. I mean here that every player can choose which cards he plays but no random process occurs as when d...
Is it sensible to have micro-modules, say with only a very few (perhaps one) class in it? Or should I store things in bigger repositories? I am long-time Java developer with a software-engineering background. I try and write well encapsulated, focussed OO code. I have previously written code in large modules/projects/r...
I'm designing a language conceptually similar to Go. In Go, for example, the keyword func is used for defining functions: func abs (a int) uint { ... } Same for defining types. However, I was thinking of a grammar that doesn't consider these keywords. For example: abs (a int => uint) { ... } Or, for structures: Tree ...
I have a requirement to allow users to suggest updates to their profiles on a site I'm working. They would be able to view their profile details, then click on and "edit" button, which would basically make a copy of all their data contained in a handful of one-to-many related DB tables. They can then add or remove item...
I'm really confused when I see a lot of in-memory database implementation used for testing, because I also heard a lot from integration testing best practices that the environment running the test should resemble as closely as possible the production environment, including operating system, library, database engine, et...
I work for a software product company. We have large enterprise customers who implement our product and we provide support to them. For example, if there is a defect, we provide patches, etc. In other words, It is a fairly typical setup. Recently, a ticket was issued and assigned to me regarding an exception found by a...
For learning and understanding purpose, I currently want to try to make a small relational DBMS with simple features like (for now) only sequential reading/writing and CREATE TABLE, INSERT, SELECT, UPDATE and DELETE management. I am currently on the "think" part of the project and I am stuck on the way to store the rea...
I have an android application with a custom content provider set up to load data asychonously. The database is a local file so I'm not sure if I needed to set up a content provider at all. Sometimes I just need to do something like get a name back from a short list by id. Is it ok to mix the content provider pattern wi...
I've written some code that has some fairly deep nests (one time, I wrote something that was a conditional check inside a forloop inside a conditional check inside a forloop inside a forloop). Is there a general guideline on limits to the number of nested for loops/conditionals you have?
For the non-Brits in the audience, there's a segment of a daytime game-show where contestants have a set of 6 numbers and a randomly generated target number. They have to reach the target number using any (but not necessarily all) of the 6 numbers using only arithmetic operators. All calculations must result in positiv...
Suppose I'm writing a program in C in which several parameters are asked at the beginning of the execution to the user and then remain costant until the end. Now, I need to pass these parameters to some function. Since they are unchanged through the program, my temptation would be to declare them as global variables, ...
I am an author of project, that consists of two parts: daemon and library. I want to license library under BSD License (or MIT, will decide later), and daemon under GPLv3. I want to permit the library to be linked into closed-source products, but I want daemon to be GPL, as it uses GPL code heavily, and I do not want i...
I program primarily in python and have programmed a couple of GUI's with Tkinter, every tutorial I have ever seen has recommended defining and using a class for the GUI, but my GUI runs flawlessly using only procedures, without a class. Why use a class? It seems from my perspective to simply be an extra layer of comple...
Part of a system I am working on manages some securities information (stocks, bonds, etc...) and business rules specify certain fields be displayed only in all CAPS (stock symbols and CUSIPs for example). Users will have to look at data displayed on the screen as well as perform create/edit data-entry operations. Where...
I've only recently begun to learn about the tensions between free and proprietary software, and I've been very confused by the way that free software can make money. I understand that free software is "free as in speech, not as in beer," but if I release an open source program and then try to monetize it, what could po...
We are planning to develop a ASP.NET Web API project starting soon. For source control we use svn. We typically follow the pattern of the trunk being stable and doing all of our work in the branches. Most of the time we are lucky that one developer is working on the project. For this Web API project there are at l...
I'm developing a product related to printing. To work it properly in all windows versions I need to include few exe (lpr.exe) files from system32 folder. So I need to know it is legal to distribute these exe file with my product.
In a team that I used to work for, there was a policy that if you introduced a memory or other resource leak, you got a 'dummy of shame' hung on your door until you found the next resource leak. While it was effective at finding resource leaks, I felt like it placed more emphasis on blaming others rather than working t...
I am an intermediate programmer with a few years of professional experience who is halfway through a masters degree. In learning to program I've often heard two pieces of seemingly contradictory advice. The first piece of advice was get something working quickly, see how it works (either through prototyping or informa...
I am currently working for a small-medium sized company (~50 employees) as the sole IT staff. Recently, we are on track to replace one expensive yet critical legacy system in favor of an application I am currently working on during my free time at work. However, its been very busy lately with issues spawning left and r...
Do long (very long) variable names slow down the compilation of source code? I'm aware that the length of variables has 0% impact on interpretation as the compiler changes them to machine code which is always the same length. But my question is, does the speed at which the compiler vary depending on the length of varia...
Should a developer close a ticket in a bug tracking tool? Or should only the scrum master or testers should do it? What are the best practices?
How do the blogging sites, Q&A sites (or any other sites host prose like content) store their data? That is, how do you store blogs and Q&A content in the database? I hope it is not good to store this huge text data inside RDBMS table columns.
I'm writing a RESTful service (Java EE, Jersey) and a client application that communicates with it, and I wish to secure it and store any usernames & passwords dedicated in my own database. I do not want the client to store the username and password locally, not in any form such as base-64 or other encoding at all, I r...
A client recently had a new backend .net stock management system developed that hooks into their EPOS and allows their stores to keep track of orders, products, customers, etc from a single central database that utilizes MS SQL Server 2003. The client hopes to use this as an opportunity to renew/re-develop their site t...
I have an ASP.NET MVC 4 solution that I'm putting together, leveraging IoC and the repository pattern using Entity Framework 5. I have a new requirement to be able to pull data from a second database (from another internal application) which I don't have control over. There is no API available unfortunately for the sec...
Once I heard that a good book on any programming language cannot be short, so the number of pages is the first criterium when choosing a tutorial. The statement was half a joke, but it has some truth in it. There are tens and hundreds of books available for most popular programming languages, frameworks and technologie...
I have read recently that it is not good practice to use the repository pattern in conjunction with an ORM. From my understanding this is because the abstraction they provide over the SQL database is too leaky to be contained by the pattern. I have a couple of questions about this: What do you do if you want to switch...
We have a bunch of data (several TB) in Hadoop HDFS and it's growing. We want to create a dashboard that reports on the contents in there e.g counts of different types of objects, trends over time etc. Our first thought was to use something like Oracle Tableau or d3.js and to use Hive queries. But Hive is just too darn...
I own a repository on GitHub to which someone sent a pull request with one single commit. I only want to implement his solution partially, and use about half of the code changes the user made. What should I do in this situation? Make a branch of his version, then go back and copy and paste the "old" code that I want to...
For the last year or so, I have been working on a very large application. I am currently on version 17 of it, and every time, I start over with some of the code from before. But now, this is starting to become unmanageabley large. When I do the design for the application, I generally start with a Word document, outlini...
Where I work, we're in the process of automating a lot of tasks that currently need to be run manually by an IT person to determine if the next task can be performed (the second task depends on certain outcomes of the first task). We're ending the first phase of our script automation process, having reworked the first ...
I'm new to this type of programming, but proficient in web development... looking to expand my palette a little. I have this file. In Windows 7 the file properties window claims its a 'system file', my assumption is that this is a generic description and isn't particularly useful, no file extention. This file resides o...
I currently have my font stack: font-family: "Courier New", Courier, monospace; In all browsers that I test in I see the font displayed in the Courier New font except for my android devices - my nexus and my kindle. And although they have a monospace fallback I would rather have my site displayed the same across these...
I've worked in a team that developed and gave support for SW practices tools. Those tools were written (and will be written) in many programming languages. According to Scrum, a given story, can be implemented by several team members (according to what I know). When organized in a team that is oriented to a specific SW...
I often hear that a real programmer can easily learn any language within a week. Languages are just tools for getting things done, I'm told. Programming is the ultimate skill that must be learned and mastered. How can I make sure that I'm actually learning how to program rather than simply learning the details of a lan...
This intro is only my naive attempt at a mile-high snapshot helping me to position my question. Any user trying to answer my question, that tries to nail down one aspect of programming, will have to overcome my naive understanding, simply because of my idiosyncratic education. So here I'm placing my subject in the arra...
I'm a planetary science researcher and one project I'm working on is N-body simulations of Saturn's rings. The goal of this particular study is to watch as particles clump together under their own self-gravity and measure the aggregate mass of the clumps versus the mean velocity of all particles in the cell. We're tr...
Creating a C++ library also means documenting it so that others can use it, and that documentation can vary dramatically in quality. How should a website for a C++ library be structured so that it is most effective? I would frame "most effective" as being divided among three specific groups of library stakeholders, wh...
I have a big pdf with the documentation for a project and I need to render this to doxygen (so take each function from the pdf and write it out into doxygen). Any suggestions on how to do this quickly and effectively (other than doing it by hand)?
A coworker and I were trying to brainstorm and list the different ways an application developer can write a program enabling a user on one computer to run remotely on another computer while being displayed on their own computer. She suggested all possibilities would fall into only three categories: remote desktop soft...
This week I could optimize using a reduced C library that allowed a drastic shrinkage in code size - from about 60 K to about 6 K and then we could load the code in the 8 K on-chip memory of an FPGA (Altera DE2) which I suppose is SRAM so there is SRAM both on-chip and off-chip(?) The program was rather small itself a...
i wanted to know what is the meaning of return False in an function. go Through this function: function reset_password($password,$user_id) { $sql="UPDATE user SET password='$password' WHERE user_id='$user_id'"; if(!mysql_query($sql,$this->mycon)) { array_push($this->err_msg,"Error in Inserting - "....
We are new to using cucumber with selenium to write automated test suites. Our initial approach was to have one java class per feature file. Now we added instance methods in each class for corresponding step definitions. Now if we need to re-use a step definition in some other feature file we are facing problems as we ...
After spending over one year working on a social network project for me using WordPress and BuddyPress, my programmer has disappeared, even though he got paid every single week, for the whole period. Yes, he's not dead as I used an email tracker to confirm and see he opens my emails, but he doesn't respond. It seems he...
I'm struggling with a task as I was given to practice UML and use cases. The problem is that I should model computer version of a board game so I am unsure about a few things. obviously it does not matter if you play against the PC or another player, the actions are the same. The game is simply like tic tac toe. E.g. ...
When I fix a bug I mention briefly what was the issue and in which revision its fixed. But this way nobody would know how much tricky the issue was and how much effort went in analysis and findings. What is the best practice for a developer to show such things to higher management to get noticed?
There are two types of documentation. One type, the Implementation Documentation, contains information about specific implementation of a construct (eg. Class, Method, etc.). It is targeted to the future me, maintainer, debugger and so on. And there is Usage Documentation, containing information how to use a provided a...
I'm trying to test a class which calls some Hadoop web services. The code is pretty much of the form: method() { ...use Jersey client to create WebResource... ...make request... ...do something with response... } e.g. there is a create directory method, a create folder method etc. Given that the code is de...
I have a TableSqlBuilder interface which has a method getCreateTableSql. This interface is used in some other class as follows: function createTable( $tableDefinition ) { $sql = $this->tableSqlBuilder->getCreateTableSql( $tableDefinition ); $this->db->execute( $sql ); } The TableSqlBuilder interface has multip...
There is the ongoing argument of free trial versus a freemium model (that is, a free-for-life version of their software with restricted and/or stripped down features) for allowing potential customers and users to test run their product. Upon my research, I can conclude that the free trial is the way to go on both for t...
In Java, by convention getter and setter for boolean fields will be isField() and setField(). This works perfectly fine with field names that are adjectives like active, visible, closed, etc. But how do I name a field that has meaning of a verb, like haveChildren? Add “_ing” to the verb (havingChildren), maybe? To clar...
I have been writing my website, front-end: html, JS, jquery and css, back-end: php mysql. However my php files only contain php and mysql code. Is this a really bad thing? In what situation should PHP files contain html/javascript?? Currently my php files are just there to receive request and response with array of inf...
I faced this question in one interview. I explained that String is immutable and StringBuffer is mutable class. I don't know very much about mutable and immutable and also don't know the exact answer. What are the key concepts to be able to distinguish the two ideas? Is there a performance impact when chosing one over...
A few years ago, I worked for a small company that went so far into developing in-house frameworks that they dedicated their most senior developer, and their architect to developing a custom MVC framework and ORM from scratch. These two things were orthogonal to their core product. Unfortunately the support for this fr...
Say you have a few applications which deal with a few different Core Domains. The examples are made up and it's hard to put a real example with meaningful data together (concisely). In Domain Driven Design (DDD) when you start looking at Bounded Contexts and Domains/Sub Domains, it says that a Bounded Context is a "pha...
I don't have much knowledge of the subject but as I know, when servers receive an email they have two sources of data to classify it as SPAM or not. The contents of the message (subject + body) and the metadata that goes with it (from who / to who / server that sent the message, etc). I know you can do basic filtering ...
This is kind of a vague question so I apologize in advance. When software is "smarter", I tend to interpret that as really just saying that it covers more edge cases. First of all, is this correct? Assuming it is, does this mean that the software is full of if/switch statements to make sure input is handled properly, ...
I just want feedback on what one considers 'most elegant design' for a situation like this. I have an object that is immutable with some (sort of) copy constructors to allow creating a similar but modified version of my immutable object. So something like this: class ImmutableObject{ Fee fee; Fi fi; Fo fo; ...