instruction
stringlengths
34
19.9k
I am trying to get my head wrapped around OOP after programming in more procedural languages for a number of years. My question: What is the best practice for handling variable values outside of source code? For example, I have file directory values and regex patterns that may need to be manually changed from time to ...
I need to hire a senior software developer. I've switched to a new recruiter and he's asked for about 3 questions to ask each candidate on the phone that he'll send the answers to when I see the CV to help me screen out the obvious bad ones. I quite like the idea of not having to phone screen people who just cannot c...
What are the exact terms to call data types with a logic structure (like C structures, C++ or Java objects) versus fundamental data types (like numeric types, characters, booleans...) independently of any language or paradigm. (I am searching for abstract/academic computer science words).
I forked a project on Github, made a small change and sent a pull request to the original maintainer, who has pulled it in. Now the last commit there is Merged pull request #11 from my_username/master. This is the first time I'm doing this, so I'm not sure what the etiquette now is: I did a git pull upstream master an...
Is there any way I can execute a block of code in a loop, like so: [ some code goes here ] Where the delimiters are "[" and "]", and also allowing for nested blocks, i.e.: [the user can create another loop[]] I am creating a parser for a language that implements such semantics, and it reads the code one byte/characte...
In my experience, being familiar with anti-patterns is as vital as knowing patterns themselves. Despite an abundance of literature on patterns, there is a surprising lack of literature on anti-patterns. Browsing the web usually reveals advises that are either too vague (e.g. "do not use global variables"), too specific...
I'm trying to start unit testing (not using any testing frameworks) for my javascripts. Here's one example of it. var obj = {}; obj.disableBtn = function ($btn, style) { $btn.attr('disabled','disabled').addClass('disabled').removeClass(style); }; The use case is as such: obj.disableBtn($('.submit'), 'btn-blue'); ...
I'm writing a database management software. It has a client-server architecture where the server has the piece of code to store and retrieve. The client has to get the input from the user, connects to the server and queries it. Now I have a parser that can parse SQL like queries. My question is which is the best place ...
Background: I am proponent of functional programming who works at a VB.NET shop where the prevailing mental model is imperative programming. Being that foundation of our system is WinForms I can understand we're not going to get entirely away from imperative programming, but still I try to use FP (primarily via Linq) ...
I'm currently in the process of modelling a generic form of RNA and RNA transcription and I'm having difficulty finding a proper OO modeling of this area. Human RNA has 4 types of Nucleotides (A, G, U, and C). An RNA strand is just a string of these 4 types. eg, AAGACAUUCUA... What I'm trying to model is more generic...
I understand that compiling into Javascript is sometimes necessary and even in some cases results in a faster application. However I'm wondering if compiling into Javascript, for building web applications, from a language like ruby, is considered bad practice. Specifically for the purpose of language preference and for...
My school's CS program avoids any mention of object oriented programming, so I've been doing some reading on my own to supplement it -- specifically, Object Oriented Software Construction by Bertrand Meyer. Meyer makes the point repeatedly that classes should hide as much information about their implementation as possi...
I'm watching a video on C# about Variables. The author declares a variable inside a method and he named it like this: string MyName ="James"; my question is: which convention is recommended by .Net Framework. Is it Pascal casing as in the above example or is it camel case?
I 'm just learning to give project versions. I understand writing details about the changes in my project when committing, but where should I put my version number for my project?
I am writing a web-application in which I am retrieving data's from server through AJAX requests and the generate HTML content dynamically. I have some data to load, generate HTML from it and append into my web page. Now I was thinking on two solutions: 1) Do AJAX call, generate HTML from response, set display: none ...
A recent flurry of comments on a JSHint issue alerted me to the fact that the JSON data-interchange format has a license. The content of this license can be debated elsewhere. What I'm unclear on is what it means for JSON (or any other data-interchance format) to have a license. If an a library simply consumes and pars...
Whenever I write unit tests I have always tried to have a single assert per test to make debugging easier when tests fail. However as I follow this rule I feel like I am constantly copying the same code in each test and by having more tests it becomes harder to go back to read and maintain. So does single-assertion te...
Many people use the term Snake Case to describe variables or other symbols with_the_form_of_underscores. In the past week, I've launched several broad searches. I can't find anything about the origin of this term that is more detailed than what Wikipedia says (above) When did the earliest record of this term enter into...
Currently I'm still learning ASP.NET. My goal is to build dynamic websites. However, I also want to be able to build some windows applications as well. So, is it easy to learn Windows forms or WPF after ASP.NET? or is the reverse easier? meaning to start with WPF then move to ASP.NET?
Was wondering if you could help me on a SQL problem I’m having. I have a set of records of events where each event has a start time and end time. No event has the same start time, and the end time for each event is greater than or equal to the preceding event. What I want to be able to do is pull out the set of rec...
If I talk about openERP its and source (AGPL-3), I have studied it, but can't find some question e.g 1: we have developed a School Management System using openERP Version 7.0, as according to my understanding, we cannot sale it to any customer as it appears to be free like other modules of openERP. So I should charge m...
I've noticed that there are a lot of UIView subclasses in my legacy project. Mostly the only reason of such a subclass is to split bigger view into custom subviews and provide layout for its subviews and delegation of UIButtons actions through the view delegate protocol. So I'm wondering, is it a correct design?
We have a core banking product developed with ASP.NET with C# using Microsoft SQL Server 2008 database. Product is hosted on a centralized server and works well at all locations (bank branches) where connectivity is good and stable. We need to implement this solution at a region where connectivity is always an issue. S...
I'm developing a software package and would like to make it (and the source) available for personal, academic, or educational use, but not for commercial use. Is there such a license? Ideally, it should be reciprocal, so that if someone publishes a modified version, they'll have to grant the same rights. Alternatively,...
I built a prototype ("one to throw away") a while ago, and I'm rebuilding it now as an alpha. My goodness, it's been worth it. I reused some of the prototype code by copy-pasting then modifying it, but I've fallen into a pattern of looking at the prototype for guidance, but writing the new code from scratch. This doe...
I am trying to design a system with the below features, and am currently trying to figure out best way to handle Identity : There will be multiple decoupled parts of the system, with same customers accessing various parts I would like users organized by organizations/companies, i.e. user1 & user2 belong to ORG1 I wo...
How to use unit testing? There are a lot of frameworks for different languages, which provide functionality of unit testing. There is a lot of information on how to use each of them technically. Just like "import to your project this lib, type assert, compile, run and blah-blah-blah". And it all is easy to learn. The p...
There were 3 developers at this GIS tracking company, but now there's 2. Last week my boss was fired. Today, new developers will be coming in for interviews. They'll be coming in from a placement agency. I don't really know how to be on this side of a hiring interview. Any advice or sample questions I can ask? Company ...
My college has a course on Introduction to programming using python and we are using Python 2.7.5. I would like to know if it will be helpful to read Python Cookbook which is for python 2.4? There are no separate cookbooks for python 2.7.x, to my knowledge. But, are there any similar books? There is a later edition t...
I am also using Node - which I am not the most familiar with - if the articles/books/tutorials pertained to this also - that would help even more. I come from a mostly MySQL background - but in this api, all data is going to be served as JSON - so at first glance, using Mongo made a lot of sense (I could be wrong). One...
At my current workplace there is a common pattern in database design: they don't use foreign keys but they list all corresponding ids in a column like this: some_table id name image_ids 1 a 1,2,3 2 b 4,6,7 images id url 1 ... 2 ... ... They store self references in a same manner: some_table id name som...
Searching the web, we can find plentiful examples of various ORMs (nHibernate, EF, LinqToSql, etc.) that implement but don't actually support the full IQueryable<T> interface, throwing NotSupportedExceptions when they encounter something they don't like, such as LinqToSql and SkipWhile. My question is this: why do ORM ...
I'm working on a site where companies can create a profile then add locations for each profile. Those first two tables are simple enough. But any changes to their profiles or locations have to go through an approval process. This is where I'm torn. The end result would be an employee going through a worklist and seein...
I am having some difficulty with MySQL and returning a unique row to a thread. I want it so the thread will search for a row from the table where the bit (see below) is false and only one row is returned. But I don't want the other threads to return the same result should there might be some race condition where the sa...
Simply put: is there a best practice for whether developers should write automated tests to check that data is correct (the contents of config files, databases, etc.)? If so, what is it? Assume that the data is static for a given release, and specified as part of requirements.
I have never written software in Common Lisp, but in Scheme and Clojure as well as C++ and Python. Yet I have had a look at the Common Lisp Object System (CLOS) in Common Lisp and Dylan. Now when comparing it to OOP in the Simula tradition, CLOS and lets say C++ and Python class system have polymorphism as a common tra...
I am looking for help designing the display of available times for appointments (for example a hairdresser's appointment book). Currently I have a query that returns a collection of periods that are unavailable for appointments (whether there is an existing appointment or if the service provider is closed). So lets sa...
I am writing the server backed by a pre-written API. I'm going to get a number of strings representing ports, signals, paths, etc etc etc. I need to look up the object associated with a given label, these objects are all in memory (no sql magic to do this for me). My question is, how best do I associate a given uniqu...
Responsive Web Design shows the user different elements -- or elements arranged in different ways -- by using media queries (if the device is a desktop or laptop, show them this; if a tablet, show them that; if a "phone," show them the other thing) or other methodologies. What about, though (especially if your app/site...
A while back I saw a comment on a Stack Overflow question that surprised me: No one can write an operating system in C. It is not possible. What one can do is write an operating system in a C-based/C-like language that adds/defines a considerable amount of non-standard capabilities on top of C core. Is it usefu...
While looking at the code in C for division/multiplication by 2, it is found that shift operator is used rather than division operator. What is the advantage of using shift over division operator?
I've an HttpHandler, which allows users to login to a system by passing in an encrypted code. Inside the ProcessRequest it performs quite a few steps. Retrieve the encrypted code from request (could be in Form/X-Header/Query) Decrypt it. (Results in an JSON string) Deserialize to a dynamic type Determine the type of r...
I got surprised when I visited some sites with an 'aspx' extension at the end of their URLs and when I looked at their html source I didn't see any view state like the follwing: <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="SNIKalxBOk0/lp+SgXklgi/0/IUoRXTjEjp6NrL2ColFXGht1bTDit5V+wHdkcuM3YVmVNKG1jpM6z...
I'm working on an enterprise project which will be deployed in many SMBs and Enterprises. The support for this project would be struggling and so I want to create a coding pattern for errors (Like HTTP status Codes). This will enable help desk people to refer to documents and troubleshoot the problems as soon as possib...
I have a software (in cloud) with so many registered users. I want to restrict the number of users logged in at a time to certain number (configuration based, let's say 100). If the 101 user tries to login he should be placed in queue with priority 1, subsequently 102 user should be 2 in queue, I know at every time a l...
What I would like to achieve is to use classes (now two, later more) with different interface the same way, so I would like avoid using decisions based on the interface on upper levels for instance, I don't want to see things like this: if ($class instanceof 'ThisInterface') { $thisInterfaceImplementation->doStuff(...
I have an existing language that I need to port to a new platform. I'll probably attempt this by changing the backend of the existing compiler. It is a significant amount of work to re-write the backend. I can't see a way breaking this down into sensible stories without violating INVEST criteria. I can't see how each ...
I am learning php from the internet on codeacademy.com. I have also learned html and css but the problem that i dont know how can i build a complete website then ! I study everything on its side. But how to put all my knowledge together its very hard! like when should i use this php code? When should i use the html cod...
To what extent should one make exceptions redundant or atomic to a method. For instance, suppose I have a method public void authenticate(String username, String password) that calls private void invokeServer(String username, String password). Both methods require those params to be non-zero length, and as such I would...
Most OpenCL Tutorials give a nice introduction to OpenCL, yet I have not found information on the question of interoperability of the compilation targets. It seems that I have to compile OpenCL code for the target GPU. Now when making a binary distribution of an application using OpenCL, does one have to make several b...
The C standard mandates that no C standard library functions shall set errno to zero. Why exactly is this? I could understand it being useful for calling several functions, and only checking errno after the last one - for example: errno = 0; double x = strtod(str1, NULL); long y = strtol(str2, NULL); if (errno) // ...
I come from using ASP.NET MVC/Web API and now I am starting to use Angular but I am not clear on the proper way to mix them. Once I am using Angular does the MVC server side concepts still provide any value? Or should I strictly be using Web API purely to get data for the angular HTTP calls? Is there maybe a more stri...
I'm working with a data import process in C#, which takes a zip file filled with XML files and saves specific data points into a database. This is accomplished by loading the XML data into classes compiled from the schema. The import logic retrieves the data by digging down into the right classes and fields. The XML ...
I have two project A(.EXE) and B(.DLL) in the solution. A references B. If I delay sign both and send them for full signing. Will A be able to load B after ? Or do I have to get B fully signed first, and then add a binary reference to that in Project A, delay sign A and send for full signing ?
I have created an app that works on my 4th generation iPod Touch and my company's 5th generation iPod touch. We were about to release, when we found a crash that occurs after any non-developer device runs the app*. The notion came up that a device registered as a 'developer device' gives your app more resources to use...
Most of my system's class attributes are just text, but in this case it makes more sense to place this particular class's attributes into one single hash (from a "keep the source code pretty" aspect). Basically, a list of attributes is returned, and instead of writing a bunch of static attributes for each one, I just l...
I'm an open source web application for use in my university. Currently professors usually have a website, but do to the fact that they're teaching multiple classes in a given term, they don't care to spend time and make an extensible, functional website. The purpose of this project is to create an OSS website that can...
This question has been bothering me for some time now and today I figured I would Google it. I've read some stuff about it and it seemed very similar to what I've always known as processor cache. Is there a difference between the two or am I right when I think they are the same? Is a register actually required to be ...
We have production code that is not easily deployed in a test area. We also have a new library of code that we would like to "plug in" to the production code. The production code would be making a few calls to the new code. Each of these calls are not mission critical (updating analytic information in a database). If...
I am using google code prettify. After a page renders, I decided to check how <code> and <pre> tags and their contents were manipulated. But in view source, I found no changes were made (in contrast to online syntax highlighters, which generate css style code with code text). So, how/where is info about keywords, varia...
I'm looking at a function that that has several statements like this: n = returnDifferentVersionOf(n); I.e., the value of the same variable n changes progressively several times during the course of a subroutine -- rather than a newly named variable being assigned at each change. What is the generic name of this techn...
I'm coding something for my job to copy directories and then use regex to make all the filenames uniform. I'm an undergrad student programmer for my university and I'm not sure what a professional coder would consider reasonable in this case. My job is mostly to implement mathematical research. The current assignment...
For declarative languages, specifically (but not limited to) in the field of modelling, it's not obvious to me whether code can be considered to be separate from data. This line of reasoning may only apply to non-turing complete languages such as NeuroML. Say for instance I had a very domain specific declarative langua...
[Context - I'm a Java developer, having a discussion with a designer who works in the html/css space] I was having a discussion with a co-worker today about the merits of 'semantic css'. His response was, "Oh we're not interested in semantic css, we use object oriented css" I understand what he means, ie that they're ...
I have a confusion regarding Factory Pattern there are basically two ways You can implement that. Approach 1: public interface IProductFactory { IProduct GetProductA(); IProduct GetProductB(); IProduct GetProductC(); } public class ProductFactory : IProductFactory { public IProduct GetProductA() { ...
I've read an article about Innodb performance optimization an in that post the author was repeatedly mentioning someting named a "battery back up cache". It is not clear for me what he was talking about and google did not help either. My guess is that this is some kind of backup storage in case there is a power outage....
As a developer I like Scala and could tell the management about technical benefits of the language. But even if management understands that a superior technology has business impact, I fear that they don't understand what I'd be talking about. What arguments would you present to managers with technical backgrounds (co...
Coming out of a project using Linq2Sql, I suspect that the next (bigger) one might push me into the arms of Entity Framework. I've done some reading-up on the subject, but what I haven't managed to find is a coherent story about how SQL Server Data Tools and Entity Framework should/could/might be used together. Were t...
I am starting with this project of mine of writing a custom UI for linux. What would happen is: The computer would boot into this UI which would not be the typical taskbar/icons/startbutton kind of thing. Think more like a dedicated UI instead of a general purpose one. It would provide access to wifi, ethernet, blueto...
From the book Professional Enterprise .Net, which has 5 star rating on Amazon that I am doubting after having a read through. Here is a Borrower class (In C# but it's pretty basic; anyone can understand it) that is part of a Mortgage application the authors built: public List<BrokenBusinessRule> GetBrokenRules() ...
I think I have never seen a [] that doesn't mean array in C. Background: I was reading about l-values and r-values here: http://msdn.microsoft.com/en-us/library/bkbs2cds.aspx and there it says so. I am curious.
My (new) development team is setting up its software development environment. I won't describe the whole scenario, since that's another, much-maligned question. Anyway, we're going to have services such as source control (mercurial), a wiki, an issue tracker, a file/document server, DNS and possibly other things. My qu...
I am currently new to Dependency Injection pattern. I am influenced by link by Mark Seemann. I have a confusion regarding whether an interface for an agent class of some agent module should be included in domain layer? by agent I mean a class / module that interacts with external wcf/ webservices. I have a diagram tha...
I am working as a IT-developer. I am developing J2EE application in our own life project cycle methodology. I have seen and learnt so many SDLC cycle models in order to develop a project but this open source development and its process still unknown to me. So, how this open source development life cycle happen? How thi...
C++ is a great language in many ways, but some things in particular are cumbersome to write without an IDE. As a VIM user, it would be very interesting if I had access to a higher level language which enabled me to write C++ with S-Expressions and possibly with Lisp-like macros, allowing for the generation of clean cod...
Lately I can't seem to get enough of the amazing async-await pattern of C# 5.0. Where have you been all my life? I'm absolutely thrilled with the simple syntax, but I'm having one small difficulty. My problem is that async functions have a totally different declaration from regular functions. Since only async functions...
I'm trying to find a developer to write me a pretty basic program. I am also a developer, but don't have enough time to write it myself. This program has a pretty basic function. It will notify users, via some dialog (or alert) that some program is about to access the built in desktop / laptop camera. It could be skyp...
I have a class that encapsulates the results of a scientific measurement. I’m building in unit tests from the beginning, but I don’t have a lot of experience with unit testing and I’m not sure which behaviors I should be testing and how. My class does three kinds of things: Reads measurement data from a file (or a str...
As an example of what I need and why I want it, I am trying to determine how a certain value (CurTotal) is getting set (wrongly). I've come up with these notes to myself to try to understand just what is happening: **CurTotal is declared in frmEntry.SetTotalControlsProperties(). CurTotal gets its value within that meth...
Resharper (or is it Visual Studio - it's a yellow light bulb with a tiny red filament in it) offers to "invert if" on this code: if (tItems >= 0) { return tItems; } SetTotalItemsAndTotalAmt(); ...and if I allow it to, it becomes this: if (tItems < 0) { SetTotalItemsAndTotalAmt(); } return tItems; ...but then ...
Developing endless frameworks for web application, websites and web services is always great fun. It's one of the richest areas where you have 100 different ways of achieving pretty much the same thing. Even with all this abundance, I've recently managed to find myself missing a web framework in C#. I feel that the new...
I want to develop a WordPress theme using Roots theme framework and then sell it on themeforest.net. Roots theme license allows me to sell the theme as per its founder's discussion with some guy on this google group post. It says that the product should have an MIT compatible license. The question is:- If I sell it on...
I have a controller in my mvc4 web application in which there is an action that needs to call another function. What happens in that function i.e. the return value is not important for my action. How i can call that function and never wait for it to be executed? I think it can be done by async but my point is not to us...
I'm building close-source application with some libraries that's using Apache License 2.0. Number 4 point a) of the license stated that: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; Does this mean that my application is now under Apache License 2.0 because I included t...
We are given a list of edges between a set of N vertices. There are atmost three edges joining a vertex. We have to arrange all the vertices on a straight line with the positions numbered from 1 to N so that the sum of the length of all the edges is minimized. The length of an edge a,b is the difference between the po...
I have a Java code which is writing some data in string format to Messaging queue. Now any one can subscribe to this queue and fetch this data. Here the client fetching this data can be written in any programming language. I was planning to expose this data in JSON format, but then as per my understanding I have to exp...
I have a basic search in my webpage. When I designed it, I chose to combine the search box inputs with OR. For example: A search for foo bar will be translated to foo OR bar, so every entry which includes foo or bar will be shown. I did this because I thought that a search should return as much as possible and leave i...
I have if (!b && c || a && c) //do action a else //... Due to some internal relationship between a, b, and c. !b && c || a && c is proved to be equivalent to (! a && b) || c. I just wonder will (! a && b) || c be simpler than !b && c || a && c? Can you prove it? Assume the chances of a,b,c to be True or False is ...
Given an expression, such as int x = y + 5, we'd call int x the left-hand side (or LHS), and y + 5 the right-hand side (or RHS). The whole expression is called, of course, an expression (or equation), but is there a generic term for a "side" of an expression? LHS and RHS don't quite cut it when it comes to an expressio...
Insofar as I understand it, tools like Git and Mercurial derive checksums from their data, and those checksums are used to derive other checksums used in aggregate, leading to a kind of accumulative checksumming (checksums being the input to other checksums), that ensures a high level of integrity. Is there a name for ...
I'm looking at Azure Mobile Services, particularly the Authentication part (which I believe relies exclusively on OAUTH 1 or 2). I want to make sure that my application isn't tightly coupled to the service and I can bring authentication back in-house using either of the following methods: I use a version of Azure Mobi...
My project lead considers both of these approaches to be unnecessary overhead. I have been involved in and have witnessed a lot of talk around XML vs JSON, but this is the first time that I have heard an argument against BOTH. We are using c# in .Net 4. We'll be storing data in a sql server database on the server and a...
What is better practice: force user to extend abstract class or make class with configuration? Eg. pseudocode: ClassA{ this.name this.weight this.height this.width constr(config){ this.name = config.name this.weight = weight this.height = height this.width = width } } or abstract ClassA{ this.name thi...
I've read recently that macro support in Scala is now official. I checked the documentation page and they are reminiscent to the LISP ones. In one of his essays Paul Graham writes that when "you add this final increment of power" to a language it is no longer a new one but a lisp dialect. Is this the case with Scala? I...
Our team is looking to introduce Web API, MVC/ASP.NET implementation in our SOA. I am having a hard time trying to wrap my head around the identity and access control it has compared to WCF. WCF has Windows, X.509, UserName, and WS-Trust (probably more, but this is what I am familiar with), MVC's Web API seems to only...
I am working on a PHP code and as it grows getting more and more tired of repeating the same standard pattern again and again and again: class BolerPlate { protected $property1; protected $property2; ... public function __construct ($property1, $property2, ...) { $this->property1 = $propert...
I am developing a Windows application and I want to store all the text for labels, radio buttons, buttons, check boxes and column headers of grids at one place. I have tried using a class file, an xml file, a database table and a resource file. I found that a class file is the best way to store all these texts, but I w...
I was trying to understand how to write unit tests for a few days now. I'm confused with following scenarios in the existing code. In first function the max value changes depending on the object created at run time but in the second case it is a constant. NOTE: The following functions are not related. These are two d...
In working with python for the first time, I've found that I end up writing multiple classes in the same file, which is opposed to other languages like Java, which uses one file per class. Usually, these classes are made up of 1 abstract base class, with 1-2 concrete implementations who's use varies slightly. I've post...
First of all let me expose what I would like to do : I already dispose of a long-time running webapp developed in ASP.NET (C#) 2.0. In this app, users can upload standard PDF files (text+pics). The app is running in production on a Windows Server 2003 and has a dedicated database server (SQL server 2008) also running W...