instruction stringlengths 34 19.9k |
|---|
I've been programming for a long time now, and I have always seen Model classes exactly as a business entity. For instance: sales, users, products, orders, etc...
But I have come to certain source codes (specifically in MVVM applications in WPF) where Model not only include business entities, but several other types, a... |
Suppose I have a lockfree queue in a multithreaded setting. I already provide a try_dequeue() method which allows for an optional failure (communicated via the return type) if the queue is empty.
I've found it convenient to have an always-succeeding T dequeue() method which will not return while the queue is empty. As ... |
I want to define a type class for geometric objects that can be intersected together:
class Intersect a b c | a b -> c where
intersect :: a -> b -> c
-- Language extensions: -XMultiParamTypeClasses, -XFunctionalDependencies
The idea is to have a general-purpose intersection functions that can handle objects of diffe... |
I have a target which is constantly moving, and only its current position is ever known. I also have about one hundred objects surrounding it, and for each of these only the current position is known.
I am trying to find a more efficient way to find the closest object to my target at any given moment in time. I have ... |
Is there any theoretical reason why client-side JavaScript could not be spec'd to allow for direct access to POST or PUT contents without need for a server language to write it into client-side JavaScript first?
It would seem that this, besides avoiding an unnecessary dependency on server-side code where not needed, wo... |
Background:
I am designing a server application and creating separate dll's for different subsystems. To simplify things, let's say I have two subsystems: 1) Users 2) Projects
Users's public interface has a method like:
IEnumerable<User> GetUser(int id);
And Projects's public interface has a method like:
IEnumerable... |
I am writing automated test scripts with Selenium Webdriver (Python) and I try to follow the correct programming practices, specifically the Object Oriented methodologies, where possible.
At the moment, I represent every test scenario as a single Class. That class is basically has the following structure:
Imports (Sel... |
I am developing a Web API as services layer for a ASP.NET web forms application.
There are two controllers ContractorController (gives details about the contractor) and PaymentsController (gives details about payments done to a contractor).
Now in our UI application we have this User-Control which will be used across ... |
Hi Guys,
I have a decision to make to solve a problem, I’m describing the problem below.
Application Overview
I have an ASP.NET MVC 4 webApp which uses Rest Api for almost all the tasks, from Login to CRUD on the records.
The rest api is being developed by a separate disjoint team and the webApp is being developed my m... |
I'm writing the installation code of my modular web application and I stumbled on writing the update code for the plugins.
The problem I am having is: how do you know if the plugin is already installed? Developers can give their plugin a very basic name like: "News". There will probably be more plugins with that name a... |
I will have a presentation about closures, and a non programmer friend of mine asked, what closures are. With what analogy would you describe that?
I mean "take a look at the lamba calculus" wouldn't be that nice.
|
Since machine language (e.g., 0110101000110101) computer languages have generally evolved to higher forms of abstraction, generally making it easier to understand the code when it's applied to a problem. Assembler was an abstraction over machine code, C was an abstraction over assembler, etc.
Object-oriented design see... |
I have a behavior tree with different leaf nodes that execute tasks. When building out the tree relationship in the database I need an association between the leaf node entry and the Java class that will actually perform the task execution. I've seen some examples that store the canonical name of the Java task class wi... |
I'm a developer of open source applications and publish my applications and smaller source code snippets on my personal website. I also often find and use code by others, often from blogs or small websites that just display a few lines of clever code, or offer a few source files for download. Most of the time, no licen... |
If:
I want to create an app (e.g. for a business who wants all its
employees to download the app from Google Play freely)
I do not have an "about" button in the app.
The app is closed source.
How do I handle code libraries using Apache 2.0? I guess it is a "no-go"...
(But as I have yet to come up with a good way to... |
What is considered a good practice to parse an array of objects returned by an API?
I am creating a RESTfull web service and a client which is meant to work with this service.
One of my REST services returns a JSON array in the following format:
{
"objectsArray": [
{
"PropertyA": 10,
"PropertyB": "A S... |
We are currently starting with TDD and we want to work in parallel in two programmers - one for writing test (Programmer A) and one for writing actual code (Programmer B). Problem is, how to synchronize our work.
Let's say A writes first test method, so B can start working on actual code. Our current workflow is that ... |
Let's say I have a view which should change it's content based on the user resp. on the users permission.
After some research I basically found 2 types of authorization. Role-Based and Activity-Based authorization. Now, activity-based seems pretty fine, but I don't think that is what I'm looking for. Sure, I want to au... |
A prior question had an answer that interested me from a design perspective. I work in geospatial data and occasionally have to deal with voids when I read these binary files into my product. What is the best way to deal with voids when reading them in - throw an exception when you encounter them or return immediately... |
I have been playing with the following idea: commonly when different release series (1.0.x, 1.1.x, development code) of a product are maintained in parallel one uses different branches within a version control system to develop them. In theory though one could use feature macros (written from a C/C++ point of view, bu... |
I have a list of around 2 billion distinct numbers stored in memory for some computation. Currently, every time I need to add a new entry I have to search the entire list for a potential duplicate.
I have 18 digit, 2 billion numbers to be stored in memory. Some of the numbers are repeated. So, I want to load new numbe... |
I am considering the usage of various open source libraries in a closed source Android app. The libraries are released under various licenses (MIT, BSD modern, Apache 2.0) which allow this kind of usage, but require that the copyright notice is made available verbatim with the application.
I have seen various approache... |
I am developing an application in Java whereby I would like to pass an object as part of an interface into other methods of classes written by other developers in the team. The object I'm passing in has setters and getters in the normal manner, but I don't want some of the classes written by others to access some of th... |
Some languages (such as C++ and early versions of PHP) don't support the finally part of a try ... catch ... finally construct. Is finally ever necessary? Because the code in it always runs, why wouldn't/shouldn't I just place that code after a try ... catch block without a finally clause? Why use one? (I'm looking for... |
Are n-tuples defined recursively in terms of 2-tuples, for example, are (a,b,c) and (a,(b,c)) the same?
If not, what's the rationale behind it?
|
While I was at university I developed some PHP libraries which I intended for personal use. I used them in a few personal projects.
When I joined my current job we created a commercial product which required the same functionality. I proposed using my libraries as they were familiar to me. We did.
Since then I have mod... |
In C#, with extension methods, you can replace this line of code:
TimeSpan interval = TimeSpan.FromMinutes(4);
with this one:
TimeSpan interval = 4.Minutes();
Extension method being:
public static TimeSpan Minutes(this int minutes)
{
return TimeSpan.FromMinutes(minutes);
}
The second example is interesting becau... |
I'm not sure that this is entirely on-topic, but I'll try to make it so.
I have an online service (API) and an Android application that uses it for all actions in the app. At the current moment, nothing is stored locally, so I have to depend on the API being online, and would like to warn the user when it's not (for wh... |
So, I'm building an API wrapper gem that works with Spree's Product model. The API provides extensive customization of the data you send to it. I would like a user of the gem to be able to take advantage of all the customizations should they desire to. This appears to me as if I should create a migration that adds abou... |
My current situation is that we have four instances of a single windows service running on the server, for production, demo, QA and dev. I am looking for a solution where I just need to run single instance of the service that will hit all the above mentioned databases and process the data.
I know the purpose of having ... |
I was reading R. Read's How to be a programmer, and I came accross something I didn't understand:
...even with garbage collection, you can fill up all memory with
garbage. A classic mistake is to use a hash table as a cache and
forget to remove the references in the hash table. Since the reference
remains, the r... |
I have a python library that allows me to define rules by chaining inputs and outputs of functions ( producer(grep(count( [print(),log() ] )))
This functions define a pipeline from left to right.
How could I allow users to define pipelines from a UI ?
I need to take a definition like for example "producer->grep->cou... |
I was recently discussing with some friends which of the following 2 methods is best to stub return results or calls to methods inside same class from methods inside same class.
This is a very simplified example. In reality the functions are much more complex.
Example:
public class MyClass
{
public bool FunctionA(... |
Some time ago I read a kind of "rule of thumb" about the concreteness of method parameter types, return types and property types, but I just do not remember it.
It said something about keep your return types as concrete as possible and your parameter types as abstract as possible... or vice versa.
I don't know if it wa... |
I have a web application which I want to make RESTful.
Here is the structure of the app:
Top level has a bunch of search screens, they are basically tabs which search different parts of database with different parameters.
After the search is done we display search results in a new tab, inside this tab is a table with ... |
I am starting a new project, and I want to follow the separation of concerns pattern, and I have been reading on the topic, and now I am in doubt of how I should go about this.
Here is how I thought I should go about it:
Application/Presentation Layer uses the Business Layer. Works with the entity interfaces.
The Bus... |
For example I have class ItemDownloader which has method downloadItem. This method creates instance of another class - Download to perform actual downloading.
Question is: I want to test ItemDownloader in isolation, so I will probably mock up Download. How should I do it?
P.S.: Question is more about design than implem... |
I am migrating to using the new Storage Client Library for my Azure Table Storage.
Querying with the previous Storage Client Library 1.7 namespace:
var orders = serviceContext
.CreateQuery<Order>(tableName)
.AsTableServiceQuery<Order>()
.Where(e => e.PartitionKey == pa... |
There are a lot of very smart and experienced people, who claim that if you don't write unit tests then your code will be buggy and God will kill all kittens. On other hand, another bunch of smart people will say that unittesting is counterproductive. So if you will write unittest then kittens will be damned too.
Also,... |
On my last large project, I used dependency injection really heavily. I started out using constructor injection but even two or three dependencies resulted in really ugly code.
public MyClass(
IDependency1 dependency1,
IDependency2 dependency2
IDependency3 dependency3)
I am not a fan of property injection... |
I just started building an iOS app and wanted to get some feedback regarding views.
I've got specs for
Activity Page
Activity Recording
Activity Create
Activity Save
Each of the specs show a different function, but would each of these be a brand new view in my iOS app?
|
In my iOS app, things are mostly driven by events.
The user presses a button
The app listens for an external device to be connected to the iOS device
Once the device is detected (is connected), an asynchronous call is made to a web service (to check for user authenticity)
The web service returns the user's authenticit... |
I recently came across an algorithm design problem that I'd like some help with:
Given some letters, for example a,e,o,g,z,k,l,j,w,n and a dictionary of words. Find a word in the dictionary that has most letters.
My first attempt:
Let us assume that the dictionary is in a tree. Start by finding the permutations of th... |
I have read numerous times that programming languages when making games or large software often use multiple languages / scripts together. I'm wondering how that works. How do they compile it? How does it work together?
Also, how does this work with web design also, i.e. How does one combine their HTML/CSS with their ... |
I would like to have a menu like this in surfdome. I don't mean the UI but the flexibility of this menu.
I will try to explain it.
I have some products. I want to match these products with some categories and have multiple type of menus based on these categories.
e.g. (in [] are the categories and in () are the prod... |
I am programming in PHP and I have an include file that I have to, well, include, as part of my script. The include file is 400 MB, and it contains an array of objects which are nothing more than configuration settings for a larger project. Here is an example of the contents:
$obj = new obj();
$obj->name = "myname... |
I've joined as a fresher (trainee) a software company developing for Windows Store. I don't know much about C#. My company has started Windows Store development recently. They didn't do .Net development before, that's why my company got an Senior .Net employee to complete the project.
Whenever he completes the project... |
There are plenty of questions around regarding random number generation, but I couldn't find anything that exactly matched my question. Apologies if I missed one.
Most random number generators in software tend to have flat distribution - in the given range, any number is as likely to come next as any other (more or les... |
I have a question as to the proper best practices revolving forking code.
I've taken code base licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 and brought significant changes to it to suit my needs. I feel as though my version could benefit others and wish to redistribute it.
I'm unsure what ... |
I'm working on a large project at the moment and I'm trying to document the communication protocol that sits on top of a message queue middleware.
The documentation is intended for another organisation that is going to be implementing a new back end to the client.
The messages format uses protocol buffers, so I'm less... |
Frequently, in my programming experience, I need to make a decision whether I should use float or double for my real numbers. Sometimes I go for float, sometimes I go for double, but really this feels more subjective. If I would be confronted to defend my decision, I would probably not give sound reasons.
When do you u... |
I have the following Azure Storage Table.
PositionData table:
PartitionKey: ClientID + VehicleID
RowKey: GUID
Properties: ClientID, VehicleID, DriverID, Date, GPSPosition
Each vehicle will log up to 1,000,000 entities per year per client. Each client could have thousands of vehicles. So, I decided to partition by... |
Quite recently, I thought about the use of as, is and direct cast in C#.
Logically, is it a better idea to use :
var castedValue = value as type;
if (null != castedValue)
{
// Use castedValue.
}
than :
if (value is type)
{
var castedValue = (type)value;
// Use castedValue.
}
But I still have issues ... |
I'm in the process of rewriting a small application from console mode to a GUI mode.
The input is a file with log data from a measuring device:
...
00029;00044;00076;00044;00021
00309;00032;00037;00000;65535
00013;00016;00008;00007;00005
...
Each row of data represents 5 counters which summarize the range in which the... |
I have read a few of the articles related to the Language Oriented Programming paradigm. Therefore, I concluded that LOP paradigm can let programmers be more productive because of it's extensibility.
Are there any programming languages that are already implemented LOP or in development status?
|
Is it considered a good practice to have a remote branch for each individual developer in the project?
We're using Git with the following branches:
master
release
develop
If each developer had their own branch, they could push code into their branches and others could merge these changes into their own branches.
|
I have moved to a new project and as the only 'software guy' I'm welcome, and expected, to suggest design improvements to the existing code (code just got out of prototype phase and needs extended to final releasable version; plus adding functionality)
The code has multiple stand alone components which are suppose to r... |
I need to create a web service using the .NET platform for accepting file uploads. What are the options available for doing this in C#?
What is the best approach to use? Can please you provide me with blogs/code samples/references for further reading?
|
I have some C++ knowledge and know that pointers are commonly used there, but I've started to look at PHP open source code and I never see code using references in methods.
Instead, the code always uses a return value instead of passing the reference to the variable to the method, which then changes that variable's va... |
At our company we have an existing translation ms-sql table wich stores strings like this:
Id | Key | Language | Value
1 | hello-world | nl-BE | Hallo Wereld
2 | hello-world | en-GB | Hello World
There are 3 languages in the system and I expect this to grow to a maximum of about 10 in the future
This ... |
I am in high school at the moment and soon reaching stages where I would have to make choices. To introduce, I love programming. I had started learning programming a year ago and have some experience with ActionScript3 and Java + (the web languages like html CSS JavaScript. But php I have found a bit hard to understand... |
Is it a bad practice to rely on an auto-incrementing primary key to sort rows in a table? A coworker and I were having an argument about this subject. We need to be able to find the last-inserted row in a table, and we have no create/update time columns (which might be considered a bad practice in itself, but that's a ... |
Background
This question stems out of an architectural discussion we had at work.
For the current project we are using Python and an object oriented database. There are input services that we consume, and certain interfaces that we are expected to provide output through.
Someone on our team started designing a data mod... |
I'm working in a software development area in my university, and we've noticed we need some system to track errors and bugs, who and when it is dealt with. I've researched some software management/bug tracking applications, with Redmine being the one that appeals to me the most because of its simple UI (actually I disc... |
The question is pretty self-explanatory. I've had some experience with git-flow, and not much more true experience with plain git before that. (I was using it more as a backup-provider.) I'm confused as to what consensus is, given that I can safely assume that there are a large number of git users who miss 'the good... |
So, I'm designing an MVC framework. In the name of keeping everything statically typed and non-magical, I've come to quite a problem with "automatically" passing models to a controller.
So, traditionally, I usually see no more than one model used at a time in a controller as far as automatic-population.
For instance, t... |
I am trying to develop a Delete command through BDD that will simply delete an user from the database, given user_id as a parameter. What can be some possible behavioral tests that will drive me to write a proper implementation for the command?
|
The often known as likely and unlikely macros help the compiler know whether an if is usually going to be entered or skipped. Using it results in some (rather minor) performance improvements.
I started using them recently, and I'm not sure how often should such hints be used. I currently use it with error checking ifs,... |
I'm working on a simple widget system (single window, fixed size). Each widget gets its parent (i.e. the widget containing it) passed into its constructor - except for the root widget, which I called Screen.
I have some doubts if that approach makes sense. I did it because most of the widget systems I used before do it... |
Static code analyzers like Fortify "complain" when an exception might be thrown inside a finally block, saying that Using a throw statement inside a finally block breaks the logical progression through the try-catch-finally. Normally I agree with this. But recently I've come across this code:
SomeFileWriter writer = nu... |
All over the internet, I see the following advice:
A GET should never change data on the server- use a POST request for that
What is the basis for this idea?
If I make a php service which inserts data in the database, and pass it parameters in the GET query string, why is that wrong? (I am using prepared statements... |
With pre written programs available, needing just editing, should programmers also learn writing them from scratch?
|
I have a web app that searches across 2 APIs right now. I have my own Restful web service that I call, and it does all the work on the backend to asynchronously call the 2 APIs and concatenate them into one result set for my web app to use.
I want to scale this out and add as many other APIs as I can (currently lookin... |
There's some subscription-based data processing web service - users pay via PayPal for the right to use the service. The "terms of service" document prepared by lawyers explicitly says that there're no guarantees so customers can't possibly file a lawsuit.
Now the service doesn't always work trouble-free. Sometimes the... |
I'm designing a system that is built on several small applications written in python, some of these will be services and others will be programs that only run during special situations. What I need to achieve is to let the server communicate to a service when a certain event occurs with some small amount of data. So th... |
I'm tinkering with a query abstraction over WebSQL/Phonegap Database API, and I find myself both drawn to, and doubtful of, defining a fluent API that mimics the use of natural English language grammar.
It might be easiest to explain this via examples. The following are all valid queries in my grammar, and comments exp... |
If we have a class main and the constructor of main constructs our setupclass and we put this class in a try catch in main.
Theoratically Will all errors go into catch? If they will how will it effect the performance and mantainability? Will the application be crash free?
|
I'm developing a board game that has a game class that controls the game flow, and players attached to the game class. The board is just a visual class, but the control of the movements is all by the game.
The player can try to make false movements that lead to the game telling the player that this kind of movement is ... |
This is long question I know. I have a few options for what I want. I don't want to know "this is obviously the best," but maybe any pros or cons I may be missing about the options, as well as any options I'm unaware of.
We have a java application seperately run as multuple daemons, each a seperate JVM. Right now S... |
In my job I have to maintain a poorly written codebase which is both hard to understand, has tons of comments that are just plain wrong, has a bunch of weird decisionmaking going on in it and a whole lot more.
I primarily do bugfixing which ranges from finding that little comment somewhere in the code that makes some ... |
I originally asked this on plain old stack but it was closed for being too open-ended. (Which was a good call as this is a better place for such questions.)
Original Link: https://stackoverflow.com/questions/15132135/opengl-image-load-store-atomics-applications
So, I've been spending the last couple months or so getti... |
I've been looking for get this website done for a long time.
I thought with a well organized write-up of what I wanted, as well as having clear examples done in photoshop of faux pages to give an idea of the vision, and no hidden surprises, I would be a programmer's dream job.
Unfortunately, no company will touch the w... |
This is my usecase:
Traverse a filesystem, gauge its entire size and then upload it to Dropbox.
Looks quite easy and is quite easy. Now if I do it using celery and spawn a thread for each folder(With sub files), then it becomes an easier process to gather all the data and gauge the size and then upload it to dropbox. ... |
I'm interested in transitioning my development environment onto the cloud.
I currently use VirtualBox with Vagrant to manage separate virtual machines for each individual project.
What would be the optimal setup for hosting these virtual machines in the cloud?
Given than I have nearly a dozen VMs, setting up separate ... |
Several governments are starting to publish open data: datasets generated by the goverment, made freely available for citizens to use for value-added app development, analysis, and feedback. For instance, the City of Vancouver (Canada) Open Data Catalogue publishes 130 datasets. The subject matter ranges from tabular f... |
My situation:
I have written a framework before I started my new job. I own the copyright.
It has a bunch of boilerplate logic inside of it, like any piece of software. (duh!)
I don't want to use the whole framework in my new job, but I do need to re-use some parts of it in a similar framework that I am building for m... |
As far as I know,
main ()
function has the following prototypes:
int main();
int main(int argc, char **argv);
Now, C does not support overloading, then how are multiple prototypes of
main ()
supported?
|
I plan to program web applications for small companies. When I read about ASP.NET Web Forms, I liked its way of building dynamic sites.
However, I have heard from a friend that Web Forms could increase the size of the pages because of ViewState output. Will the difference between the size of PHP pages and the generated... |
If I am taking data from a website, for example status updates from Facebook and showing them on my website. What possible damage can be caused if I am not taking into account that the code written as status update would execute on my website?
For example,
Mr. Simon has putted his status update,
"<p style="color:red;">... |
I want to make a desktop application- an analog-clock with the option of setting alarms using java. For rendering all the graphics and the button features, a Swing applet is the answer.
But the problem is that I want to run the applet onto the desktop and so need an applet viewer like thing. Applet viewer comes with th... |
My problem is quite complex to explain and my English is not excellent, so I hope you can understand my question.
In a service oriented architecture there are some modules that own data used by all the others applications end these modules expose the data via Remote Method Invocation and Web Services.
We the developers... |
I have been reading up on the seminal and excellent book Code Complete. It discusses about the various kinds of couplings that can happen between modules(which may be classes as well as methods):
Simple-data-parameter-coupling
Simple-object-coupling
Object-parameter-coupling
Semantic coupling
The book has to say this... |
Here's something from Slonneger's "Syntax and Semantics of Programming Languages":
A variable may occur both bound and free in the same lambda
expression: for example, in λx.yλy.yx the first occurrence of y is
free and the other two are bound.
I assume the free variable is the y right after the λx. and the bound ... |
I came across the analogy of the class being a cookie cutter and the cookies being objects while reading Code Complete. I fail to see why this analogy was drawn.How is it related to the concept of objects being run time instances of their classes?
|
I have the following task: developing a program where there is a block of sample text which should be typed by user. Any typos the user does during the test are registered. Basically, I can compare each typed char with the sample char based on caret index position of the input, but there is one significant flaw in s... |
Every instruction comes from main memory/RAM.
In a bootloader, at least on Intel and IBM PC firmware and designations, you
have BIOS jump to a memory address to begin fetching instructions for whatever
purpose, usually to load a kernel, when or where does the instance of a process begin?
The hardware stacks are limited... |
I've seen several different ways to design WCF services, and it seems some developers prefer parameter wrappers while others favor 'naked' parameters. To explain what I mean, consider the following service interfaces:
'Naked' Parameters
[ServiceContract]
public interface IService
{
[OperationContract]
string[] ... |
I'm looking for guidance from someone who has successfully hired a freelancer to assist with writing software they later marketed publicly. Simply, what kind of software agreement should I have the freelancer sign so I have full rights over the code and cannot be sued later. I'm currently independent but have plans to ... |
This has been bugging me for a while. Most of the time, when it comes to storing data in structures such as hashtables, programmers, books and articles insist that indexing elements in said structures by String values is considered to be bad practice.
Yet, so far, I have not found a single such source to also explain ... |
The problem
We need to store data in a table-like way, but we have very strict space constraints (~1Mb per table of 10k+ rows). We store data like this:
ID | reviews | factor | score | interval | etc.
---+---------+--------+-------+----------+-----
1 | 244 | 2.4 | 10 | 4268 | ...
in a simple binary form... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.