instruction stringlengths 34 19.9k |
|---|
I'm using a lot of printf for tracing/logging purposes in my code, I've found that it's a source of programming error. I always found the insertion operator (<<) to be somewhat of a odd thing but I'm beginning to think that by using it instead I could avoid some of these bugs.
Anyone ever had a similar revelation or I'... |
On this wikipedia page I have found the following sentence regarding closures in C++11:
C++11 closures can capture non-local variables by copy or by reference, but without extending their lifetime.
Does this mean that an existing closure might refer to a non-local variable that has already been de-allocated? In such ... |
I work on a Windows/Mac cross platform application that is sometimes downloaded from web sites. It is sometimes re-branded by and sold by third parties.
I'm the 'windows guy', my Mac counterpart is on vacation.
I'm getting some questions from a customers about what the Mac user experience will be if we sign the Mac... |
Of course, it is very good use to use a logging framework for the error messages or warnings. But sometimes I use System.out.println() if I want to try something new in a short time.
Is it really so bad using System.out.println() for some quick test?
|
I am currently reading the Analysis of Algorithms section in Algorithms, 4th Edition and I'm trying to understand how the author calculated (N^2)/2 and (N^3)/6 frequencies of execution in the code snippet below (here is the full code):
public class ThreeSum
{
public static int count(int[] a) {
int N = a... |
This is a purely hypothetical question.
Say I create a class method that contains no references to instance variables or other resources. For example (C#):
protected string FormatColumn(string value, int width)
{
return value.Trim().PadLeft(width);
}
As far as I can see, there is absolutely no reason why this met... |
I submitted an application I wrote to some other architects for code review. One of them almost immediately wrote me back and said "Don't use static. You can't write automated tests with static classes and methods. static is to be avoided."
I checked and fully 1/4 of my classes are marked static. I use static when I am... |
Let's consider something like a GUI application where main thread is updating the UI almost instantaneously, and some other thread is polling data over the network or something that is guaranteed to take 5-10 seconds to finish the job.
I've received many different answers for this, but some people say that if it is a r... |
How does caching effect the performance of a running program? From my understanding, the assumption that each instruction always takes the same amount of time is not always correct, because of the effects of caching. How does caching affect algorithmic performance? Thanks in advance.
EDIT 1:
To further elaborate, lets ... |
I am using GDataXML library developed by Google as part of their Objective-C client library. As its Google’s XML processing library and I heard that Apple don't allow to use any third party libraries in app, will they allow this one?.
(I am using this library because many iOS geeks suggest to use this one!!).
Thanks in... |
I have a database table holding 40 million records (table A).
Each record has a string a user can search for.
I also have a table with a list of character replacements (table B) i.e. i = Y, I = 1 etc.
I need to be able to take the string a user is searching for, iterate through each letter and create an array of every ... |
I am taking a networking class(data communication) this coming semester. In many courses in my computer engineering degree, the books lack mathematical content. I am not a math wizard, but I think mathematics has the potential to give a much deeper understanding of different concepts, but it requires more work.
Is it ... |
I developed one application for iPhone and now I want it on App Store. So many my iOS geek friends told me to test it on actual device i.e. on iPhone.
So I wonder that why it is necessary to to test my iPhone app on actual iPhone device though they (Apple) have given "simulator" which is near about same as my device?
|
I often see projects (in Java projects and teams using Eclipse) that prefix function parameters with p.
For example
public void filter (Result pResult) ...
I personally don't see any benefit in this, but would like to know what the reasoning is. The best explanation I've heard yet is that it is to distinguish the nam... |
I am building a site and idealy I would like to record the users interaction via their webcam. How do I intergrate webcam recording into my site. I have seen It done with flash. But Im trying to avoid using this. My site is being built using c#, javascript and designed for IE 7 and older.
I want to record the videos f... |
In a git environment, where we have modularized most projects, we're facing the one project per repository or multiple projects per repository design issue. Let's consider a modularized project:
myProject/
+-- gui
+-- core
+-- api
+-- implA
+-- implB
Today we're having one project per repository. It gi... |
I'm using a registration function that hashes the email in PBKDF2 with a random and unique Salt each time. The hashes email and his salt are saved in the DB. No problem with that.
The problem is that now I want to make sure that users only create one single account per email. Obviously to verify that I need to check my... |
Possible Duplicate:
When are Getters and Setters Justified
Why are public and private accessors considered good practice?
In my time as developer I learned that properties can be very useful. I use properties to control read and write access or to add something like validation checks.
But assuming that I have an aut... |
I'm trying to create a JSON schema for the results of doing statistical analysis based on disparate pieces of data.
The current schema I have looks something like this:
{
// Basic key information.
video : "http://www.youtube.com/watch?v=7uwfjpfK0jo",
start : "00:00:00",
end : null,
// For results o... |
I'm requesting best practice with this question. This is only an issue if the customer company is strictly national has a native language other than English, I think.
If the customer has a lot of mainly very domain specific (say, German) expressions, mixed with some lesser domain specific namings. The language of our c... |
I have a line of text I would like to display only when a webpage is being printed. Is it possible to only display this line when printing the page or doing a print preview using PHP in some way?
Basically, I want to print a page without the print headers, but would like to include the page's URL within the page's con... |
I installed Apache2 and PHP5 last night on my fresh Linux Mint machine.
I created a folder and created a simple index.php file with a call to phpinfo() to test out the installation and every works correctly.
However when I open the file with Sublime Text 2 or any other editor, I cannot save my changes. I can use the su... |
I'm using this as part of a game, but it's not really a game development question, so I'm putting it on this more general Stack Exchange.
The goal is to generate "random" outputs for a fixed integer input, but (and this is the clincher) to generate the same random output every time the same random input is put in.
The ... |
I have the following:
html {
overflow-y: scroll;
}
body {
font-family: Georgia, "Times New Roman", serif;
font-size: 1.125em;
line-height: 1.5em;
margin: 0 auto;
max-width: 41em;
}
Which attributes should be with the HTML section, and which within the BODY section?
|
I have insert 14.485 lines on MySQL like this:
INSERT INTO `bairros` (`id`,`cidade_id`,`descricao`) VALUES (1,8891,'VILA PELICIARI');
INSERT INTO `bairros` (`id`,`cidade_id`,`descricao`) VALUES (2,8891,'VILA MARIANA');
...
It took around 5 minutes.
I had to insert in another table 16.021 lines, same database, so for t... |
We currently abuse our version control system and use it... pretty much as an FTP to store big release binaries (4+ GB).
We are seeking to move away from this horrendous practice which has and continues to devolve and take more and more of IT's resources while crippling the integration and release processes.
A solutio... |
I know Javascript for some time, although I am not a heavy user, I know it the first from the time when Netscape was my browser. I pretty much understand the main things, but since JavaScript approach to OOP is prototypical I have some problem grasping it.
One problem to add to this it seems that things can be done in ... |
I'm thinking of freelancing and building web sites in my free time.
I have experience in C#/ASP.NET, JavaScript/jQuery as well as HTML/CSS and SQL. Thus, I feel like I have sufficient web technologies knowledge to go down this path.
What I'm unsure of is if there are any tools which can be used to simplify the life of... |
In my last three jobs, I was a code maintainer. In all three cases, I was hired after the majority of the code for the project was already written.
I'm a self taught programmer. Before I ever started my first professional job, I had maybe a dozen projects under my belt that I started and shipped successfully.
Writing n... |
Possible Duplicate:
How should I test randomness?
One of the features to be developed in our application was allowing user to click a button which will choose an element at random out of (normally 5-10) values registered in the database. The randomness doesn't need to be secure or scientifically uniform, but we do n... |
I started programming with Python, and I was really confused by concepts like coroutines and closures.
Now I think I know them on some superficial level, but I've never felt that "enlightement" moment, so I choose to learn Clojure. I bought the book by Stuart Halloway and it's good, but when I looked at the index there... |
Who is responsible for bumping version number in commercial software development?
How to setup policies for that?
1) for small team
2) for medium team
It is important not to forget to change the version number that self-describes that output file.
Such as AssemblyInfo.cs / resource.rc / AndroidManifest.xml
|
What is Amortized Analysis? And how can it help me achieve worst-case performance guarantees in my programs?
I was reading that the following techniques can help the programmer achieve Worst-case performance guarantees (i.e. in my own words: guarantee that the running time of a program would not exceed the running time... |
Floating licensing is a software licensing approach in which a limited number of licenses for a software application are shared among a larger number of users over time. Nice for the corporates to reduce the costs. It has also the developer aspect.
I saw lots of pricing examples for many software. As far I understood, ... |
So when you call malloc or new [] from your C/C++ application, how does the CRT translate it into Windows API calls?
|
As a freelance developer, I sometimes have to access the administration panels of hosting providers of my customers. It is an astonishingly frightening experience. Below are some points I noticed when accessing recently a not-so-unpopular hosting provider based in UK which has the word "secure" mentioned in large on th... |
After reading about OpenMP and not finding functions to support semaphores, I did an internet search for OpenMP and the readers and writers problem, but found no suitable matches.
Is there a general method for replacing counting semaphores in OpenMP with something that it supports? Or is there just a gap in the enviro... |
How does the memory usage of an integer object written in Java compare\contrast with the memory usage of a integer object written in C++? Is the difference negligible? No difference? A big difference? I'm guessing it's the same because an int is an int regardless of the language (?)
The reason why I asked this is becau... |
I am trying to learn lua and am experimenting on my linux machine. I am not a programmer, so I am looking for your help to give me some suggestions.
What I want to accomplish is making my compile-rewrite-recompile cycle as efficient as possible.
Here is what I do.
I am using vim in one window to program. I have a shell... |
Continuing from my previous question: Javascript simple code to understand prototype-based OOP basics
Let's say we run into console this two separate objects(even if they are called child and parent there is no inheritance between them):
var parent = {
name: "parent",
print: function(){
console.log("Hell... |
I've created an application framework using the unit of work and repository patterns for it's data layer. Data consumer layers such as presentation depend on the data layer design. For example a CRUD abstract form has a dependency to a repository (IRepository).
This architecture works like a charm in client/server envi... |
While learning Haskell I have faced a lot of tutorials trying to explain what are monads and why monads are important in Haskell. Each of them used analogies so it would be easier to catch the meaning.
At the end of the day, I have end up with 3 differents view of what a monad is:
View 1: Monad as a label
Sometimes I t... |
I can find all sorts of weird information about templates in Perl, but nothing about what they actually are.
Are they generic types like in C++? Is it a class-like structure? Or maybe something else?
|
I find that oldstyle (or text) figures are much easier to read in any context outside of simple assignment. Are there any low-ambiguity fonts, monospaced or proportional, that have text figures and other programming-friendly features, such as marked zeroes; aligned braces, operations, and other symbols; and bold and it... |
I've been trying to read through the RoR API to try to learn things that the tutorial missed, and I haven't been able to follow it at all. The only time I've read documentation was when I needed to look up a Python module, and that was easy to understand, but I can't understand the docs for Rails. How do I read through... |
Azure ACS offers OAuth and OpenID providers, and now that ASP.NET 4.5 offers the same thing, without the added cost, is there any reason for a .NET developer to consider ACS?
(Disclaimer, I don't know what version of oauth each service provides)
|
Programming languages and programs (as wells as individual functions, objects, etc.) are often described as being "safe" in one way or another. For example, they could be "type safe", "memory safe", "exception safe", "thread safe" - even "reentrant". Each of these concepts is about preventing erroneous or damaging code... |
I am going to be a third year computer science student and I have read Head first Java, Head First C, and I am currently reading C++ which is the language that I like the most since it has a good teaching style for people with experience. I am planning to either learn to make software with QT, learn objective-C(for iph... |
A study shows that lines_written/time is language-independent and application-independent for most programmers. If this were true it would imply that the most terse a language is, the more productive a programmer can be on it.
Where can this study be found?
|
I was wondering if there was a valid use case for being able to properly define the specific internal properties and functions of a class in a way similar to how an interface defines the public properties and functions of a class.
Imagine the task that you have to build a class that describes a human being.
Obviously, ... |
I've been thinking about that for quite a while actually. I am not a native English speaker myself but still, I have years of programming experience and I always asked myself this. Why is it named as Exception but not Error since they are errors?
It could be PageNotFoundError instead of PageNotFoundException!
|
I am a mercurial person. I even use it as an incremental backup tool. I used to use SVN and CVS.
In a recent project, I had to to use clearcase and encountered lots of issues with it. For example, I could not figure out how to recursively include a whole tree of code without writing a script or using awk or find. Is th... |
My problem is the following; I need to get to know a totally new system, for example Wordpress, Drupal, or a framework like Symfony, or maybe a big forum system like PhpBB.
Let's suppose it has no documentation at all, but the code is good.
What I end up doing is that I start at index.php and click the first include,... |
In programming we're often faced with a choice: cover each conceivable use case individually, or solve the general problem:
Its obvious that solving the immediate problem is faster, however creating a generalized solution will save time in the future.
How do I know when it's best to try and cover a finite list of case... |
Besides logical and physical architecture diagrams, comps / mockups and tables for expected network load between components and various data schemas, what kinds of visual content, tables or diagrams might I want to include in my Project Architecture Document?
The specific project is an integration of 3rd party social n... |
We have a business logic layer (BLL) that is tightly coupled to our data access layer (DAL). We make calls like this:
using (FooData data = new FooData())
{
data.DoSomething();
}
It's important to note that all of our data classes are internal, and they're in the same assembly as the logic classes, so that only the ... |
The IO monad in Haskell is often explained as a state monad where the state is the world. So a value of type IO a monad is viewed as something like worldState -> (a, worldState).
Some time ago I read an article (or a blog/mailing list post) that criticized this view and gave several reasons why it's not correct. But I ... |
I work better when I have some firm foundations. This helps me to solve everyday problems better, because I can generalize them. The thing I find in programming is so many things are black boxes. Logic is scientific, but commands are not. A command in a language is just "something that does something". It is very hard ... |
We have list of players, which is represented in form like this:
<div class="players_list">
<div class="player" data-points="500">
<div class="name">Player1</div>
<div class="position">1</div>
</div>
<div class="player" data-points="400">
<div class="name">Player2</div>
<d... |
I've got a little bit of history with programming, having gotten my start with Visual Basic. I let it slide as a hobby from a little after VB6 up until just a year or so ago when I got on the iPhone bandwagon, when I decided to take up Objective-C programming.
I now have what I feel to be an intermediate level of knowl... |
I have a requirement to allow users to fill in journal/diary entries per day.
I want to provide a handful of known journal templates with x columns to fill in. An example might be a thought diary; a user has to record a thought in one column, describe the situation, rate how they felt etc.
The other requirement is that... |
I need to design a function to perform the basic arithmetic operations that are addition (+), subtraction (-), multiplication (x), and division (/) between 2 numbers.
That function takes 3 arguments:
-number1: composed of a value and a unit.
-number2: compoased of a value and a unit.
-operation_type: one of the 4 afore... |
QUnit advertises itself on its web page like this:
...capable of testing any generic JavaScript code, including itself!
Can you really use unit testing software to test itself? Wouldn't defects in the software mean that the results are unreliable?
|
I'm reading The Art of Unit Testing by Roy Osherove. I'm at section 7.2 Writing maintainable tests where the author has this note about code smell:
NOTE: When you refactor internal state to be visible to an outside
test, could it be considered a code smell (a sign that something might
be wrong in the code's design... |
I recently started using arguments in my main program (here written in C++ but could be any programming language)
#include <iostream>
int main(int argn, char* argv[]) {
// do stuff depending on argv[1], argv[2], etc.
}
For now I am using mostly random naming conventions like -t for testing, -d for debugging, -l f... |
Our company runs a SaaS application where users log in from across the world (although mostly in the US). We store all our time relevant information as UTC, but we need to display times using local time. The application is web based, and we would like to "auto-detect" the user's Time Zone by using javascript to deter... |
I have an android app that fetches a list of about 100 Items.
Trying to get the server load down, I've built a filtering feature that
does everything offline, so basically instead of calling the server (and thus a MySQL query every call)
It filters on its own.
However I've noticed the app tends to lag (while the on... |
I'm building an n-tier application, I have UI, BL, DAL & Entities (built from POCO) projects. (All projects have a reference to the Entities).
My question is - how should I pass user input from the UI to the BL, as a bunch of strings passed to the BL method and the BL will build the object from the parameters, or shoul... |
I wanted to add timezone support to my blog app but got stuck with a design problem.
Every post has a published_on field which stores the publication date in a timezone aware format (UTC converted to user's timezone). So far so good. But the permalink of a post is created from the publication date as well. It has the f... |
I'm building some custom web controls in .NET using C#. The controls inherit from the standard web controls, and add additional properties and functionality (e.g. I'm creating an 'extendedTextBox' and I'm adding a 'required' property, which if set to 'true' will add a .NET required field validator to the control autom... |
Currently I have some code like this:
OntologyGenerator generator = new OntologyGenerator();
generator.AddOntologyHeader("Testing");
generator.AddClassDeclaration(owlBuilder);
generator.AddSubClass(owlBuilder);
generator.AddAnnotationAssertions(owlBuilder);
where that OwlBuilder param you see being passed has collecti... |
Well, the title really says it all, but to elaborate a bit, can you take a random, typically effective QA department and have them learn to work in an XP environment (with a learning curve to pick up the XP workflow of course) or would they need more programming skills to be effective? If so, what would they need to k... |
Can a loosely typed programming language like PHP be really considered object oriented?
I mean, the methods don't have returning types and method parameters has no declared type either.
Doesn't class design require methods to have a return type?
Don't methods signatures have specifically-typed parameters?
How can OOP t... |
I am thinking of integrating the openfire chat server with my custom website. Openfire server and the smack client library is licensed under Apache License, Version 2.0.
If I decide to use openfire, will it require my website source code to be also made available under the Apache license?
Tried going through the licens... |
The user will fill out information in page 1, and the data will be seen in the other page listed in a listbox.
Is it advisable to use data binding?
I've been studying/researching about data binding already for about 2 days and still couldn't understand it.
Simple example would really help.
|
I've spent the last year becoming really comfortable with MySQL, but due to its increasing trendiness and my desire to homogenize my web-apps with Heroku, I'd like to start using PostgreSQL for my web apps instead. There are a resources out there for learning PostgreSQL, but I don't really want to have database concep... |
I am a web developer, working mostly with ASP.Net(webforms + MVC), C#, javascript and so on.
As you know, continuous learning is very important for us, but time is not infinite. I do dabble with the odd technology every now and then that has nothing to do with web but mostly I try to learn more about my field in order... |
I wrote a program which scrape internet sites. It is pretty straigtforward because it process link one by one.
With the limiting factor of the internet speed, the process is rather slow.
I wonder, how can I make it multiprocess? The modules of python is confusing. I don't know the difference between subprocess and mult... |
I have a video on demand style site that hosts series of videos under different modules. However with the way I have designed the database it is proving to be very slow. I have asked this question before and someone suggested indexing, but i cannot seem to get my head around it. But I would like someone to help wit... |
We are in the process of constructing an API (using WCF).
So far I noticed 2 ways in which methods could go wrong due to problems with the parameters sent.
wrong format, for example we have a string date parameter which should be in a certain format, if it's in a different format the method cannot continue.
if a metho... |
We have big enterprise projects they normally involve copying data from a source database to a destination database and then setting up a number of additional applications that sync this data etc.
The last project contained 250,000 items (rows of data). The next project will only contain 4,000 items. Project managers /... |
Basically, I develop websites, some large with many crud operations, etc...
However I've gotten into the habit of storing re-usable data as a constant in my PHP applications
I currently have 44 constants defined in one application.
These range from:
Database config
Home page for admin and guest
url slug names
declarin... |
I am a Jr. ASP.NET/C# Developer and I have been working with a Company for the past 9 months. I have been appointed to try and develop their Legacy System (built in Visual FoxPro) in ASP.NET/C#.
I am the only developer working on this project and it's a bit overwhelming, but I complete the tasks assigned to me within a... |
I am used to Java and therefore always think conditions are interpreted from left to right, i.e. there is a vital difference in null != $obj and $obj != null
Now this seems not to be the case with PHP.
Can I do something wrong in PHP when I always start with null on the left-hand side? Can I keep my behaviour from Jav... |
I am working on a Java application (an ERP) that has grown pretty large, and will continue to grow for the next couple of years. We have been using Spring-JDBC for our DAO layer. But the amount of boilerplate code that needs to be written is slowing us down significantly, not to mention introducing silly bugs in the sy... |
I've recently been tasked with testing some COM objects of the desktop app I work on. What this means in practice is writing a large number (>100) unit tests to test different but related methods and objects. While the unit tests themselves are fairly straight forward (usually one or two Assert()-type checks per test),... |
We are a team of developers working on multiple small projects - a developer could have 3 or more 1 man projects to work on and keep moving. It can feel like your time is pretty fragmented & interrupted moving between project to project. Sometimes frustrating, stressful & overwhelming. In an ideal world it wouldn't be ... |
What is a good way to name a method that checks if X needs to be done, and does X it if necessary?
For example, how to name a method that updates a user list if new users have logged in? UpdateListIfNeeded seems too long, while simple UpdateList implies a possibly expensive and unnecessary operation is done every time.... |
In the past I did a freelancing project for someone where I wrote a couple of image filters. Nothing fancy, and a very very low cost project for them. I was wondering, if I wish to use these in a project of mine, would I legally/ethically be allowed to do that? If I couldn't use the exact code, could I at least use the... |
I am looking for a way for SQL Server Management studio to show me the last SQL query that was run. For example, when I make modifications to a table in the designer mode, I will eventually want to make the same changes to the production DB without recreating the entire table. I'm looking for functionality similar to P... |
(Written against GPLv2.)
It is always said that GPL does not prohibit selling the software, as long as its source code is provided under the same license (GPL). Now, I do not understand how it is consistent with Section 2b:
You must cause any work that you distribute or publish, that in
whole or in part contains... |
In Scrum, work is delivered to customers through a series of sprints in which project work is time boxed to a fixed number of days or weeks, usually 30 days. In lean software development, the goal is to deliver as soon as possible, permitting early feedback for the next iteration.
Both techniques stress the importan... |
I have the requirement that users should be able to specify filter conditions for one kind of entity through a GUI on a thin client. These conditions must be
convenient to generate, meaning the GUI should guide users as much as
possible. They shouldn't have to write SQL or anything.
stored with a time stamp, a user ID... |
Long story short, I've spent the last two years in an entirely new career, transitioning from academia to a data analyst role (working towards a data scientist). Before starting at my current company, I knew next to nothing about coding, save for teaching myself SQL for a few hours per week over a couple of months. Bes... |
In Code Complete page 25, it's said that it's a good idea to be able to easily replace the regular user interface classes by a command line one.
Knowing its advantages for testing, what about the problems it may bring?
Will this extra work really pay off for web and mobile projects? What about small and medium projects... |
I read several related questions about the use of GPLv3 in a commercial app but they don't say anything about a freemium app. I would like to use a GPLv3 library in two apps, a free one (with limited features) and a paid one.
Basically, the free app will allow to use the library without limitations, and the paid one wi... |
I'd like to read the opinion of experts on whether compiled, strictly-typed languages help programmers write robust code easier, having their backs, checking for type mismatches, and in general, catching flaws in compile time that otherwise would be discovered in runtime ?
Has unit testing in loosely typed, interpreted... |
Possible Duplicate:
What is a normal “functional lines of code” to “test lines of code” ratio?
I've found that more often than not, when you write lots of unit tests, and have good coverage (80% or so), the test suite ends up being larger than the code itself.
Do my observations match that of everyone else?
I've a... |
I have a project I shelved a while back- it was essentially a working web app built in django but I stopped working on it to work on something else.
I plan on starting it up again in my spare time, but I'm wondering if it's worth converting a django project with about 5kloc to Rails. I'm considering this because I've b... |
Personal context: I've been learning C++ formally the last 6 months at university. Prior to this I dabbled in JavaScript for a year. Now I am considering learning Python during a month off school.
By splitting my focus early in the learning process am I degrading the efficiency of my learning? Should I spend the month ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.