instruction
stringlengths
34
19.9k
I'm coding a server/client application pair in Java, as I learn about it. I have basic functionality of sending a message to the server and parsing it but in thinking about the big picture of their communication, I'm stumped about where to go from here. Both the client and the server have to be able to initiate an exc...
I've noticed that a lot of companies use "reverse domain name" namespaces and I'm curious where that practice originated and why it continues. Does it merely continue because of rote practice, or is there an outstanding architecture concept I might be missing here? Also note questions such as: https://stackoverflow.com...
With a YYYY-MM-DD HH:MM:SS date I always store the UTC time. When I pull to display I translate timezones with built-in PHP functions and classes. I believe that is one correct way to do it and it makes sense to me. May I handle YYYY-MM-DD the same way?
I'm pretty sure that someone has already thought about it and researched it extensively, but I'm having trouble finding any materials or even keywords to look for, for the idea that I was thinking about recently. I thought about this concept, where in distributed systems, actual computation and processing would happen ...
In SICP 2nd Edition section 2.2.3, the authors have the following code: (define (even-fibs n) (accumulate cons nil (filter even? (map fib (enumerate-interval 0 n))))) My question is why did they use accumulate in this case? Couldn't they ha...
I need to write a cross-platform GUI application to process (in multiple threads) and visualize fairly large quantities of data. Ideally the application should be relatively fast and look good. The app's interface will consist of a table widget, a tree widget, and a custom figure-drawing widget. The user will be able t...
It seems like FILEHANDLER is more commonly used as a handler naming convention than $filehandler. But it can give a bareword error if one forgets to use *FILEHANDLER in some constructions. What are advantages and disadvantages of HANDLERS and $handlers? Which naming convention is a better practise, and why?
I am implementing an application in Haskell and, for sorting, I use the library function Data.List.sort. However, I was wondering whether this is the fastest sort implementation in the Haskell standard library (perhaps lists are not the best choice for efficient sorting). I have found different alternatives, e.g. heap ...
This might sound like a naive question but when are database table indexes in mysql required? How do such indexes affect performance and why?
I'm trying to learn recursion. I copied this bit of code from my book and added the displays to help me trace what the method is doing and when. public static void main(String[] args) { System.out.println(sum(4)); }//main public static int sum(int n) { int sum; System.out.println("n = " + n + "\n")...
I have an array of dimension 5. But, I can't figure out how to visualize that array? int[][][][][] array = new int[4][4][4][6][2]. Is there a good way to visualize arrays with dimension counts of 3 or more?
I am starting a software project that I want to have the option to keep it proprietary. However, since I generally use a Linux environment, I want to know: How do people write proprietary software in Linux and not violate the GPL/LGPL/etc licenses that seem to restrict uses of libraries needed to build the project? Al...
I have a conceptual problem with a proper implementation of code which seems require multiple inheritance, that would not be a problem in many OO languages, but as the project is for Android, there is no such thing like multiple extends. I have a bunch of activities, derived from different base classes, such as simple...
I am not talking about simple UI logic like clicking a button directs you to another page, but where one action may result in several different of behavior depending on current application state, and may also trigger response in other parts of the application. Currently my view publishes all UI event so the response ca...
When manually inspecting unfamiliar code (to review or modify), I seem to have three options. A top-down read of the code, choosing each next source file by how fundamental the filename seems. I usually end up reading nearly everything. Some files twice. A breadth-first read, where I find and read all of the invokin...
I've been tasked with creating a dashboard application to show real time updates for our servers. The raw data comes in from an XML file on our intranet which I need to parse and present to the user. It is not an option to have every user of the dashboard pull this XML file at the same time for their updates. From what...
I ran into the following issue where a keyboard shortcut I was used to was no longer working in Ubuntu. That's just an example. For programming, this kinds of thing happens a lot, but it also happens in any aspect of work and life. I'm always tempted to fix it right away because I have an idea of what might fix it in a...
I have trouble drawing a clear line between Presentation and Application layer in Domain Driven Design. Where should Controllers, Views, Layouts, Javascript and CSS files go? Is it in the Application or the Presentation layer? And if they go all together in the same layer, what contains the other one? Is it empty?
Look at this: <?php echo "Hello World"; ?> <br /> <?php echo "Welcome"; ?> And now look at this: <?php echo "Hello World"; echo "<br />"; echo "Welcome"; ?> Which one of the above examples is considered to better (at least from performance point of view)?. I know the examples are trivial but I want to follow good pr...
A rather simple question here, With regards to web design and the paperwork behind it (Which I am sure many people/companies don't actually do). Would there be any reason for using a Cumulative Chart? Specifically a Cumulative Resource chart, although I am unsure what the resources could even be! More to the point, ...
Design Question Recently, I've been doing more and more FP in C++, mostly in the form of function templates and lambdas, and heavy overloading of a single function name. I really like FP for some well-defined operations, but I've also noticed that as with OOP, one could easily fall into anti-patterns of spaghetti-code...
Problem Statement - Given a 2xN grid of numbers, the task is to find the most profitable tiling combination (each tile covers 2x1 cells; vertically or horizontally) covering all tiles. I thought of approaching it in the greedy way, enqueuing the max possible for any cell, but it has a fallback that a low-profit choice...
I just read Beating the Averages, and Mr. Graham writes that they had a significant advantage over competitors because they used Lisp. From what I understand, Viaweb was a WYSIWYG editor that ran in the browser for customers to create their own 'stores'. This is obviously inconceivable now to do without JavaScript, yet...
Problem Statement - The task is to find the most profitable contiguous segment of tests, given a sequence of test scores, with being allowed to drop any k tests from a chosen range. The problem appears to be a DP problem at the outset, but complexity arises when the test drop condition comes into the picture. What mo...
This is a web application based on actionscript 3. I have all of my modules enumerated in a class, but I never know which modules actually come from database. Let's say I have 20 modules in my application, but the user only has access to 10 of them. All I get are 10 strings from database (the module names) whenever the...
From a given tree, subsequent trees have to be generated. Nodes can be marked as "variant" in the given tree (the example uses an asterisk to mark the node). All possible combinations between the variants form the resulting trees. From the following tree: - Product - Packaging * - Small box - Heavy ...
Any idea why the C# version of sqrt (System.Math.Sqrt) is ~10 times slower than c++ version ? Furthermore, C# version seems to have one extra digit of precision. I have run my test under MSVC2012. I have used double and call System.Math.Sqrt once before doing the bench in order to force Jit
In functional programming since almost all data structure are immutable, when the state has to change a new structure is created. Does this mean a lot more memory usage? I know the object oriented programming paradigm well, now I'm trying to learn about the functional programming paradigm. The concept of everything bei...
I'm a beginner-level C++ programmer, but I understand the concepts of the language fairly well. When I began to learn external C++ libraries, like SDL, OpenGL (maybe something else too), to my great surprise I found out that they don't use C++ concepts at all. For example, neither SDL, nor OpenGL use classes or except...
I have some legacy code, which uses Lisp as it's scripting language. To broaden, ease and accelerate scripting I'd like to replace Lisp by Javascript. In order to be able to built on all present scripting files, I first need to translate all lsp to js. Now I found parenscript but am not yet sure what it is good for (se...
In the context of the Ruby programming language, what is a closure and when do you use one? What are the uses for it in Rails?
Lets say that I have hundreds/thousands of objects(entries) in a database and each object contains 10 attributes. I have a way to quantitatively measure each attribute where a higher number implies that the object is better in that area. I also have a final price associated with that object. Is there any way to program...
Javascript is a prototype-based object oriented language but can become class-based in a variety of ways, either by: Writing the functions to be used as classes by yourself Use a nifty class system in a framework (such as mootools Class.Class) Generate it from Coffeescript In the beginning I tended do write class bas...
Wikipedia says that Agile is a type of "RAD" which I guess is incorrect. From what I know, Agile was developed becasue RAD itself was not that sucessfull in 90'S (too rigid for changes). Or am I wrong? (Remark: apparently the Wikipedia article on Agile software development was improved in between, it just lists RAD as ...
I am creating a free nokia application for which I am about to use images from a creative common website. Now my question is if a free application come under creative commons as it is not a paid one? Thanks in advance.
Imagine a small calculator GUI, with basic operations (+,-,/,*), and in the menu we can check for example scientific calculator and a small new view with the extra functions appears beside. I was thinking that the decorator pattern is the solution but after reading some documentation on it, I am confused now. Which pat...
Problem Statement - The task is to find the minimum number of swaps required in the given arrangement of cartons to get the desired arrangement of cartons. Only adjacent cartons can be swapped. I have tried an ad hoc approach, but it proved inefficient towards the upper limit of the data range. Here it is for referen...
I do not have the access to the IEEE standard and information on the net are contradictory. Can I capture user requirements in SRS using use cases? Or I should keep use cases separate as they are more like scenarios than separate requirements?
I'm developing a software documentation in a project, and much of it are just CRUD or CRUD based functions. As you can imagine, a lot of the rules are constraints about fields validation, things like length, range, data type and masks of the field. Writing all those rules would be cumbersome to write and to read, so I...
We have developed a job-portal where users can view jobs and and also post jobs. We have used Php and MySQL. We hosted this on web faction. Now we want to develop the mobile app of the job portal for android, ios and windows. As the database should be synchronous and aligned dynamically with apps and website database. ...
I find it that when languages are considered the same as commercial software, there is always a constant need to add new features to justify new releases. Can there be or are there languages where version 1.0 is the final version? Of course bug fixes are exempt from this, but the feature set always remains the same? Th...
The definition of a Y combinator in F# is let rec y f x = f (y f) x f expects to have as a first argument some continuation for the recursive subproblems. Using the y f as a continuation, we see that f will be applied to successive calls as we can develop let y f x = f (y f) x = f (f (y f)) x = f (f (f (y f))) x etc....
Recently, I've been trying to implement some working version of the Glicko Rating System for fun. However, I fail to understand how to programmatically isolate R in Step 2. As you can see R appears on both sides of the equation and for a variable number of instances. How would I programatically solve for R using pytho...
This is my understanding of the Application Layer: • It implements Application logic • this layer contains Application Services, which are used by external consumers to talk to your application • Application Services are coarse-grained and orchestrate operations which map directly to use cases ( hence also the term ...
I'm working on a pretty standard LAMP based web application. The server itself has a standard MySQL database and the application is written in PHP. The kicker is, we also use SQL Server databases with this application. The current data setup is this: MySQL stores the user account information (Username, password, pri...
When browsing open-source projects that are primarily developed for Linux systems and downloading the latest packages, the source code is always stored in a .tar.gz or .tar.bz2 file. Is there any reason for using .tar.gz or .tar.bz2 rather than something like .zip or .rar or some other compression algorithm (or even le...
Say I'm developing a bug tracker, where a ticket belongs to at most one milestone, and a milestone can have many tickets. When a milestone is deleted (from the database), all tickets associated with that milestone must have their relationship unset (i.e. set to null). This is a simple relationship. The classes are fair...
When writing page generation in PHP, I often find myself writing a set of files littered with database queries. For example, I might have a query to fetch some data about a post directly from the database to display on a page, like this: $statement = $db->prepare('SELECT * FROM posts WHERE id=:id'); $statement->bindVal...
We have an application that we need to ensure that our APPLICATION DATA should not be used (or opened) in different computers with same users. For that we thought about getting harddisk GUID as a part of data encryption private key. In this case raid disks, virtual PCs would fail and wouldn't be able to open the data. ...
Do NSURLConnection service objects and XML/JSON parser objects fall within the controller layer or the model layer? Why? Is it OK to have business logic in the controller? Or should it be in the model layer only? Can the model layer be represented by NSArray/NSDictionary objects or should it be strictly structured with...
I was recently wondering why the keyword auto was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in auto x = 1; Since var seems more common in other programming languages (e.g. C#, Scala, JavaScript), and As far as I understand the new semantics of auto breaks backward compatibil...
Word processors (e.g. Microsoft Word) display documents to the user as styled text. The user can select a part of this text and apply styles to it, and edit the text. The word processor must (I guess) have an internal representation of the document that indicates which bits of the text displayed to the user should be s...
E.g. - $stream1 is the STDOUT of a child process and $stream2 is the STDERR of the same child process - $stream1 is one child process and $stream2 is another child process Is there a possiblility in perl to monitor two or more streams at the same time? So we loop as long as anything pops-up in any of the streams and we...
I'm developing a tool that handles (electrical) parts. The parts can be created, viewed, modified, deleted, grouped and so on... In order to make this question useful for future visitors I like to keep this question universal since managing parts in a DB is very common no matter what parts are in the DB (CDs, cars, foo...
One of things that annoys me about SQL is that it can't think in terms of objects and it's lack of encapsulation makes me constantly have to escape commands to prevent injections. I want a database language that can be polymorphic and secure. I have searched online for non-procedural database programming languages and ...
I work on a rather large code base. Hundreds of classes, tons of different files, lots of functionality, takes more than 15 minutes to pull down a fresh copy, etc. A big problem with such a large code base is that it has quite a few utility methods and such that do the same thing, or has code that doesn't use these ut...
Just wondering if text such as the following, which appears inside the source files of a free, open source API, means anything in a court of law // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal //...
For example, if I have a Customer Transactions Table and I create a REST for it. The fields are: date, description, and total_amount. I am trying to figure out which one is much more efficient when you get the sum and the count of the transactions: You create a REST for /transactons URI and it lists down all the tran...
Note: after writing this I realize that this question is perhaps philosophical, but I'm interested in how the industry handles this scenario regardless. I have recently been working with a code base that is not yet as testable as it should be. I've seen some junior developers check in code that breaks use cases, whic...
I want to uderstand why there is a method in C# that could reurn a value, for example: public int Accelerate() { Speed++; return Speed; } and a method that does not reurn a value (void)? What is the difference in the following example of the above one: public void Accelerate() { Speed++; Console.WriteLine(Sp...
I'm in the early stages of designing a client/server application. The clients will be batch programs that read a file of customer contact data (name, address, email address, phone no's) and pass these components to the server, which will add them (if not already present) to corresponding mySQL tables and return id's ...
Say we have a view page where users perform actions in multiple steps, some of these actions would involve DB operations with transactions (the snippets are in pseudo-code like from): View 1: Step 1: ... Step 2: ... Call ActionX Step 3: ... ActionX: # can be called fro...
My programming friends are always telling me that HTML is a markup language and C++ is a programming language. When I ask them what's the difference, they never give me a reasonable answer. What could make one call C++ a programming language, and HTML not?
I am trying to figure out a better way to decide table storage configurations whether it will use static configurations using tables or dynamic configurations using EAV (entity-attribute-value) When creating database tables, forms, and reports, when do you decide that a program should use a normal database (wherein eve...
I was using this feature in earlier Windows release like XP and NT. I was able to run a GUI from a Windows service. But it is not possible in the later versions. What is the reason behind the removal of this feature? Why can't Windows services have a GUI?
During a job interview, I was asked to explain why the repository pattern isn't a good pattern to work with ORMs like Entity Framework. Why is this the case?
I have a program I'm working on that my company uses internally, but is also sent to vendors. The vendor version will be identical, except that it will be missing some features, and use an installer. I only have to remove 2 lines from an XML file, and it's good for external use. Is there some "typical" method to creat...
I'm about to leave a project, and before I go my boss has asked for me to document code (I've not documented very well). It's not a big deal, the project is not terribly complex. But I'm finding places in my documentation where I would like to say, "Notice on line XYZ that such-and-such happens." In this case, it doe...
When learning about these tools, I (naively) thought that mapping about the business space could be front loaded by doing it only once and refering to those diagrams for each project within a single business unit. However, I am finding that each situation is calling for it's own set of diagrams to properly communicate...
I'm not sure if what I'm after even exists or if it doe's im looking for the wrong thing. I'm after a framework/application/SDK that allows me to build a desktop application with a HTML/CSS/JavaScript based interface yet still allow for more complex OS interaction with a programming language such as Python (im also fa...
I'm looking into delving into a bit of custom OS work (and yes I understand that doing any development at the DE level or lower on an OS is extremely complex and not a light thing to undertake, curiosity is driving this though), I'm in the research phase right now, digging around and learning by example from the source...
I am working in a Python project that I want to release under the GPL3 license. This project has one file that uses the BSD lxml library . I really need to put reference of the BSD license in the file where I use the library? Or just the GPLv3 of my project covers the licenses restrictions. Library: http://lxml.de Lic...
I find header files to be useful when browsing C++ source files, because they give a "summary" of all the functions and data members in a class. Why do so many other languages (like Ruby, Python, Java, etc.) not have a feature like this? Is this an area where C++'s verbosity comes in handy?
I've been reading about software licensing as I feel that I'm at a stage now, where I should probably have some sort of a license associated with my code. What I am looking for is a copyleft (weak or strong) license that basically is very liberal. So I'd like the license to allow anybody to do anything with the code/pr...
I asked this question on Stack Overflow and it was closed as off-topic. I'll ask it here hoping it will do better. This might sound silly, but bear with me. I've been working a lot with intervals and dates lately. One question that bothers me: is a day really 24 hours long? I'm interested by the answer both from a theo...
I'm finding it hard to solve the problem and was hoping that someone could help me with the solution or at least give me a search term to use for problems like this one. The generalized problem: I have a set of numbers (e.g. [1,2,3]) and a an array of sets (e.g. [1,4,5],[4,2,3],[6,7,8],[2],[1,3]). What I need to do is ...
One feature I miss in from functional languages is the idea that operators are just functions, so adding a custom operator is often as simple as adding a function. Many procedural languages allow operator overloads, so in some sense operators are still functions (this is very true in D where the operator is passed as a...
I've written several unit tests for an already existing DatabaseOpenHelper class. I covered the creation scenario and migration from old schema to new one. Unfortunately, I don't feel that my tests are good. For example, for DB creation I check that SQLiteDatabase. execSQL() was called three times (we have three tables...
I have an open source project for mydomain.com which requires connections to a database (...as is tradition). What is the standard practice for allowing others to work on the site, without giving them full access to the database's credentials? For example: If I have a connect.php page that connects to the database. I d...
I'm new to GitHub and VCS in general. I've been programming in various languages for years, but I've always worked solo on custom projects (no public releases). I recently started using a jQuery UI widget I downloaded from GitHub in a project I am working on. The repo is no longer maintained by the original author. Ano...
Although this is a gamedev project, the question is about general OOP practices, so I believe it goes here. Here's the problem: (note: I will call any equivalent of real-world physical objects "entities" from now on; e.g. a rock in the game is an entity) A specific class: class Character { public/private CharacterInven...
Recently I have been reading online about eXtreme programming and agile practices. I wish to adapt them. However most of my code is all in PHP which is the normal CRUD type web applications. Moreover I user web framework like CodeIgniter, which also abstracts a lot of the core features. To sum up, how can I implement t...
I have written an open source and cross-platform C++ File Library which have exception and error codes. Exceptions can be disabled when the program is running. In that case, the user have to check the error codes. Of course, when exception throwing is enabled, error code won't be returned because exception is thrown be...
I looked at it in my field of work, which is film and pretty much every software we use comes with python as a scripting language: http://en.wikipedia.org/wiki/List_of_Python_software That made me assume it's the most popular. How did Python become popular as a scripting language? Especially as an embedded language int...
I’m trying to “conceive” the business logic of this website that has many activities, that the users can build their “combo” and get discounts depending on their choices and how long they are willing to pay for their plan (1, 3, 6 and 12 month plans). I’m having a hard time trying to come up with a solution, while keep...
Suppose there are two threads, which communicate by asynchronously sending data messages to each other. Each thread has some kind of message queue. My question is very low level: What can be expected to be the most efficient way to manage the memory? I can think of several solutions: Sender creates the object via new....
I have an open source project that uploads files to DropBox among several file hosts. Right now I am screen scraping for DropBox. To use their API, I have to hardcode a SECRET KEY provided by them to me for OAuth authentication. But I'm afraid that the key won't be secret if it is visible plainly for anyone to see. It ...
I have a set of loadable data decoders for a specific type of data and a stream to read containing data. Now I want the program to select the correct decoder in a reliable way so I want to use a trial-and-error algorithm. It seems resonable to create a decoder and connect it to the stream using a constructor: // C++ co...
In your opinion, do you think it is a waste of time to make checks that you know there is no possible way of it being there/not being there, or would you just put it there just in case there is a bug or something? For example, below checks to see if a button is visible, then music is playing, but there is no way for t...
If a project is dual-licensed GPL & BSD, should there be one LICENSE file with the text of both licenses? Or two separate files, one for each license? And I think I should put a copyright/license comment at the top of each source file. How should that comment indicate the dual-licensed status of the project?
On the internet, I've come across this question: Classify the Hashing Functions based on the various methods by which the key value is found. with answers like Direct method Subtraction method Modulo-Division method Digit-Extraction method Mid-Square method Folding method Pseudo-random method which I find strange. ...
Possible Duplicate: I’ve inherited 200K lines of spaghetti code — what now? Not long ago my company placed me in a team that deals with some of the most complex bugs that are in production. The thing is that almost all of these bugs are in legacy applications I am having a really difficult time understanding and deb...
First, does anyone know a specific advantage of Google App Engine for Python Apps? Is there some advantage over Heruko or Appfog? And about the database API? Now, what about the limitations? Are there any factors that make you think twice about using GAE?
Michael Perry states in his Pluralsight course on Provable Code (transcript subscription only) that: [T]he burden of proof rests with the caller In a code contract, why must the burden of proof rest with the caller and not the method of the class that is being called? Is this a preferred convention or does it have a ...
I'm looking at plupload for some upload features on a website I'm developing. Now plupload is GNU GPLv2 licensed and that implies that all derivative software should also be GPL licensed (right?). Therefore I run the plupload through my minifier, the single minified js file will violate the license, and upon request, I...
I mean something along the lines of: public interface Dimensioned { int getWidth(); int getHeight(); } and public interface Positioned { int getX(); int getY(); } There are a lot of standard java classes that have exactly those methods-- notably Component and all of its subclasses as well as Dimensio...
The name mangling schemes of C++ compilers vary, but they are documented publicly. Why aren't linkers made to decode a mangled symbol from an object file and attempt to find a mangled version via any of the mangling conventions across the other object files/static libraries? If linkers could do this, wouldn't it help...
Is there some standardized or widely accepted algorithm for picking up operators in shift/reduce conflicts in LALR parser? The question is naive, my problem is not with implementing my solution, but implementing the solution is already widely used. For shift the operator is the next input token, for reduce, it depends ...
I'm trying to figure out the best way to handle custom errors in my application. Option 1: if(expr) { } else { $_SESSION['error'] = "Some message describing the error"; } Option 2: if(expr) { } else { $_SESSION['error'] = 2; } In option 1, the same error might be recycled in multiple situations. If I ever dec...
I was using a popular music package (Ableton Live) when I opened the legal section of the helpfile and saw that the program contained code licenses that appeared to be both free as in freedom and free as in beer. I cannot find an online copy, alas, but if necessary I can list the licensed packages. As far as I can see ...