instruction stringlengths 34 19.9k |
|---|
If I want to program in a "functional" style, with what would I replace an interface?
interface IFace
{
string Name { get; set; }
int Id { get; }
}
class Foo : IFace { ... }
Maybe a Tuple<>?
Tuple<Func<string> /*get_Name*/, Action<String> /*set_Name*/, Func<int> /*get_Id*/> Foo;
The only reason I'm using an int... |
I recently finished this book called The Elements of Computing Systems where you build a working computer system from the ground up, starting from basic logic gates, to creating your own machine code and Assembly language, to intermediate code, and finally a simple object-oriented programming language that compiles dow... |
I tried doing a Google search, as well as searching this Stack Exchange site but could not find a question relating directly to this.
The PEP 8 -- Style Guide for Python Code has lots of good style recommendations, however I don't think they mention anything about whether a space between a minus or negative sign (-) an... |
In C++ I was told that my classes shouldn't have getters and setters: Doing it wrong... blog post.
On the other hand, in Objective-C, the direct use of ivar is discouraged, because the getters allow to do lazy instantiation, and setters make KVO easy.
Why is that difference?
|
Our teams is having the following discussion:
Let's say we have the following two methods:
public Response Withdraw(int clubId, int terminalId,int cardId, string invoice, decimal amount);
public Response Withdraw(Club club, Terminal terminal,Card card, string invoice, decimal amount);
whats sent over-the-wire are jus... |
My team and I took over a medium sized codebase over a year ago when the previous tech lead left the company. Originating from the lack of man power I fear we favored pragmatic solutions over best practices a little too much.
Now, I have to deal with a constant decline in code quality and some kind of organic growth of... |
I understand that computers are basically a complex system of electrical signatures that can calculate based on logic boards, and some sort of gate mechanism, but how do computers process something like if the number produced by the keyboard is less than 10, or if a mouse is clicked two times in a certain amount of tim... |
I have designed a RESTful API and I am now working on creating a web application to use the service.
One thing I am struggling with is how to manage alerts in the web application (similar to the alerts stackoverflow gives in your profile for a new answer, response etc).
Basically the web application is a workflow betwe... |
I am developing an application which will need to store inline, intext metadata. What I mean by that is the following: let's say we have a long text, and we want to store some metadata connected with a specific word, or sentence of the text.
What would be the best way to store this information?
My first thought was to ... |
I know the idea of strong cohesion applies to methods as much it applies to classes. Just to be clear when I say strong cohesion of a method I mean a method which does only one task and does it well. This idea really works for simple getters and setters. But sometimes we usually come across methods that does more than ... |
I read from the seminal Code Complete book that method statements that require to be executed in order passing parameter from one to the next is a code smell and is an example of a sequential cohesion. Why is this not a good idea?
A contrived example of a sequential cohesion:
public Part createPart(input) {
Pa... |
I have been working on an application alone for several years.
I am now asked to transfer knowledge to a few other developers, which I think is a good idea because it will allow us to share the workload.
The problem is that I have never been involved in such a process. My manager is asking what I need to facilitate th... |
I'm new to the opensource world. The project I'm working on resides on Github. (Just for reference) The project I'm working on is a plug-in for the Plex Media Server. I plan to submit my plug-in to Plex so that it will be included in their "app store". Now to my question.
When I first started out, I found an older sem... |
I'm a Ruby on Rails developer. I'd like to create a web application. I will let users get a payed subscription to use the product. So I will need a recurring billing system (e.g. via paypal).
But there is the fear to fail and make some bad mistakes, because I will handle money from other people.... regardless followin... |
My project team is making a site that will use reddit style voting to track users' opinions on various issues, and use the data to create a "heat map". I say heat map in quotes because I'm not sure that it's the correct term - I don't have the math to express it properly.
The idea is you'll be able to see, on a 2 dim... |
I was wondering what that term even meant. Is it something to do with one's amount of knowledge about the Ruby language or just the plain idea of using it. When can one call themselves a "Rubyist"?
|
When offering to create a profile (for example, login+pwd) for a web service, what are the best practices one should implement to avoid mass spamming/creation of fake profiles? I am thinking about email confirmation, captchas, etc... any other ideas that work in practice?
|
I'm trying to figure out a good practice for designing a function with (many) optional components.
For a specific example, say I am interested in designing a feature extractor function that takes as input a document and returns a list of features extracted from the document.
Question
If there are many optional componen... |
I'm really struggling to write effective unit tests for a large Django project. I have reasonably good test coverage, but I've come to realize that the tests I've been writing are definitely integration/acceptance tests, not unit tests at all, and I have critical portions of my application that are not being tested ef... |
Most issue tracking systems have only single status field.
Typical Status: New -> Fixed
When code is pushed to repository with commit message "Fixed issue #1234", the issue #1234 is automatically mark as "Fixed".
I have the below idea but no system can fulfill.
The question is: Am I right or just not finding the suita... |
I recently asked a question on StackOverflow that was related to string splitting and pattern matching in .NET.
Some beady eyed developers that viewed the question said: "It looks like you're trying to parse a JSON string...why don't you just use JSON.NET or JavaScriptSerializer".
The conversation went off at on a tan... |
Here's a common scenario for developers who want to integrate static analysis in their workflow. Any suggestions on how to get this working with a minimum of pain?
The situation is similar to the one discussed here:
http://enterprise-it-solutions.blogspot.dk/2011/02/maven-configure-checkstyle-pmd-eclipse.html
The dev s... |
Now with gamemaker studio source files are no longer stored in a proprietary format - instead they are stored as simple XML files containing all data. Now I am wondering, can projects created with gamemaker be licensed using an open source license - especially wondering about the GPL and BSD/APACHE families?
And if so ... |
Edit: As a lot of you have pointed out, efficient can mean a lot of things. I guess when I say that the device 'requires efficient programming', I mean that the device does not have lots of memory or a very high CPU clock rate, and therefore needs to be programmed with these limitations in mind.
Original Question: Some... |
I'm a writing a small webserver for personal use in c (not c++). I want to allow user input in the console like "shutdown server" or "restart server".
In order to allow this kind of input the server is running in a seperate thread (pthreads), so the console isn't blocked.
I also want this thread to print output in the ... |
I was reading this blog by Joel Spolsky about 12 steps to better code. The absence of Test Driven Development really surprised me. So I want to throw the question to the Gurus. Is TDD not really worth the effort?
|
I have this old implementation of the Command pattern. It is kind of passing a Context through all the DIOperation implementation, but I realized later on, in the process of learning and learning (that never stops), that is not optimal. I also think that the "visiting" here doesn't really fit and just confuses.
I am ac... |
Imagine, there is an open-source project with a Maintainer and a Contributor. Both of them have theirs repos exported to some repository hosting (github, bitbucket, sourceforge --- whatever, but they are public).
Imagine further, Contributor did several commits, pushed them into his repo and sent pull-request to the Ma... |
I've been hired by someone to do some small work on a site. It's a site for a large company. It contains very sensitive data, so security is very important. Upon analyzing the code, I've noticed it's filled with security holes - read, lots of PHP files throwing user get/post input directly into mysql requests and syste... |
Let's say I have a not-so-intuitive if statement in my code, but only if you're new to the codebase:
def set_markets(markets=None):
"""
Will accept 'all' as markets to set all markets on.
For individual markets, pass in a list of ints.
"""
if markets:
if type(markets) == list:
ma... |
At my company, I develop and maintain all the operational reporting used by management to run the business. There is no reporting position on the application development team. I've taken it upon myself to step in and attend design review meetings to give input to the development team on how changes will impact report... |
Back in the late 90's I worked quite a bit with a code base that used exceptions as flow control. It implemented a finite state machine to drive telephony applications. Lately I am reminded of those days because I've been doing MVC web apps.
They both have Controllers that decide where to go next and supply the data t... |
I am traditionally a MsSQL or MySQL developer - I have been prototyping a new application that involves storing data from many targets.
I have seen that the app appears to get slow after scaling to 10k targets after inputting around 300k results for each (64 bit ints) - especially once I start trying to average and/or... |
I think this is a good question for here but I'm not 100% sure. Please flag if it's too vague.
I've worked on many websites where common framework classes are overridden.
Since I work mostly in .net these days examples would include Page, Masterpage, UserControl, DbContext ect. I believe this could apply to any langu... |
I'm exploring a piece of code in Architecture Explorer in Visual Studio 2010 to study the relations between methods. I noticed a strange behavior.
Take the following source code. It generates a hello message based on a template and a template engine, the template engine being a method (a sort of strategy pattern simpli... |
I'm having difficulties understanding whether or not this is the right process to use for a flow chart which illustrates the processes involved in an algorithm.
For this, assume the following:
A 1D X = [0, 1, 2, 3,........] data block is split into 2D blocks:
x = {[0 1]}
{[2 3]}
For each of these blocks, the tota... |
I store large quantities of GPS data in storage tables. Each partition can reach up to 1 million entities. Each GPS entity that is inserted into the table is actually sequential to the previous data inserted, so order matters.
Sometimes I need to perform the following query:
Get the previous/next 3 GPS entities fr... |
I'm curious about what it takes to build a simple and robust RPC framework. I've only looked at a few ruby frameworks but they are all lacking in some way. What I want out of an RPC framework is some kind of registration/discovery mechanism and a simple plugin architecture. Pretty much all the frameworks out there prov... |
I am a .NET developer and I just had the chance to play with Ruby on Rails this weekend.
In .NET we separate layers of the application by creating separate class library projects. From the design pattern standpoint, do we have to do that in Rails too or is it just one whole project with everything in it?
|
We are considering to impose a single standard code format in our project (auto format with save actions in Eclipse). The reason is that currently there is a big difference in the code formats used by several (>10) developers which makes it harder for one developer to work on the code of another developer. The same Jav... |
An organization with a number of agile Scrum teams also has a small group of people appointed as "enterprise architects". The EA group acts as control and gatekeeper for quality and adherence to decisions. This leads to overlaps between the team decision and EA decisions.
For instance, the team might want to use librar... |
I'm struggling to get my head around how best to eager load entities, and how to assign relationships when creating new entities. I'm using EF5 POCO, by the way.
I'm retreiving a large hierarchy of entities from a database, representing chemical analysis results. As a simple example I have an "AnalysisResult" entity wi... |
Bit of a workflow question.
I'm just staring with MVC and wondered how other people usually work in MVC? The 2 options I see is to code the model and controller completely first and then work on the views after. The other option is to code all parts at the same time.
I'm looking for what might be the quickest most effi... |
I am in the process of designing an architecture for a plugin based application and I have some questions about how to handle database access and logging. The goal of my application is to allow a device my company is manufacturing to send messages over any number of third-party protocols and to any number of third part... |
I was at an interview recently and although they knew that I was a beginner in javascript they asked me what selectors I used before? I didn't know what to say.
I came back home and searched for it but can't find a clear definition. Isn't a selector something like a .class or #id?
|
Suppose I have a class Manager derived from a base class Employee, and that Employee has a method getEmail() that is inherited by Manager. Should I test that the behaviour of a manager's getEmail() method is in fact the same as an employee's?
At the time these tests are written the behaviour will be the same, but of
c... |
An external source will be sending us XML data that BizTalk will pick up and transform into an internal schema. We need this data to be loaded into a SQL Server database as we're going to expose some of the data to our web front-end via a custom WCF service.
The question is: what is the recommended approach for doin... |
When map-reduce divides a task and sends the data to each worker process, does it also transmit the instructions for how to operate on the data?
For example, let's say Google has some huge array of computers that use map-reduce to index webpages. If they wanted to temporarily use that same array of systems to do somet... |
I'm still trying to wrap my head around OOP. All of the following examples work, of course, but is there one (or possibly another) that best exemplifies OOP concepts?
/**
* For the following examples the Image class queries an image
* and associated info from a database, which is passed on
* instantiation via depend... |
I am quite comfortable with using actionscript3 and flash. I also have some experience with Java. But recently, I started learning JavaScript and node.js. I ultimately want to make a 3d game in threejs, but for now I simply want to make a chat application.
I want to get into the habit of using JavaScript. Unfortunatel... |
I recently posted a question here: Methods to share memory or state across JVMs? and appreciate the answers. However, as I read the code and learned the system better I learned I was over complicating the problem. Only one of the JVM's really care about the dynamic data so there is no need to pass dynamic data across... |
I am currently tasked with creating a software architecture for compliance with IEC 62304. These regulations are notoriously vague, and do not provide any real substance as to what is required for a "software architecture". The standard states
The manufacturer shall transform the requirements for the medical device ... |
I'm in the early stages of writing an Emacs major mode for the Stack Exchange network; if you use Emacs regularly, this will benefit you in the end.
In order to minimize the number of calls made to Stack Exchange's API (capped at 10000 per IP per day) and to just be a generally responsible citizen, I want to cache the ... |
Preamble
I have been bitten by the bug of automated unit testing. I feel the benefits and the confidence in a code base it can deliver.
I am also feel I have a reasonable intuition as to what parts of the code deserve to be unit tested. Code that has logic, code that might be messy (because it's dealing with some messy... |
After doing a bit of research about licensing my free software, I reached this:
Attribution-NonCommercial-NoDerivs 3.0 Unported - http://creativecommons.org/licenses/by-nc-nd/3.0/
how do I include it in my software or website ?
going here: https://creativecommons.org/choose/
I see the text that I should include:
Thi... |
I have a big side project that I do now for 3 years. It has a lot of extra small tools to help me do tasks. Most of those tools are so old that I forgot what I have there.
How to create a feature map to have easy reminder of what is possible ?
Is there some special UML diagram notation for it?
How to do it? I think gra... |
Well, I don't have a strong background in programming. I know C, C++, some C#, some vb, and some basic java and SQL, that's it. I don't have any work experience in web development, so just consider me as a completely new starter.
I would like to do web development, and I hope I can easily find a job in web development... |
I have a question about hashmaps.
If you have this hashmap with m slots, and need to map n items to it, and n > m. There will be collisions for sure. But assuming there is simple uniform hashing assumption, this means that the maximum amount of collisions in any spot is the load factor right? The load factor is n/m. Bu... |
Let's say it is a concurrent mark-and-sweep garbage collector.
When such GC handles constant pointers it just walks through them (starting from roots), and marks every encountered data block. Then sweeps everything unmarked. A client code should mark the data blocks it uses as roots.
But what to do with variables? Here... |
It was quite hard to put what I meant into a title, but it's easy to put into code.
C++
Is this
int offset_x = 10;
int offset_y = 40;
...
element.move(offset_x, offset_y);
To be preferred over this?
Vector<int> offset(10, 40);
...
element.move(offset.x, offset.y);
(Note that Vector is not like std::vector, it's a 2D ... |
I am new to ORM, and we started developing a new system using NHibernate as the ORM.
I think this question may refer to any ORM and any language/platform.
The Team Leader has said we should use NHibernate only when retrieving our domain data model objects, ie, not to use any of the built in NHibernate selection or aggr... |
I am the Studies Coordinator at a College and we currently have somewhere in the order of 100-200 unit outlines that are created at the beginning of each semester. Those outlines need to have information like:
Unit Name
Unit Code
Course Type
Assessment Item 1 Name
Assessment Item 1 Distribution date...
And the list g... |
I'm developing a web application and we are using XML as a database and I'm using Linux as a platform and centos 6.5 as a server. Changing some value would make a lot a lot of changes in about six XML files.
So here's the problem: Pressing button save after editing, adding, deleting takes about one or one and half minu... |
The Problem: Two developers => three opinions on indention, braces on new line or not etc.
We usually work with three or four people on our projects and each of those has it's own code style. I know, the common solution is to agree on a code style, everybody has to use, but I don't want to force creative programmers in... |
I stumbled upon an article named Programming With Assertions.
And beside the mechanism of turning on and off assertions after compile time, I don't get it. Why were assertions introduced on language level, which is quite a big deal, isn't it?
I have never used assertions in production code, was never taught to use them... |
While developing web sites it can be annoying that I have to login to the site.
Every time the session runs out I have to go through a flow like...
Open logon page -> enter username/password -> click link to navigate to my page.
I sometimes use Selenium to record this flow, and then automate it.
But Selenium doesn't wo... |
When I write code like this, where obj is a local variable:
if (obj is IMyInterface)
{
var result = (IMyInterface)obj;
// ....
}
Resharper offers to change it into code like this:
var result = obj as IMyInterface;
if (result != null)
{
// ...
}
I prefer the former, as it offers no opportunity for accidental ... |
I have a class Image and another one ImageStore. The Image it's just a value object containing the package name and the image name. The ImageStore does all the actual work: calculates the real path of the image (based on the package and image name) and loads it from the server.
Now I have a quite big (and deep) hierarc... |
I work in a PHP based company. There is a project where we want to create a backend service. Senior members here are going for PHP, even though it is slower than Java. Their only point of contention, that Java is heavier than PHP in both memory and cpu load standpoint.
Jvm is more like a container environment, if u bri... |
I have a website e-mail form. I use a custom CAPTCHA to prevent spam from robots. Despite this, I still get spam.
Why? How do robots beat the CAPTCHA? Do they use some kind of advanced OCR or just get the solution from where it is stored?
How can I prevent this? Should I change to another type of CAPTCHA?
I am sur... |
Do not declare interfaces for immutable objects
[EDIT] Where the objects in question represent Data Transfer Objects (DTOs) or Plain Old Data (PODs)
Is that a reasonable guideline?
Up to now, I've often created interfaces for sealed classes that are immutable (data cannot be changed). I've tried to be careful myself to... |
I'm in the process of creating my own programming language, which I do for learning purposes. I already wrote the lexer and a recursive descent parser for a subset of my language (I currently support mathematical expressions, such as + - * / and parenthesis). The parser hands me back an Abstract Syntax Tree, on which I... |
According to ECMA-262, part 11.13, following is the exhaustive list of compound assignment operators: *= /= %= += -= <<= >>= >>>= &= ^= |=.
According to the part 11.11, var c = a || b will put a value into c if ToBoolean(a) is true and will put b value into c otherwise. As such, the logical OR is often used as the coal... |
This article shows that for Android apps, software developers use between 30 and 50 different devices for compatibility tests.
I tried to find information about tests of applications on "classic" computers, for example PC games or graphics-oriented business applications: how many different hardware configurations are t... |
I have one one software system which allows developers to specify an ID or name to create NodeReferences. Both work fine, but ID's are not guaranteed to be the same across different environments. I've tried in documentation and in conversations to stress that ID's should not be hard coded (since they will break when de... |
It has just dawned on me, that a system I am developing exposes a users username in the URI. This is a problem, since some of the users pages are public. Therefore people will know their username.
I thought that this would be a security issue, but then realised that big names like twitter do the same thing. Pretty much... |
I am working on an open source project on GitHub.
It has a subdirectory /Vendor in which it has a copy of several external libraries. Original maintainer of the project updated this directory with newer copy of external library once in a while.
One developer send me a pull request with idea to replace this copy by git... |
I am looking for resources to turn to when I don't have the answer for something. I lead a team of software developers. We have been rolling out new software releases on a monthly basis.
When there is a bug that my team cannot fix, it lands on me. Most of the time I can resolve the issue, but there are times when I get... |
I was wondering how the cover flow effect is coded. I used this link which gave me the code on how it all worked out : http://luwes.co/labs/js-cover-flow/. I am completely new to complex programs so I had a hard time in understanding how it all works out.
Why do we program each file separately and place them in separ... |
I've documented my code for doxygen, but I don't want the default HTML it gives. I know I can customize it by providing custom CSS, headers, footers, etc. (like GNOME does), and how I can add common PHP code to the files and tell it to save as .php, but that isn't really what I want.
What I want is output like MSDN. I ... |
I am new to caching and trying to understand how it works in general. Below is code snippet from ServiceStack website.
public object Get(CachedCustomers request)
{
//Manually create the Unified Resource Name "urn:customers".
return base.RequestContext.ToOptimizedResultUsingCache(base.Cache, "urn:customers", () ... |
I have a jQuery Plugin that I use myself which modifies the selected value of select items on a page.
In my own code the plugin automatically executes as soon as it is included in the page this code in the plugin file.
jQuery('Document').ready(function(){
jQuery('select').SelectOptions();
});
this automatically execut... |
Quoted from MSDN about StackOverflowException:
The exception that is thrown when the execution stack overflows because it contains too many nested method calls.
Too many is pretty vague here. How do I know when too many is really too many? Thousands of function calls? Millions? I assume that it must be related in som... |
Background
I revisited an old (but great) site I had not been to for ages - the Alioth Language Shootout (http://benchmarksgame.alioth.debian.org/).
I started out programming in C/C++ several years ago, but have since then been working almost exclusively in Java due to language constraints in the projects I have been i... |
Backstory
I graduated less than a year ago with a degree in Computer Science (with extra courses in software engineering), and another degree in Software Engineering. I'd like to think that I'm familiar with modern software development methodologies (CI, Scrum, XP, etc).
The problem
I got my first (and current) job at ... |
Although I suspect the answer to this question may be something along the lines of "popularity is irrelevant; each algorithm has its trade-offs", I'm interested in a list of popular sorting algorithms used in practice.
I was browsing Wikipedia's page on sorting algorithms and while there are not that many algorithms li... |
This seems like a simple question, but after a lot of reading on the subject, I still haven't found a definitive answer (perhaps because it is so simple).
My question is this: when a garbage collector compacts objects in the heap, how are the references to those objects in the stack updated? I can think of two possibl... |
I have a .NET (C#) application that I am releasing soon, which also has some support files. Right now I am storing those files as .txt files, and I update them as necessary whenever the application version changes. I am wondering if a better solution might be to store the information in those files in a central datab... |
We are an organisation consisting of around 200 developers that are working continuously on one single product (using the revision control Git) which is planned to be released at a certain date.
Due to the huge number of developers, we are trying to create "cross functional" teams with around 10 developers in each team... |
For background information, see "Some background" further down.
I have a list that looks like this:
Start-Time-In-Seconds;End-Time-In-Seconds
1;2
4;6
12;15
...
This works together with a wave file by acting as a cutlist. So the desired parts are 1->2, 4->6, 12->15, ...
If the distance between End-Time-In-Seconds of th... |
I have a form that includes an area for putting in address information and a table that shows the addresses that have been added. I've separated out the ActionListener for the "add address" button on the form into it's own top level class and I'm finding it tricky and cumbersome to refer back to the form that has the ... |
First, it is clear that the right to sublicense doesn't give you the right to relicense.
Let's say that we have a library licensed under the MIT license(1 file), someone adds some features to the library but puts them under GPL(in the same 1 file). Or, if someone wants to sublicense, do they have to separate the code?
... |
Should bash be expected to change in ways that break non-trivial amounts of existing scripts at some point in the (near/<5y) future? How much change has it gone trough in the last ten years compared to, say, python or perl?
|
I am considering using a NoSQL Document database as a messaging queue.
Here is why:
I want a client to post a message (some serialized object) to the server and not have to wait for a synchronous response.
I want to be able to pull messages off of the "queue" based on some criteria, which may be more sophisticated t... |
I wonder, would it not be possible for an IDE to detect any shared mutable objects that are used in multiple threads?
You could flag types as either [ThreadSafe] or [Immutable] using attributes in .NET for example, and then those variables would never cause warnings, but any other variable that is used inside of a meth... |
I have to create a program that compares two or three different methods (FEM FVM FDM) for solving an easy pde. Is there a program language in which I could do this easily?
(i need to operate with vectors/matrix and perform inversions on matrix)
|
The first application (web-based) will be located at site1 and once the information is processed, it will be sent to the second application(web-based) located at site2. Application2 needs to be able to do the same thing as application1. Because of this, there has to be a way to share the database to keep data in sync. ... |
I am trying to create a very simple evolution algorithm for a creature simulator, what I would like to have is, both creatures have a trait and a dominance level, both noted by ints. their child's trait will be a random number between creature A's trait and creature B's trait then skewed to the more dominant. So if A h... |
From what I've read, LGPL 3.0 allows you to use the license together with other licenses, more permissive about that(Not even sure about that). From https://www.gnu.org/licenses/gpl-faq.html#AllCompatibility it says that it is not compatible with GPLv2, while LGPL 2.1 is compatible with it. That's a bit contrary to the... |
I'm reading a book on Objective C, and I was wondering how important the subject Working with files for learning to develop iOS in particular?
On you tube the tutorials are very short, maybe 10 min of video that teaches you how to do stuff with files and URL's. But in the book its a very long chapter with lot's of deta... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.