instruction
stringlengths
34
19.9k
What is a good way to define "state", as in state variable or state machine, to a new (previously non) programmer? What are some good ways to explain why this concept is useful for writing software? Is the concept of state explicitly taught in beginning programming courses or books commonly?
I think one of the best ways to learn and become a better programmer is to share knowledge gained from working on personal or work projects with others. One way to do this at the workplace is to set aside an hour or so a week and let one or several team members present their progress on the part of the code base they h...
OK, I am creating a game using JavaScript and HTML5. The variables such as map, x, y, level, exp, etc are stored in JavaScript to keep track. On my client page, the JavaScript variables are stored to play along with the game. Every 5 seconds, the client page sends a POST AJAX call to the MySQL database and it successfu...
I've been thinking about the subject and I've always wondered, from where do they obtain the data that is analized in applications, I've looked at Nasdaq's website and they do not seem to have any sort of APIs, do the firms parse yahoo's finance section, or are there special contracts, agreements in places with the dif...
On my machine while developing I'm using icons from other application (in particular MS Paint and Paint.NET) as sign for the user that if he chooses to open that file (with our own internal command) it would open in those applications. Is it legal to extract the icons from those applications and use them? Commit them t...
We have an intranet site which was done in .net with plenty of functionality but management wants it to look more visually attractive and get the graphic designer involved. The graphic designer is NOT a programmer nor has any desire to learn how to code. She would be updating the main page only. I was trying to figur...
I have 2 apps. They both have accounts, and each account has users. These apps are going to share the same users and accounts and they will always be in sync. I want to be able to login automatically from one app to the other. So my solution is to generate a login_key, for example: 2sa7439e-a570-ac21-a2ao-z1qia9ca6g2...
In a project where I'm working on the data access layer I'm trying to make a decision how to send data and objects to the next layer (and programmer). Is it better to tell him to reference my dll, OR should I build a generic handler and let him take the objects from there (i.e. json format) If I understand correctly...
On EF4 actions on entities are actually done via the Business Element layer (BE). Why do I need the Data Access (DAL) on another layer?
On my new team that I manage, the majority of our code is platform, TCP socket, and http networking code. All C++. Most of it originated from other developers that have left the team. The current developers on the team are very smart, but mostly junior in terms of experience. Our biggest problem: multi-threaded concur...
I don't know if this question is strictly related to software development, but still I'll give it a try: Like a lot of programmers, I love to work on hobby projects. Sometimes, seemingly good ideas turn out to be not so good, so I drop the project. But sometimes, something useful comes out of the project. So, I could r...
When using method chaining like: var car = new Car().OfBrand(Brand.Ford).OfModel(12345).PaintedIn(Color.Silver).Create(); there may be two approaches: Reuse the same object, like this: public Car PaintedIn(Color color) { this.Color = color; return this; } Create a new object of type Car at every step, like t...
I have recently finished an undergraduate course in computer science and I am looking for a job. During the search I encountered several interesting (and tough) problems that needed clever algorithms to solve. I also use google code jam as a practice set. I cannot understand how those solutions translate in solving rea...
For a long time now I've been in the habit of checking whether a collection (array, dictionary, whatever) is non-empty with a nonequality. Like this: if ( MyArray.Length < 1 ) { // Do something if the array is empty } Sometimes I do this for strings too, and other kinds of collections. In practice, this should be ...
I would like to know the idea behind the working of 'docking' in applications. I have worked with applications where components from individual forms are docked on a single main form to provide the necessary GUI. But I don't have any idea whats happening in the background. According to Wikipedia A dock is a graphical u...
I am a noob to sentiment analysis and found a good resource for Bayesian Opinion Mining and a way to make it self improving. I was wondering though, if the optimum analysis is dependent upon the supplied data set and since self improvement would mean adding known patterns to the data set (my understanding), wouldn't th...
I am designing the a web application using Domain-Driven Design. I have following scenario: Each Application Group can have one Application and each Application can have multiple Configurations. I am trying figuring out which one will be aggregate object... Which one will be aggregate roots and why?
I am learning objective-C after having good knowledge of C/C++. I have 2 questions: Are Obj-C message passing and C++ vtable, two different ways of implementing polymorphism or Are they two very different concepts which I have misinterpreted into different implementations of same concept? I read following line from th...
I am working on a personal side project that will utilize a complex and large relational database. During the design of the database I had some co-workers give advice to how I should approach my application; they advised to use the entity framework. From what I've read and what I am watching it sounds like the entity f...
Im currently evaluating a front-end architecture for a big app that will be developed by a team of about 6 developers + 1 web designer so that said, having a robust SVN friendly architecture is a must. So far I'm evaluating this two options: A mixture of JQuery/UI/Mobile + Backbone/Underscore + Require JS + Twitter-Bo...
I'm very curious about this: Lets say that you have to use the GPL in your library because some dependency uses it or (if your library is fork) the upstream library uses GPL. Now GPL doesn't play well with a couple of important open source licenses which means that some users simply can't use your librar because of lic...
This post is a follow up to this question: PHP Atomic Memcache on StackOverflow. Considering I am using Memcache (no d at the end) on PHP 5.3.10, I implemented a custom locking system where a client will wait until a lock key is destroyed before it begins to modify a key on memcache. So: Client 1 connects, checks for ...
I'm about to undertake a project. This requires me to write code, and tons of it. The client's requirement is to hand in all source code at the end of the project. My question is: How do I quantify the price for source code and the software product? Is there any metric that one follows to determine pricing? How would ...
I study in software engineering and this year a new association at my university is opening a robotic submarine club. It's a new club and they needed software guys for micro-controllers manipulation, gui output and other software oriented requirements. I've been accepted to the club and there is nothing established rig...
I need a proper explaination of Jamie Zawinski's Law of Software Envelopment: Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.
I've been looking around for an algorithm that would optimize the distance between 2 list of coordinates and choose which coordinate should go together. Say I have List 1: 205|200 220|210 200|220 200|180 List 2: 210|200 207|190 230|200 234|190 Calculated Distance between Coords: 205|200 to 210|200 == 5.00 205|200 to ...
Say I've got a third-party service called Cool.io that provides a RESTful API but often goes down. My applications consume that API, but when Cool.io goes down, my app really can't do much... but it should! Say I create a proxy to the Cool.io and this proxy stores a copy of Cool.io's data and provides RESTful endpoints...
I am creating a website, where users can upload their own videos. So far I am just building the main structure with HTML and CSS. Is it a better practice to write server-side code before the site layout is finished? Does it not make a difference?
During an interview I was asked to implement a random generator in java without using any existing random number libraries that takes as an argument int n, and returns a random number between 0 and n. This was the implementation I provided: public static int random(int n) { int r = 0; for (int i =0; i <n;i++) {...
Edit: Given the recent downvoting (+8/-6 at this point) it was made clear to me that Gartner's lifecycle is a biased metric from a programmer's perspective. This is something that is part of a paper I'm going to present to management, and management types are part of Gartner's audience. Giving DVCS exposure & enthusia...
I was wondering why C++ is a good choice to write a compiler. Of course C is good for this purpose too, because many compilers are written either in C or C++ but I am more interested in C++ this time. Any good reasons ? I was looking for that in the Internet, but I cannot find any good reasons.
I did a lot of self-study coding, got some experience with Parallel Programming Models: Actors, Software Transactional Memory, Data Flow. When I am trying to apply these architectures to real life - into high load web application - any model doesn't support durability and persistence for data. Real life tasks requires ...
When I read the book Effective Java chapter 4, I met some sentences but I can't think them out : What is the implementation when designing a class , why subclass will rely on the implementation detail of superclass? Why will inheritance break encapsulation?
As far as I know, a Turing Machine is the widely used model in computational theory to know whether something could be computed and if computed can they can be computed in finite time (P, NP, NPSpace). But I have the following doubts: Is a Turing Machine essentially a black-box model where a set of inputs give a set o...
Here's what I'm doing: I am reading a file in BLL, which is sitting in the UI layer. Currently the application is using HttpContext.Current.Request.PhysicalApplicationPath to find the absolute path written in BLL. I feel this is not a good design and I am thinking that I should pass this information in some kind of str...
Let's assume, for a second, that you're "the boss", or architect, or whatever position would permit you the authority to decide on the following question: You work on a product that's existed for a number of years and it's developed entirely in an imperative style/language. Let's also say that there is a feature or sub...
I have a logic intensive algorithm that I need to code in two languages (actually I finished it in one language satisfactorily and am about to start coding in the other language). By logic intensive I mean the algorithm is non trivial, needs careful understanding and, importantly, could be having bugs (due to complexi...
I've been checking out Berkeley DB and was impressed to find that it supported a SQL interface that is "nearly identical" to SQLite. http://docs.oracle.com/cd/E17076_02/html/bdb-sql/dbsqlbasics.html#identicalusage I'm very curious, at a high-level, how this kind of interface might have been architected. For instance: ...
I'd like to reach out to the community on this one. As a software developer, I'm not an expert salesperson or marketing guru - I think in code and not much else. Most developers I come across are like this and also tend to be serious penny-pinchers. Let's say, as a developer, I recently released a new software produc...
I want to create my own Dropbox clone (for learning purposes - only the Windows app) and am looking for some tips. Currently, I use the FileSystemWatcher to check if there's a change, then use rsync to sync all the data. Now, how does this work with multiple computers? If computer A changes a file, it should be pushed ...
Just came across this post on reddit, where someone was charged $1,223 for a "FREE STEAK SALAD". I was trying to figure out 'Why 1223?' thinking that this might be a programming error somewhere. But 1223 seems to be pretty much an ordinary number (= 100110001112). Any ideas?
I'm just learning about use-case analysis and use-case diagrams and am a little confused whether or not the MySQL database of a web app should be considered an actor. Is the databased considered outside of "the system" or my application, because it is its own server, most probably on another physical machine? On the o...
In an ideal world: In an excellent article Don't Call Yourself A Programmer, And Other Career Advice, Patrick McKenzie explains, among other things, that language doesn't matter: A developer is a person who solves problems, in general. A developer is not a person who writes code in a specific language. Businesses don'...
I am just beginning to learn Functional programming (FP). I come from a OOP world, where everything are objects, and most of them are mutable. I have a hard time wrapping around the concept that functions don't have side effects. If something is not mutable, how are common things objects like Employee or Person repres...
I'm part of a small team of four, and I'm the unofficial team lead (I'm lead in all but title, basically). We've largely been a "cowboy" environment, with no architecture or structure and everyone doing their own thing. Previously, our production deployments would be every few months without being on a set schedule, ...
I need to find a way or an algorithm that groups members of a given data set (of positive integers) so that the difference between group means is minimized (not maximized, as usual). There are two constraints: The number of groups should not exceed log(N) base 2. N is the input array size. Let us assume that N = 16, ...
I am relatively new to Visual Studio Development and I was wondering - it seems that everytime I make changes to my JS or CSS in my project - I have to "build" the project again. Is there any way to simply refresh the browser as opposed to building everytime ? My understanding is that all the files are copied to some t...
Microsoft released Silverlight 5 but there has been no news of any future versions (except service releases) being released. Combined with the increasing visibility of HTML5 and modern JavaScript libraries it now makes a lot of sense to start adopting the new and emerging technology instead of relying on Silverlight wh...
I ask because I've seen a couple of OO PHP tutorials which do not adhere to this, but to me it just makes sense. It makes it easy to instantly see if a file is a class or not, if non-class files all use lowercase names.
Say I have a function that creates a list of objects. If I want to return an iterator, I'll have to return iter(a_list). Should I do this, or just return the list as it is? My motivation for returning an iterator is that this would keep the interface smaller -- what kind of container I create to collect the objects is ...
When starting a new software project that will be used on several platforms, how do you determine the best way to start development? Do you develop for one platform and then port to the next? Do you try to develop all platforms simultaneously? For example, I'm going to start developing a Windows Phone app in C#. Much o...
Possible Duplicate: How much documentation is enough? Do you know how the big IT company like IBM, Microsoft, or google make sure their application source code has proper documentation for future new programmers? What are their methods or tecniques? Do they tell the programmers to write documentation or hire a speci...
I am working on a project in which we have to implement and unit test some new module. I had a quite clear architecture in mind so I quickly wrote down the main classes and methods and then we started writing unit tests. While writing the tests we had to make quite a few modifications to the original code, such as Mak...
Abstract (tl;dr) Please read the full question, this is awfully simplified: How can unix file permission style restrictions be applied to inter-type data/control flows, allowing fine-grained access to some class-members for some groups of classes? Background information If you think about unix file systems and permissi...
Is there a way I can make the license I use for an open-source software package be valid for all contents of the package without having to write it into every single file? I often saw a LICENSE file, but does this file (with the license in it) makes all contents of the package (i.e. the current directory and all sub-di...
I'm going to work on some project that would do a user-action recognition based on what he/she does in the system. As far as I understand there are two main parts here: Intercept the user actions (say http traffic in web/ui interaction in thick-client) analysis of user intentions. While the first part is rather technic...
I've heard a few times that every extra [number1] milliseconds it takes to process a web request and return a response will lose you [number2] percent of users. Is this just "conventional wisdom," or have there been actual studies on the subject? And has there been found to be a lower bound to this phenomenon, like "...
For about 10 years I've worked on various in-house desktop client applications with SQL Server data stores. Rarely did I start these projects - most are takeover work. One thing that seemed constant everywhere was that there was a single global SQL Server user account that this application used that granted it permiss...
I don't understand what is passed to the function f() when I call it like this. main() { void f(int,int); int i=10; f(i,i++); } void f(int i,int j) { printf("%d %d",i,j); } gives me 11 10 .Can somebody explain why its 11?
Im working on a Java Software and there is a need to use some extern libraries. I found two relevant libs. The one is on an AGPL and the other on the MIT License. Now Im asking my self, can I use these libs if: I would make a non-opensource-nonfree-software or I would make a non-opensource-free-software I dont real...
I have two different tables in two separate databases with around 1.5 million records each. (BTW: im working on oracle databases) The objective is to check if every record present in table A is also present in table B. Since the tables exist in different databases, I think I cannot calculate the "difference" between ...
I'm writing a web app and am wondering about future upgrades and how upgrading the webapp will affect the user experience. In particular, I was wondering how a company like Google approaches this problem. For example, I have seen several examples where a particular google app will ask the user if they want to upgrade t...
A Client has a huge Windows Application running on a Database. This client wants you to develop an "Express" version of this application, including only, let's say, 20% of its features. This Express version must be a Web Application, opened on the WWW. You have 2 choices: Use the same Database to develop the web appli...
Note more discussion at http://news.ycombinator.com/item?id=4037794 I have a relatively simple development task, but every time I try to attack it, I end up spiraling in deep thoughts - how could it extending the future, what are the 2nd generation clients going to need, how does it affect "non functional" aspects (e....
Can we use the word "object" for data / functions in e.g. C (or Pascal) which doesn't really have objects? In C, what is an object? A data structure? A named memory area? I spoke to my collegue about "objects" in C and he said that there weren't any but in the text I study about C the word object is used as a generaliz...
WinRT: is it really about calling WIN32 (wrapped in COM (exposed as .NET)) via a proprietary extension of C++? That looks like a lot of wrappers and layers between the developer and the actual functionality. Does anyone trying to go with it stand a chance at profoundly understanding the ecosystem (if his last name is...
I find that some software developers are very adept at this, and often times are praised for their ability to deliver a working concept with abstract requirements. Frankly, this drives me crazy, and I don't like "making it up" as I go. I used to think this was problematic, but I've started to sense a shift, and I'm won...
I just graduated from university with a degree in Computer Science/Engineering and was fortunate enough to land a job working in the pharmaceutical industry as a developer. My title is System Developer I, which will require the following skills: 0-3 years development experience with C# .NET and SQL Server Experience wr...
I am looking for coding guidelines developers should follow while writing C#/ASPX/SQL code, so that merging into other branches is smooth if not seamless.
I have been asked to quality review two code bases. I've never done anything like that, and need advice on how to perform it and report it. Background There are two providers of code, one in VB and one in C (ISO 9899:1999 (C99)). These two programs do not work so well together, and of course, the two suppliers blames ...
This is a repost of a question on cs.SE by Janoma. Full credits and spoils to him or cs.SE. In a standard algorithms course we are taught that quicksort is O(n log n) on average and O(n²) in the worst case. At the same time, other sorting algorithms are studied which are O(n log n) in the worst case (like mergesort and...
I have, for example, this table +-----------------+ | fruit | weight | +-----------------+ | apple | 4 | | orange | 2 | | lemon | 1 | +-----------------+ I need to return a random fruit. But apple should be picked 4 times as frequent as Lemon and 2 times as frequent as orange. In more general case i...
I have been working on a database project, and I recently received a bug report for the remote execution of some queries. Usually, you try to find out the actual cause for the bug to occur and then fix it. But sometimes what I do when I'm fed up of doing some research (and can't find suitable information on the interne...
In my company we are building a webapp containing serveral central services that we design ourselves and then specify as interfaces. I.e. the interfaces are application specific and they are then implemented with third party libraries which we may change over time. When it comes to exceptions, I have realized that the ...
Another team in my company start to document their stand-up meetings, but I believe it is a waste of time. As far as I know, stand-up meetings are for communication not for status reporting (please, correct me if I am wrong) So, Should we document stand-up meetings?
If we have more than one service that uses same database - is it ok to move out user authentication on separate server and use RPC calls, instead of traditional database lookup?
Me and a friend are looking to team up for some freelance web designing. We both are very strong PHP coders and website designers, but I am better at design and he is better at PHP. So, I'll be controlling the stuff the user sees, he'll be controlling the stuff the user does. In order to speed up development, I'm wonde...
I am currently creating a web application that allows users to store and share files, 1 MB - 10 MB in size. It seems to me that storing the files in a database will significantly slow down database access. Is this a valid concern? Is it better to store the files in the file system and save the file name and path in the...
I'm designing a pretty standard Spring MVC application, and I'm trying to figure out where the responsibility for transaction management should lie. I've been reading Java Transaction Design Strategies, and the one that I think best suits is the Server Delegate one, where the controller is what manages the transactions...
I'm writing a game and the accompanying graphics engine on top of OpenGL in C++. Im also a fan of good coding processes and automated testing. Graphics code + testing seems pretty immiscible, since the output is often visual only, or very heavily visual-oriented. For example, imagine analyzing the raw image-stream that...
Preamble (Skip if you don't like to read) I've been learning C/C++ in school for a year now and all the assignments in the book, after reading through the chapters, were not too difficult to implement. Some examples of programs I've written are abstract data types like binary trees, queues, stacks, lists, and other typ...
According to section 11.2 of the App Store Review Guidelines, Apps utilizing a system other than the In App Purchase API (IAP) to purchase content, functionality, or services in an app will be rejected. Various apps like JetSetter, Gilt, and Kayak include in-app purchasing flows that either collect credit card inform...
I'm starting an internship program for our software department and I was wondering about creating a position ("chief intern", intern supervisor, or whatever one should call it) with the following responsibilities: Train interns Coach interns Manage projects and tasks for interns Supervise intern's work in terms of rhy...
We are a group of people playing floorball together on a regular basis. Every session starts with the daunting task of dividing teams... So what would be better than an application to pick teams automatically? So, given a history of team-combinations and results, and a list of people showing up for this particular sess...
Current job: Working as the lead business analyst for a Big 4 firm, leading a team of developers and testers working on a large scale re-platforming project (4 onshore dev, 4 offshore devs, several onshore/offshore testers). Also work in a similar capacity on other smaller scale projects. Extent of my role: Gathering/...
I have FILE_A which has over 300,000 lines and FILE_B which has over 30 million lines. I created a Bash script that greps each line in FILE_A over in FILE_B and writes the result of the grep to a new file. This whole process is taking over 5 hours. How can I improve the performance of my script? I'm using grep -F -m 1 ...
The Queue class in the python kombu library inherits from MaybeChannelBound, which in turn implements the call method (making it callable). The call() method itself is a thin wrapper around the bind() method. It is not clear why this was done, as calling the bind() method seems (to my simple mind, at least) to be clear...
I'm working on an Android app. We have listeners for position data and camera capture which is timed on a background thread (not a service). The timer thread dictates when the image is captured and also when the data is cached in a local sqlite db. So, my question is how to properly store the location data as it com...
I'm working on a team where the team leader is a virulent advocate of SOLID development principles. However, he lacks a lot of experience in getting complex software out of the door. We have a situation where he has applied SRP to what was already quite a complex code base, which has now become very highly fragmented a...
I'm looking at using some open source code in my ASP.NET web app (specifically dapper). Management is not a fan, because open source is seen as a risk that has bitten us before. Apparently previous developers have had to rewrite things after having open-source components fail. The pros seem to be: It does a lot of s...
I wanted to verify with all of you, if I have a correct Observer Pattern analogy. The scenario is as follows: Consider, at a junction, there is a traffic signal, having red, yellow and green lights respectively. There are vehicles facing the traffic signal post. When it shows red, the vehicles stop, when it shows green...
The data in my website is stored in many different tables(friends,relatives,etc) and every-time I have to query each and every table. But all this data is subject centric. E.g. data for a person is of the form data[301]={ "pid"=>301, "friends"=>array(), "relatives"=>array(), "interests"=...
When I want to use the Apache 2.0 licence in my project, I should include this in the comments of my source code: Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the Lice...
Why was it decided to call the kill command "kill"? I mean, yes, this utility is often used to terminate processes, but it can actually be used to send any signal. Isn't it slightly confusing? Maybe there are some historical reasons. All I know from man kill that this command appeared in Version 3 AT&T UNIX.
Working on two formats throughout our website - PC and mobile. Each request will have a check who the client is. Then, two methods seem optional: Render the page accordingly. Redirect to a parallel site Is there a difference in server load (i.e. maybe 2 has less load because requests are actually pointed at different...
I have been conducting some research into RESTful web service design and I've reached what I think is a key decision point so I thought I'd offer it up to the community to get some advice. In keeping with the principles of a RESTful architecture I want to present a discoverable API, so I will be supporting the various ...
I was thinking on how current key-value storages implement "expire date" for items. Currently I have 2 variants for that in my mind: they don't do anything (keep expired data), and only do check when you do, for example, GET by some key. The problem here is that if you are limited in memory, expired items won't be del...
We've been tasked with creating a web based workflow tool to track change management. It has a single workflow with multiple synchronous tasks for the most part, but branch out at a point to tasks running in parallel which meet up later on. There will be all sorts of people using the application, and all of them will ...
I'm trying to understand how the puts function fits in Ruby's "Everything is an object" stance. Is puts is the method of a somehow hidden class/object? Or is it a free-floating method, with no underlying object?
My experience with web services is slim and I'm trying to understand this a little bit more. I have done for instance a web service using visual studio. In order to use it, I add a web service reference in my projects and this creates a proxy and the use is pretty simple. Does this use SOAP? I ask this because i will ...