instruction stringlengths 34 19.9k |
|---|
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 ... |
I wonder what are the advantages of Maybe monad over exceptions? It looks like Maybe is just explicit (and rather space-consuming) way of try..catch syntax.
update Please note that I'm intentionally not mentioning Haskell.
|
I am building a Flex 4 based application using the presentation model design pattern. This application will have several different components to it as shown in the image below.
The MainView and DashboardView will always be visible and they each have corresponding presentation models and models as necessary. These view... |
How can 2 or more developers code a certain feature/module of a software? Let's assume that the module is big and feature rich. How would they prevent each other from overlapping their code? Say, we have the same method but is implemented in a different way. Do you think it might be better to have one focused at a ... |
For functions that need to index files in a directory and rename them FileName0001, FileName0002, etc... I often need to write a function that splits the file name from the file path and rename the file. When I put the file name and file path back together, I don't have a very good name for the variable that contains ... |
I was reading Code Complete regarding variable naming in trying to find an answer to this question and stumbled on a table of commonly accepted prefixes for programming word processor software. Well, I'm not a word processor software programmer, but if I was, I'd be happy to use those user defined types.
Since I'm a... |
I am implementing a controller class to manage a view. I have a file uploader class, Grabber, which could communicate in one of 2 ways:
1) Offer some kind of notification event to the controller on upload start and finish
2) Provide a property on Grabber that indicates true or false if upload has completed
I am concern... |
I have a few functions in PHP that read data from functions in a class
readUsername(int userId){
$reader = getReader();
return $reader->getname(userId);
}
readUserAddress(){
$reader = getReader();
return $reader->getaddress(userId);
}
All these make a call to
getReader()
{
require_once("Reader.php");
static $reader ... |
I have about 12 Oracle tables that represent data that's being integrated from an external system into my web application. This data is going to be used in an informational and comparative manner for the clients using my web application.
On one particular page of my web application, I need to combine data from 3 - 5 O... |
I was just wondering if a language could support something like a Retry/Fix block?
The answer to this question is probably the reason it's a bad idea or equivalent to something else, but the idea keeps popping into my head.
void F()
{
try
{
G();
}
fix(WrongNumber wn, out int x)
{
x = 1;
}
}
void G... |
Why was section 1 added to LGPLv3? My understanding of section 3&4 is, one can convey the combined work under any license and with no requirements from GPLv3 (besides those explicitly stated as requirements in LGPLv3 3&4). Given that, why is section 1 necessary. Wouldn't that sections 3&4 by themselves already imply an... |
I'm developing a web application for Windows Azure using ASP.NET MVC 4. I would like to enforce one restriction in the architecture: do not use Session.
To achieve availability on Azure, and since there is no sticky sessions, I would need to store the session data in some central service, probably either SQL Azure or ... |
I am trying to make an algorithm that counts the days between two dates, e.g. between 3/1/2012 and 3/2/2012.
What is the correct answer, or the most popular choice? Should be the one I use?
In this case, if I don't include both dates I am comparing, the days are 0; if I include one of them, the days are 1; if I inclu... |
The goal is to create an application that has objects that can represent some operations (add, subtract, etc).
All of those objects will have common functions and members, and thus will either implement an interface or inherit from an abstract class (Which would be better practice, this will be in C# if that matters?).... |
I know that exponential time algorithms should generally be avoided but are sometimes necessary. A case being the Traveling Salesman. How common are such algorithms in production software? Are these cases typically necessary or a result of rush jobs? I understand that many can be solved with a good heuristic. What is t... |
Here's an excerpt from "The C++ Programming Language"
template<classT> class List { // optimal
public:
class Link { /* ... */ };
List (); // initially empty
void put(T *); // put before current element
T* get(); // get current element
/ / ...
};
Can we make a class inside another class ?
How about other languages? For... |
Scala has been called complex with its rich feature set by many of my colleagues and some even blamed all those new features of it. While most programmers are aware of the OO-features, and at least the decent ones also know about functional programming, there is one feature in particular in Scala for which I am not awa... |
I inherited a project that I am managing and having to maintain pending the redevelopment of the code base. At the moment I am being tasked with adding little features all over the place and have gotten into the habit of returning null instead of zero in parts of the code where I am working on.
The problem is we have ... |
If we should favor composition over inheritance, the data part of it is clear, at least for me.
What I don't have a clear solution to is how overwriting methods, or simply implementing them if they are defined in a pure virtual form, should be implemented.
An obvious way is to wrap the instance representing the base-cl... |
I'm (still) working on a template-based XML editing program. It's a GUI-based XML editor that only allows users to add certain tags and attributes based off the requirements. You can see the current version here for an idea.
Now, I'd like to allow users to upload their own data templates, but I'm concerned about potent... |
Is there a metric analogous to the McCabe Complexity measure to measure how cohesive a routine is and also how loosely (or tightly) coupled the routine is to other code in the same code base?
|
Is there an advantage to piecemealing sql strings together vs conditional sql statements in SQL Server itself? I have only about 10 months of SQL experience, so I could be speaking out of pure ignorance here.
Where I work, I see people building entire queries in strings and concatenating strings together depending on c... |
I'm trying to improve my c++ coding technique by reading c++ source code. Which open source project would you recommend? Is the code of Boost C++ Libraries a good one?
|
We're trying to implement a strategy for how we transition our builds from RC to released retail code.
When we label a build as a release candidate, we send it to QA for regression. If they approve it, that RC then becomes our released retail code.
I liked the idea of "obvious" labeling of versions so that a user knows... |
I'm working on a fundamental programming class in college and our textbook is "programming logic and design" by joyce farrell(spelling?)
Anyhow, I'm struggling conceptually when it comes to initialized variables and named constants.
Our class is focusing on pseudo-code for the time being and not one particular language... |
I have an application that needs to store client data, and part of that is some data about their employer as well. Assuming that a client can only have one employer, and that the chance of people having identical employer data is slim to none, which schema would make more sense to use?
Schema 1
Client Table:
----------... |
I recently have been reading about move constructors in C++ (see e.g. here) and I am trying to understand how they work and when
I should use them.
As far as I understand, a move constructor is used to alleviate the performance problems caused by copying large objects. The wikipedia page says: "A chronic performance pr... |
This is something I did for a bus travel company a long time ago, and I was never happy with the results. I was thinking about that old project recently and thought I'd revisit that problem.
Problem:
Bus travel company has several buses with different passenger capacities (e.g. 15 50-passenger buses, 25 30-passenger bu... |
To make it more clear, this is a quick example:
class A implements Serializable { public B b; }
class B implements Serializable { public A a; }
A a = new A();
B b = new B();
a.b = b;
b.a = a;
So what happens if we serialize a and b objects into a file and deserialize from that file?
I thought we get 4 objects, 2 of ea... |
Let's say I need to add a drop shadow behind a box. Some old platforms do not support drop shadows, so I have to fake it by putting an image behind the box. Here's the pseudo code of how I'm currently handling this fallback:
if (dropShadowsAreSupported) {
box.addDropShadow("black");
} else {
box.putImageBehind... |
suppose I have a custom function such as
def greater(a, b):
if (a % b) % 2 == 0:
return 1
return 0
It defines how to compare two numbers and determine which is greater.
In this case, if the function returns 1 a > b else, a < b. Can I use inbuilt <built-in function sorted> orto create a sorted array of... |
I was writing some tests in Gherkin (using Cucumber/Specflow). I was wondering how abstract should I get with my tests.
In order to not make this open-ended, which of the following statements is better for BDD:
Given I am logged in with email admin@mycompany.com and password 12345
When I do something
Then something ha... |
I've programmed in Java for about 8 years and I know the language quite well as a developer, but my goal is to deepen my knowledge of the internals. I've taken undergraduate courses in PL design, but they were very broad academic overviews (in Scheme, IIRC).
Can someone suggest a route to start delving into the detai... |
I was talking with a colleague today. We work on code for two different projects. In my case, I'm the only person working on my code; in her case, multiple people work on the same codebase, including co-op students who come and go fairly regularly (between every 8-12 months). She said that she is liberal with her comme... |
http://php.net/manual/en/function.mb-convert-encoding.php
Say I do:
$encoded = mb_convert_encoding ($original);
That looks like simple enough. WHat I am imagining is the following
$original has a pointer to the way the string is actually encoded. Something like char * kind of thing. And then there are things like what... |
By introducing LINQ to SQL, I found myself and my .NET developer colleagues gradually moving from TSQL to C# to create queries on the database. Entity Framework made that shift almost permanent.
Now it's nearly 2 years that I use LINQ to SQL and LINQ to Entities and haven't used TSQL that much.
Yesterday, a colleague ... |
Many web sites when you registering an account present you with a form where you put in your details such as name and other profile data. One of the fields without a change is email address. It seems that there are quite a lot of web sites that double this field up. They have email address field and then re-type your e... |
I'm about to make a new Linux install, which will be primarily used for programming. I've seen benchmarks showing speed improvement of 64-bit version, however, I have hard time of telling how much these benchmarks translate to improvement in every day usage. And of course there are other aspects to consider.
Usage I ha... |
I would like to know why were annotations introduced in Spring and Hibernate? For earlier versions of both the frameworks book authors were saying that if we keep configuration in xml files then it will be easier to maintain (due to decoupling) and just by changing the xml file we can re-configure the application.
If w... |
I find that most of the design patterns are concerned with implementation of a model like mvc, or how to change the implementation with less cost. These are all happened in the implementation phase of a software. So why not call them implementation patterns?
|
I'd like to ask if someone of you knows the exact meaning of JEE.
That's because a collegue of mine was asked this question in a job interview, and was "unable to answer properly"... to speak with his interwiewer's words. And when he told me what he said to his interviewer I got really surprised, since it was more or ... |
At work I stumbled uppon a method. It made a query, and returned a String based on the result of the query, such as de ID of a customer. If the query didn't return a single customer, it'd return a null. Otherwise, it'd return a String with the ID's of them. It looked like this:
String error = getOwners();
if (error != ... |
(I was encouraged to ask this question here.)
In C, we say:
GCC compiles foo.c.
For interpreters (such as Lua), what is the equivalent verb?
The Lua interpreter ____________ foo.lua.
When I write instructions for users of my Lua script, I often say:
Run the interpreter on foo.lua.
I think this can be said more s... |
My company is building an App Engine application. The app encounters a bug (possibly due to an issue with App Engine itself, as per our research) on IE9, but it cannot be reliably reproduced and is experienced by a small percentage of users.
The workaround is to force IE9 to use IE8 mode. As a lazy front end developer ... |
Has this ever happened to you? You've got a suite of well designed, single-responsibility modules, covered by unit tests. In any higher-level function you code, you are (95% of the code) simply taking output from one module and passing it as input to the next. Then, you notice this higher-level function has turned i... |
Comparing software engineering with civil engineering, I was surprised
to observe a different way of thinking: any civil engineer knows that
if you want to build a small hut in the garden you can just get the
materials and go build it whereas if you want to build a 10-storey house
(or, e.g., something like this) you ne... |
I have some plain Views, they don't have any logic behind them (there is no action or controller behind them), their only propouse is to alert the user about something like "We have sent you an email to confirm your account", "You have no access to this resource", etc...
These views are really simple, and calling them ... |
Are there resources out there for a programmer with a large code base to have professional alalysis performed for the goal of finding the areas of most needed improvement?
Logic/Reason tells me there's a limit to what a code review question can absorb, and also that the amount of work involved is not something that sho... |
I have two huge tables on separate databases. One of them has the information of all the SMS that passed through the company's servers while the other one has the information of the actual billing of those SMS.
My job is to compare samples of both of these tables (for example, the records between 1 and 2 pm) to see if... |
The JavaBeans Specification describes a JavaBean as
A Java Bean is a reusable software component that can be manipulated visually
in a builder tool
Since the majority of the lines of code that are written seem to have nothing to do with being manipulated visually in a builder tool, why has the JavaBean specificat... |
First, I'm an entry level programmer; In fact, I'm finishing an A.S. degree with a final capstone project over the summer. In my new job, when there isn't some project for me to do (they're waiting to fill the team with more new hires), I've been given books to read and learn from while I wait - some textbooks, others... |
Rob Napier, the author of iOS 5 Programming Pushing the Limits, mentioned there are several models of selling apps on the App Store:
Write an app and sell it
Publish a free and a full version
Ad supported by third party or by iAd
In App purchase
Surprisingly, the author said that the most workable model is (1) in ter... |
Do people outside of the USA use two-part date abbreviations for the current year? For instance, representing the last day of May, you might see someone enter 5/31 into a date field.
Do international users do something similar? In a country that ordinarily uses dd/MM/yyyy would they use 31/5 or some such?
|
this is my first question on this particular stackexchange node, not sure if it's the most appropriate place for this question (if not, guidance to the appropriate node would be appreciated).
the abstract: I'm interested in modifying existing video codecs and distributing my modded codecs in such a way as to make them ... |
Is it possible to introduce scrum to a consulting environment? On any given week I might belong to 4 different teams, each with a different PM, BA and dev team (I am a designer). It doesn't seem feasible, time wise, to be able to be part of that many teams/projects as there would need to be daily stand-ups for each, sp... |
Let's say you're creating a website for a customer. This website has its own registration (either combined with OpenID or not). The customer asks you to be able to see the passwords the users are choosing, given that the users will probably be using the same password on every website.
In general, I say:
either that it... |
I have a .NET project at work that provides a couple of (Iron)Python scripts to the customers, to allow them to customize the output of the program. The application generates code for certain machines, and supports a couple of different formats.
Until recently, we only provided a script for one format. We're expanding... |
Background:
I'm currently part of a team of four: 1 manager, 1 senior developer and 2 developers. We do a range of bespoke in-house systems / projects (e.g. 6-8 weeks) for an organisation of around 3500 staff, as well as all the maintenance and support required from the systems that have been created before. There is n... |
UTF8?
UTF16?
Do strings in PHP also keep track of the encoding used?
Let's look at this script for example. Say I run:
$original = "शक्नोम्यत्तुम्";
What actually happens?
Obviously I think $original will not contain just 7 characters. Those glyphs must each be represented by several bytes there.
Then I do:
$converted... |
Hi I am a beginner web developer and am trying to build the interface of a simple e-commerce site as a personal project.The site has multiple pages with checkboxes. When someone checks an element, it retrieves the price of the element and stores it in a variable. But when I go to the next page and click on new checkbox... |
When I first started at my current job, my purpose was to rewrite a massive excel-VBA workbook-application to C# Winforms because it was thought that the new C# app will fix all existing problems and have all the new features for a perfect world.
If it were a direct port, in theory it would be easy as i just need to go... |
I have:
ten numbers: +1, +2, +4, +8, +16, +32, +64, +128, +256, +512.
flag == sum of some of this ten numbers.
How to determine that sum contains 2 or 32?
|
I have been programming for last 15 years with non-CS degree. Main reason I got into programming was that I liked to learn new things and apply them to my work. And I was able to find and fix programming errors and their causes faster than others. But I never find myself a a guru or an expert, maybe due to my non-CS ma... |
Recently, I read a lot of good articles about how to do good encapsulation. And when I say "good encapsulation", I am not talking about hiding private fields with public properties; I am talking about preventing users of your API from doing wrong things.
Here are two good articles about this subject:
http://blog.ploeh.... |
I'm learning OpenGL with C and that makes me include the windows.h file in my project. I'd like to look at some more specific windows functions and I wonder if you can cite some good sources for learning the basics of Win32 and Win64 programming in C (or C++).
I use MS Visual C++ and I prefer to stick with C even thoug... |
I suppose the class have several different interfaces. Some it shows to some class, some it shows to other classes.
Are there any good reason for that?
One thing I can think of is with one .h per class, interface would either be public or private.
What about if I want some interface to be available to some friends' cla... |
I write Linux embedded software which closely integrates with hardware.
My modules are such as :
-CMOS video input with kernel driver (v4l2)
-Hardware h264/mpeg4 encoders (texas instuments)
-Audio Capture/Playback (alsa)
-Network IO
I'd like to have automated testing for those functionalities, such as integration testi... |
For many programming quizzes we are given a bunch of input lines and we have to process each input , do some computation and output the result.
My question is what is the best way to optimize the runtime of the solution ?
Read all input, store it (in array or something) ,compute result for all of them, finally output ... |
I am starting to develop a WCF API, which should serve some specific clients.
We don't know which devices will be using the API so I thought that using a RESTful API will be the most flexible choice.
All devices using the API would be authenticated using an SSL certificate (client side certificate), and our API will ha... |
In my project I am creating an abstraction layer for some APIs. The purpose of the layer is to make multi-platform easier, and also to simplify the APIs to the feature set that I need while also providing some functionality, the implementation of which will be unique to each platform.
At the moment, I have implemented ... |
I am going to implement a repository, and I would like to use the UOW pattern since the consumer of the repository could do several operations, and I want to commit them at once.
After read several articles about the matter, I still don't get how to relate this two elements, depending on the article it is being done in... |
Years ago, I was surprised when I discovered that Intel sells Visual Studio compatible compilers. I tried it in particular for C/C++ as well as fantastic diagnostic tools. But the code was simply not that computationally intensive to notice the difference. The only impression was: did Intel really do it for me just now... |
Let's say you have a Master Database and a few External/Internal applications that use WebServices to interface data.
What would be your preferred architecture to interface data from and to those applications? Would you put some sort of Enterprise Service Bus in between? Like BizTalk? Or something cheaper?
We don't wa... |
According to blog post by RetroDreamer Android developers have to pay sales taxes for their App sales in countries with have sales taxes while Apple developers don't as Apple pays the taxes directly.
Is this an accurate description? Is so, how do the various people who publish Android apps handle it?
|
After almost 8 months being in ios programming, I am again confused about the right approach. Maybe it is not the language but some OOP principle I am confused about. I don't know..
I was trying C# a few years back. There were fields (private variables, private data in an object), there were getters and setters (method... |
The nature of my job is that I have to switch back and forth between projects every few weeks. I find that one of the biggest impediments to my productivity is the ramp-up time to getting all the relevant pieces of code "back in my head" again after not seeing it for a period. This happens to a smaller and larger exten... |
I have a general coding standard question. Is it bad practice to initialize and create an object in multiple methods depending on the outcome of a users choice. So for example if the user quits a poker game, create the poker hand with the cards the user has received, even if < 5, and if the user played till the end cre... |
Is there a language where collections can be used as objects without altering the behavior?
As an example, first, imagine those functions work:
function capitalize(str)
//suppose this *modifies* a string object capitalizing it
function greet(person):
print("Hello, " + person)
capitalize("pedro")
>> "Pedro"
g... |
There are some opensource projects, that have classes and classes without any significant explanation about what the class does and or why is that class needed. For example, classes in the CppEditor plugin for QtCreator. What are the best practices to read undocumented code? Don't read it, is not an option :)
|
Is it possible define methods from the same class in different "CPP" files?
I have header file "myClass.h" with:
class myClass
{
public:
// methods for counting
...
// methods for other
...
};
I would like to define "methods for counting" in one CPP and "methods for other" in other CPP. For clarity.
B... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.