instruction stringlengths 34 19.9k |
|---|
Lately I've been trying to split long methods into several short ones.
For example: I have a process_url() function which splits URLs into components and then assigns them to some objects via their methods. Instead of implementing all this in one function, I only prepare the URL for splitting in process_url(), and then... |
My question is about how to put code review into practice in a workplace where nobody else has asked for it, I've never done it before, and I'm not entirely sure if it's worthwhile for this type of programming.
I'm a contractor on an assignment that mostly involves tools engineering, data analysis, fixing code when som... |
Looking at two of our entities Company and Address. A company has a billingAddress and a profileAddress.
I'm unsure of how to implement a function to set the billing address versus the profile. Here are the options I can see:
Create a new address using a POST to /address. Update the company object at /company with pro... |
Let's say an application I'm writing requires a password for something but I don't want that password to be saved in version control (so no hard-coding the password). What I've been doing is creating a file called PASSWORD which is read in once by the application and ignored by version control. Is there a more preferen... |
I'm not quite sure if this is a question for programmers.se rather than stackoverflow, but here goes. So Facebook [or any other large company] when given something like an apostrophe or html, can strip it of its malicious intent, but still display it properly. My current sanitizing function in PHP just strips those c... |
As any taught Software Engineer knows how important Documentation for good software projects is. Could you show me best practices for assure good documentation beside of JavaDoc comments?
In my opinion the documentation should not only contain javadoc comments to assure good human readable text for future and present p... |
I am in a position where I have been asked to review some code that fixes a problem that I don't believe exists.
The fixer, who is more senior than me, insists his fix is necessary but it appears to be no more than C++ sophistry to me. Part of our deployment process is a code review, and as the 2nd highest engineer ... |
I'm experiencing a strange behavior with Atmosphere + Long Polling.
I'd like to have a broadcaster per user, so I have registered a broadcaster on resource suspension with id : /user/.
I use Atmosphere on a clustered environnement, so I have configured to use an external broadcaster that use Hazelcast. (No chance for ... |
I have started a project which will duplicate Dropbox or Google Drive behavior but using Amazon S3 az a backend.
Idea is very simple, a Node.js server that watchs a directory for file changes and PUT them on the S3. Or it will look at S3 for changes and applies them to file system structure. I'be uploaded very early ve... |
During the current (2013) Google Code Jam contest, there was a problem that took C++ and Java people 200+ lines of code as compared to Python people that solved the same problem only using 40 lines of code.
Python is not directly comparable with C++ and Java but the difference in verbosity I thought might perhaps have ... |
Dynamic typing newbie here, hoping for some wizened words of wisdom.
I'm curious if there is a set of best practices out there for dealing with function arguments (and let's be honest, variables in general) in dynamically typed languages such as Javascript. The issue I often run into is with regards to readability of c... |
Relevant Background Details
We've got two types of VMs (Utility Boxes & Web Servers) that developers need.
We are going to be using git for version control.
We have developers who have different preferences for their working environment (e.g. Some Linux, Some Windows).
I'm in the Linux camp and I believe Git and Wind... |
Creating an HTML5 page using canvas and javascript to draw a set number of musical staves on the page, spaced a pre-determined amount in between.
What I have is re-drawn on top of the canvas 10 times, and what I really need is something that's spaced out apart every time the loop is drawn.
I tried to create a JSFiddle... |
I'm building a website for a small store and I was told that its better not to keep the login and the rest of the users information in the same table.
Now im wondering, what is the best way to implement this website's database?
Some of the database tables are:
Customers
Providers
Products
Etc..
I need to have differe... |
...Provider
...Searcher
...Resolver
...Builder
...Manager
...Importer
...Descriptor
...Helper
...Indexer
Is it a global convention to refer a thing with "..ers" or "..ors". In contrast, a "thing" that composes with behaviors (habits) or attributes (properties) doesn't go with such naming convention.
It is fun to thin... |
I am working with A* algorithm, in which I have a 2D grid and given two points, find the shortest distance between them, while not running into any obstruction.
Now, for each cell, I find the distance from the source, and calculate the distance from destination. Add the two quantities, and the one that has the minimum ... |
I'm writing a Web Service that will be consumed by a Mobile client.
The Mobile client has to make several chained requirements checks to determine whether the user may initiate a request, and if so what type. If any of the checks fail then the user is redirected to a UI explaining why.
I can't decide whether I should ... |
I've just learned that .NET 4.5 introduced a change to how exceptions inside a Task are handled. Namely, they are quietly suppressed.
The official reasoning for why this was done appears to be "we wanted to be more friendly to inexperienced developers":
In .NET 4.5, Tasks have significantly more prominence than they d... |
I'm curious if there are any commonly used large enterprise frameworks for PHP that would be your whole or most of your environment if you were working in PHP. Something comparable to ASP.NET's WebForms or MVC in that when you're working in either one, most of your code and system is based off of working integratively ... |
We have a site that launched and is "feature-complete", we've done all that the client has asked for and fixed a few bugs post-launch. However, I noticed that our site's home page is using 100 SQL queries, and there's no caching. I took half a day to add caching and did it in a branch.
Now I'm wondering how I can convi... |
I came across this example recently:
If 999 times out of 1,000 an exception will not be thrown then the exception is only generated once. On the other hand a conditional would have been called needlessly 999 times, therefore in this case the exception is superior.
In this instance it's C#, but generally speaking is t... |
Reading the comments to this answer, specifically:
Just because you can't write a test doesn't mean it's not broken. Undefined behaviour which usually happens to work as expected (C and C++ are full of that), race conditions, potential reordering due to a weak memory model... – CodesInChaos 7 hours ago
@CodesInChaos... |
Is having mutable local variables in a function that are only used internally, (e.g. the function has no side effects, at least not intentionally) still considered "non functional"?
e.g. in the "Functional programming with Scala" course style check considers any var usage as bad
My question, if the function has no side... |
Lets says I have a Carclass:
public class Car
{
public string Engine { get; set; }
public string Seat { get; set; }
public string Tires { get; set; }
}
Lets say we're making a system about a parking lot, I'm going to use a lot of the Car class, so we make a CarCollection class, it may has a few aditionals ... |
I am working on software for some scientific instrumentation. An embedded computer running Windows 7 is inside the instrument, which controls various components of the device; cameras, motors, thermometers, etc. I've written a basic interface in WPF/C# and use remote desktop to test the application. (Reason is safety, ... |
Say I have the following graph of dependencies between procedures/functions/methods:
o
/ \
v e
/ \ / \
r f l w
That is, function o first calls function v, and then function e. Function v itself first calls function r, and then function f. Function e itself first calls function l, and the... |
I am looking at a codebase where a developer never uses SQL transactions i.e. each update/insert into the SQL database is an atomic operation.
I believe the codebase would benefit from transactions. I was looking online today and in one Stackoverflow question an answerer says: "In some situations it is better to have ... |
I am working on a Arduino project using the Uno. The project contains a significant amount of code. I would like to create a library and I may even share it later on. What guidelines should I follow while designing the library?
|
We want to start collecting timezones for each of our addresses in the database. What is the best practice to store the timezones? How would you go about acquiring timezones for the existing address records?
I'm using Microsoft SQL server, .net mvc, C#. Any suggestions would be greatly appreciated.
|
In a library I am developing I have a factory method that looks a bit like:
public <T> T instantiate(Type targetType) {
return ...;
}
I am using a type parameterized method to avoid that users of my library have to cast every time they invoke it (that would be the case if I would have chosen to return Object).
Is ... |
I'm building a file storage programme that will also display images in photo galleries to users who upload them. I was wondering if anybody could help me out.
My plan was if an image was wider than 500px then I would resize it to 500px (gallery and mobile use) width and 250px (thumbnail use) width
I have no serious exp... |
I'm having hard times transforming a math formula to code. I can solve it on the paper easily, but it's hard for me to bring it into code form. Is it generally possible to bring a math formula directly into a program, or, if not, how can it be transferred?
Taking, for example, the Pythagorean Theorem: a² + b² = c². Hav... |
If I want to make a card game app or android, could I legally borrow parts of the Apache-2.0-licensed Solitaire-for-Android? Would I be able to charge such a project? (I was unable to understand the legal jargon in the license here.)
|
What's the best approach to creating documentation (displaying the function prototype if you will) for functions that take a variety of different forms in terms of parameters.
Let's say there are 10 different choices:
param(name);
param(name, type);
param(name, options);
param(name, type, options);
param(name, fn);
par... |
I am currently trying to break through the intermediate coder stage to advanced and needless to say it's been tough.
I have been working through several books with example code. I have felt lately that taking the example code, changing it to fit my own similar project, breaking it, and fixing it, is more effective for... |
This is one of the questions given to us an assignment and I've tried to search for this on the internet but didn't get the required answers. Would be great if examples are provided too :)
|
I am currently acquiring my associates degree in software engineering. I have been told in order to be successful in a computer science field you have to specialized in something. After researching several areas I have decided I want to specialize in Java Database Connectivity. It earns a decent income and seems intere... |
I've collected a bunch of interview questions like "Describe how you would design a photo album application", "Describe how you would design this particular feature of this particular website" (e.g. likes on Facebook, recommendation on Amazon, shopping cart, game of black jack). Then, what if there are millions of this... |
I am looking for a way to control large amounts of JavaScript code in a ASP.Net MVC web application.
I have been looking at Ember.js and whilst it's pretty compelling it takes control of the routing and as such treats the server as little more than a place from which to receive API calls. This isn't really useful for w... |
I am currently working on a C# ASP.Net 3.5 website I wrote some years ago which consists of a "main" public site, and a sub-site which is our customer management application, using forms-based authentication. The sub-site is set up as a virtual folder in IIS and though it's a subfolder of "main", it functions as a sepa... |
To make things simple to explain: I've got two tables: Table1 and Countries.
The Countries table contains a nice flag and some information, such as DisplayName, the ISO3166 ALPHA3 code and the phone code (+49, +xx).
Table1 contains customers with a column Country.
Is it (in terms of usability, normalization and common ... |
So I am working on a small Project at my company, I am a mere trainee engineer (halfway through a Software Engineering degree), where we are developing an intranet - based project management and people management system - it incorporates Employee appraisals, personal skill management and development and so on.
Ive been... |
Many projects on Github comprise a LICENSE file, usually looking like:
Copyright (C) 2012-2013 Mr. Creator
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without li... |
I'm in a team where I am the only Java developer. The rest of the team are VERY experienced in their own programming language, but their area of expertise is not object orientated.
I found the first time that I had a code review, it was a lengthy process that involved a lot of tangents about how Java works, or how OOP... |
I am going to write an application that reads data from a csv file, and display that data to the user. I intend to apply an MVC design pattern to create this application. A user will interact with this application through a console. Hence the view is a console.
There will be a Main.java that is responsible for :
Pre... |
I'm currently refactoring a part of a large codebase with no unit tests whatsoever. I tried to refactor code the brute way, i.e. by trying to guess what the code is doing and what changes wouldn't change it meaning, but without success: it randomly breaks features all around the codebase.
Note that refactoring includes... |
I don't hate using assembly language, since I have written some in my os course. But obviously, assembly language lacks abstraction, you have to pay more attention to the details.
Is assembly language really essential to write TAOCP?
|
I'm trying to figure out a way to capture the system audio of an Android and/or Windows Phone. The idea is to provide a stream based on the music I'm currently playing on my phone.
What I'm not sure about is what the best approach would be for sending the audio. Preferably I'd like to capture all the device audio (same... |
I know, I know -- it isn't possible presently but my question is this:
Would it be possible to write a browser plug in for the major browsers that enables true, multi-threaded JavaScript?
It just seems like this would be possible and, if so, it would take the web (not to mention JavaScript) to new heights.
|
My organization is moving to Agile process of software development. As part of it, the developers and quality engineers will sit together with the cubicle walls scaled down.
I am just wondering how does it satisfy one of the Joel's test - programmers should have quiet working conditions.
Does it not contradict it? If ... |
A person I met recently had an argument. It was that a programming language had to be compiled to be considered a programming language. This would make HTML/CSS (unless you're using SCSS or LESS) not a programming language. So, does it have to be compiled?
|
Let's say I am selling hardware that uses the linux kernel. Do I have to state somewhere that it is running linux(or other gpl code)?
The reason I am asking this is because I bought a television, which I found out is running linux. It doesn't say anywhere it is running linux, which seems to me a violation of gpl. If th... |
Explanation
First let me briefly define how I'm using terms (I might be bending their typical use a little):
When I talk about semantic breaking changes, I'm referring to a change in the meaning/behavior of a public API. It may require changes to consumer code, but it isn't immediately obvious, since nothing 'broke'. C... |
We're developing a site where individuals (store owners) will be able to take pictures and upload to the site. Our biggest concern is the variance in quality of pictures across the site.
The options we are considering are:
Minimum image cleaning scripts (including filters, resizing, sharpening, etc.)
Approval process... |
With advent of WPF and MVVM Microsoft introduced DependencyProperties and INotifyPropertyChange interface to provide a way to implement the "reactive" approach used with those technologies.
Sadly both of these constructs are very verbose, require much boilerplate, are clumsy to use, also are not really that safe since ... |
I'm wanting to get an assembly book to learn assembly, and was wandering if i get a book for intel x86 processor will there be any problems assembling the code on an amd processor?
|
I have a model called Car and depending on what type of Car the user select the view is presented differently. For example the user selects from a grid of different cars and depending if it is a Volvo or a Kia or a Ford the view must allow different fields to be editable. For example with a Volvo the color is editable ... |
It's pretty easy to track when we fix security vulnerabilities in existing code. But to make sure the whole team is staying on their toes about writing secure code, I'd like to also track how well we are preventing and avoiding writing new security vulnerabilities. What is the right way to measure that?
|
I faced a question in a .NET interview.
As a client i need a LoggingAPI. How you go the approach of design and development and delivering Logging API to the client? I don't care about WPF or a language specific. I want a LoggingAPI which has to log some data? what is your approach in delivering the same.
I failed to an... |
In this MSDN Magazine article Peter Vogel describes Extension Objects pattern.
What is not clear is whether extensions can be later implemented by client code residing in a separate assembly.
And if so how in this case can extension get access to private members of the object being extended?
I quite often need to set d... |
Well this has been a question I have puzzled about for a long time:
Suppose I have a dictionary of input:output like:
This
{2: 6,
5: 15,
20: 60,
26: 78,
...
982: 2946,
997: 2991}
where output = input*3.
or This
{0: 5,
3: 8,
17: 22,
19: 24,
...
991: 996,
996: 1001}
where output = input+5
or something els... |
I am developing a commercial application. There are several programs under GPL which have some common features with my planned applications.
Can I take ideas from those applications under GPL and implement them myself without copying the code?
Would this violate the GPL?
|
Apologies for the long post...
Where I work we have a system with many subsystems which are located in different locations. All the subsystems process some data and write the result on A database. In case any other subsystem needs the output f other subsystems it gets connected to the database and read from it. And tha... |
I apologise in advance if this question is too subjective but I'm struggling to find a good answer, probably as there is not really a correct answer to give.
I'm currently writing a database abstraction layer to unify the use of a single API throughout my applications. Possibly re-inventing the wheel but I'm mainly doi... |
I want to use a dictionary (basically a text file, and no code) that is included with an open office spell checking plug-in. The plug-in is under the tri-license GPL/LGPL/MPL which I don't understand. is that legal?
If it is illegal, what if I wrote a script that uses the said open office plug-in to generate the dictio... |
I see myself using more and more immutable types when the instances of the class are not expected to be changed. It requires more work (see example below), but makes it easier to use the types in a multithreaded environment.
At the same time, I rarely see immutable types in other applications, even when mutability woul... |
I'm writing a program to automatically make the draw for a competition. There are four objects: Debate Judge School Team Each Debate has two teams and a judge. Each team participates in three debates.
With this, there are the following rules: 1) A team cannot face someone from their same school 2) A team cannot face a... |
I've read it at many places that unit tests should be independent. In my case I have a class that does data transformation. These steps must be done sequentially, otherwise they don't make sense. For example,
load_data
parse_float
label
normalize
add_bias
save_data
For example, I cannot normalize the data before I lab... |
I'm writing an application that deals with the network and the hard drive. For the network portion, the application measures in bits per second, while the disk portion measures in bytes per second. This becomes an issue as they both are abbreviated b/s or bps everywhere I've seen. How could I inform the user that one m... |
I am building an application which, at the moment, consists of many small Python scripts.
Each Python script processes items from one Amazon SQS queue. Emails come into an initial queue and are processed by a script, and typically the script will do a small unit of processing (for example, parse email and store some da... |
I've read about the "hypervisor" in hardware virtualization. VMs are not my area, so I can't quite see where the term came from.
THe wikipedia article talks about how "the hardware's supervisor state was virtualized as well, allowing multiple operating systems to run concurrently in separate virtual machine contexts"
... |
As from March 2013, Microsoft allows Adobe Flash content to play by default on its immersive Internet Explorer 10: http://redmondmag.com/articles/2013/03/11/new-ie-10-flash-policy.aspx
When asked about Silverlight, Microsoft says
Silverlight will not be supported in immersive Internet Explorer 10 since these capabili... |
I'm a bit confused if saving the information to session code below, belongs in the controller action as shown below or should it be part of my Model?
I would add that I have other controller methods that will read this session value later.
public ActionResult AddFriend(FriendsContext viewModel)
{
if (!Mode... |
I am a student and a freelance programmer. These days I am developing a software in VB6 which has recently crossed 100KB of source code.
The main problem, I face is, many times I have to refactor my existing source code which is really very boring. Also the size of my code base is not very big (only 100KB).
What are th... |
The consensus seems to be that one should follow the convention of the platform they're developing for. See:
Underscore or camelcase?
Naming conventions: camelCase versus underscore_case?
However, PHP doesn't seem to strictly follow any convention internally (no surprises there), even for methods and functions (e.g. my... |
Our product registers new players on our service, and we've chosen to host it on Azure (we're using .NET) and we wanted it to be stateless (for scalability) and relatively secure.
Since this is the first REST WS I'm writing, I wanted to get some feedback on whether or not it's a solid solution.
Some presumptions to kno... |
I need to build a web service API for our mobile app to interact with our server & database (in ASP.Net MVC 4, but that's hardly relevant). Wile most actions do not need users to be registered with our service, we would like to restrict access only to users of our app.
What are the methods to make sure that calls made... |
The question is - what is an effective way to deliver files to users? Consider an asp.net application which gives an ability to view various files. A kind of image library or web file directory. Key points are:
user can upload arbitrary files of size <= 10Mb
files are stored on disk
files never change
user can remove ... |
I have seen many answers in SO regarding using Google's CDN to load jQuery instead of
loading it from the local server. In essence I understand this is the issue related with decreased latency, better caching. But I want to know the technical answer, perhaps an example mentioning why it is even an issue to just load a... |
I'm looking to write a program that will generate valid sudoku puzzles. Essentially, a sudoku puzzle is just an 81 digit number. (The blanks are zeroes.) I would then like to use these puzzles in an Android app.
Is there any risk to using randomly generated puzzles in an app? If another app has the same puzzle, am I... |
I'm a CS student and I have been coding for a few months shy of a year now, and I seem to have developed what I think may be a "bad" habit and I'm wondering if anyone does the same (or whether it's a bad habit at all). When I'm coding / solving a problem with code, I find that my initial implementation is lengthy and o... |
We have a project that keeps recurring. The client expects us to run a website twice a year and this is happened for the last year and a half. I took the last working copy and based our latest website on it. Now, a co-worker has suggested that next time we should start from scratch instead of fighting against legacy co... |
Let's say I have a set of items {e1, e2, ..., en}, and I also have a set of constraints {c1, c2, ..., cm}, with ci := ej appears before ek, for some j and k.
I want to produce an ordering of my items which maximizes the number of satisfied constraints, with the possibility that some of the constraints are contradictory... |
i am working on a project consisting of sending and receiving streaming multimedia.So,i have installed JMF, but i have seen that JMF has 32 bit library as mine is 64 bit so i wanted to use Xuggler for streaming videos.
Can anyone clarify me about the support of Java Media FrameWork with Xuggler..
|
I was looking through some Objective C docs.. and got this :
UIGraphicsBeginImageContext : Creates a bitmap-based graphics context
and makes it the current context.
Also, the same term is used in Robotlegs :
(http://www.adobe.com/devnet/actionscript/articles/intro-robotlegs-pt1.html)
Context: Context is the boo... |
I need to implement some graph partitioning algorithms for my thesis. I have mostly Windows experience. I would like to know if it is hard to migrate c++ console program to Linux. I want to program it on Windows but I want to test and compile it on Linux as well. It will be pure cli application, with no use of windows ... |
I'm writing an InputStream that processes data streams containing "trailer" data. That is, the final n bytes of the stream is a piece of data that must be handled separately and shouldn't be returned from the read methods.
My class will maintain an internal byte array of length n and read data into this byte array fro... |
So I'm planning to use APIs for my host app. But the APIs are built such that it requires a sessionkey for every request.
So my question is, how would I dogfood my API? Cause, apparently I'm thinking in the line of creating a "special" key for my host app (cause it makes no sense to request for a key for my own use), b... |
I have a fairly new C# application, approximately 6 months old, that we are now trying to incorporate testing into. (Should have been done from the start but I can't change the past)
Parts of this application involve pushing some documents out to a folder. A third party application then picks these up, does its own wor... |
I have a large module which have to process more than 10k request/ response per second.
Every request has a json and need to process it and verify it on the database and generate the response on the basis of the db query.
Here is an example
Function 1
function ('/get' , fucntion (req1 , res1 , next ){
//to proce... |
Now, when I make a programming mistake with pointers in C, I get a nice segmentation fault, my program crashes and the debugger can even tell me where it went wrong.
How did they do that in the time when memory protection wasn't available? I can see a DOS programmer fiddling away and crashing the entire OS when he made... |
We are currently designing a REST API to access classical customer data.
One of the elements in the API are the assets of an user. The assets are added under a given service. The backend API will only add an asset to an user under a given service. So, there's no User--Asset relation, but a User--[Service]--Asset rela... |
Preamble
My aim is to create reusable code for multiple projects (and also publish it on github) to manage subscriptions. I know about stripe and recurring billing providers, but that's not what this module is aiming for. It should just be a wrapper/helper for calculating account balance, easy notifications to renew a ... |
I am trying to broaden my understanding of the history and development of object-oriented programming, and I am curious to find out
if C was designed to facilitate Object-Oriented programming? (like C++ and Objective-C definitely are) or if it was, on the contrary, simply just a clever exploitation of the language's c... |
The problem
Let's say I have a class called DataSource which provides a ReadData method (and maybe others, but let's keep things simple) to read data from an .mdb file:
var source = new DataSource("myFile.mdb");
var data = source.ReadData();
A few years later, I decide that I want to be able to support .xml files in a... |
I have a number of objects storing state. There are essentially two types of fields. The ones that uniquely define what the object is (what node, what edge etc), and the others that store state describing how these things are connected (this node is connected to these edges, this edge is part of these paths) etc. My... |
In this blog post about acceptance criteria the author explains that good acceptance criteria should:
State an intent not a solution (e.g. “The user can choose an account”
rather than “The user can select the account from a drop-down”)
Are independent of implementation (ideally the phrasing would be the
same regardles... |
I'm looking to refactor an existing design; to move a bunch of stuff out of a database and into memory where it should be (There are many reasons the DB approch is dangerous as it is now). My first act was to take all the existing objects and expand more state to them. The previous objects new only their parents, and... |
If you had a manager, a couple of levels above you, tell you that building software is like building a bridge, how would you respond to that?
If this manager truly believes that we should be able to accurately estimate and build a system, what good metaphors are out there to explain why this isn't the case?
|
I'm going to develop a fairly basic re-usable blog component, with simple CRUD operations using ASP.Net.
Which method of storing blog posts would be best suited to the situation in terms of performance/maintainability?
Create an XML file and store data in filesystem, filesize will not likely be any more than 50kb in s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.