instruction
stringlengths
34
19.9k
I have two chat rooms, one has administration behaviour, and one doesn't. I have factored out all of the common code into a base chat room, but the AdministerChatroom behaviour I have pulled out into an interface called IAdministrable and it sits on the base chatroom class. My issue is that because the interface is o...
Imagine a simple Controller (as in process control) interface. I have some concrete classes, say PIDController, that implement it. I also have some decorator classes that extend these classes somehow, say ITAETuningDecorator. Now imagine that a FloodGate class has a private Controller field. I would like, from the ou...
I'm making an MPMC queue in C++, and I would like to find out what the best interface for a try_dequeue method would be (I'm not concerned about its implementation). I'd like to provide a method which does not block if the queue is empty (like my dequeue() method does), but somehow notifies this to the caller. While I ...
Given the following interface interface Modem { public void Dial(string pno); public void Hangup(); public void Send(char c); public char Recv(); } Uncle Bob writes However, there are two responsibilities being shown here. The first responsibility is connection management. The second is data communi...
I am currently investigating different alternatives for building a mobile instant messaging application for iOS and Android, using an XMPP server (probably ejabberd) as the back-end. Main requirements are a nice UI and of course good performance on most devices. I have identified three different alternatives, two of wh...
Say I compile a simple application called myproggy that depends on the libfoo dynamic library. Assuming I have another dynamic library libbaz that implements absolutely the same interface (in other words it has definitions of the same functions as libfoo), is it possible to modify the myproggy to depend upon libbaz wit...
I have various interfaces i have to implement. Let's assume ITypeA, ITypeB. They have following methods: ITypeA Connect Disconnect GetData SetData ClearData ITypeB Connect Disconnect GetData SetData Start Pause Stop They have some base functionality: Connect, Disconnect, GetData and SetData. I...
We have an agile team and nearly running 80. sprint.Our sprint starts wednesday and finish Tuesday 10 days after.One of our team member,developer, will attend to a university course every Wednesday during 4 months.Which one is better should we take sprint days Tuesday to Monday,total sprint day will not change still 1...
In our company there once were multiple programmers, now i am the last man standing. I have inherited all the code and i maintain, rewrite, extend (,fix) it. I always run into this behaviour that i try to make stuff fool proof so that a dummie co-worker couldnt mess up the code. But there are limits to what i can do. I...
I've written a system that calculates discounts for a shopping cart based on a set of rules. Each rule is implemented with the following interface (C#): interface IRule { bool IsActive(); bool IsApplicableTo(IShoppingCart cart); decimal CalculateDiscount(IShoppingCart cart); } A concrete implementation might ...
I'm trying to calculate the NPath Complexity within a function, but I'm unsure what parts I count. My understanding is that it'll sum: If Else Else If Switch Case Default Do While Is this correct? Or am I missing something?
I am developing a project where I have to load very large files (upto 50 MB). Currently I am loading these files completely into (consecutive) memory. This has the advantage that I can very easily change bytes at certain locations, because I do not know the structure of all bytes. However, my intention is to also chang...
As far as I understand the Actor Model and the Reactive Programming are separate concepts. Actor Model does not seem to be inherently reactive to me. However the Akka framework which is an Actor Model implementation is being described as reactive: "Java and Scala program logic lives in lightweight Actor objects, whi...
I'm not sure how I should have worded the question. If I have a Student and Classes database, and I have queries that involve both. Where do I put my queries? In one case, someone wants student information, and I query Students and Classes in my Student class, if I put it in Classes, I cross over to the Students, [ed...
I'm developing a (PHP MySQL) Web App which will sell dynamically generated real time cell phone numbers for cellular companies. A company will ask for, say, a thousand numbers and this app will check for available numbers and provide them. The number will be an 8 digit figure. The first two digits of the number will mo...
I am working on a Scala project and I want to include some sample data somewhere in the project. Specifically, my Scala project includes code that performs various natural language processing tasks on text data. I want to include a sample set of text files that the user can use to test out the program somewhere in th...
Occasionally while typing something up that relates to a case-sensitive programming language I end up starting a sentence with a function name. Now the rules of English state that the first word in a sentence needs to be capitalized; the function name is lowercase, though. If you are wondering what could I be saying th...
Background My team uses scrum I have currently no task assigned There are no more pending task in the backlog Today is Labor Day for my client. Not having many things to do today I wanted to start refactoring some code I keep on seeing in the project I am working on, but currently I am not assigned to any sprint task...
I have been investigating on the viability of a "normal" programming language with dependent types. Think for example in Java and add dependent types to it. One difficulty which I have found is that the type of a variable may change when mutated, like in the following piece of pseudo-code: let xs = [1, 2, 3]; // The ty...
WinAPI is focused primarily on the C family, but how do new programming languages use those features without creating their own runtime/interpreter type thing? Do they hook directly into the DLL files? kernel32.dll contains most of those functions right? Thanks.
I could login through the website, android app, iOS app, the browsers on mobile, and when I log out from one, it doesn't log me out of all of them. Traditionally, you would log out of all the services at once because your auth_token would be set to null in the DB. That being said, I don't see a way to do this through R...
As I read a book about "Algorithm Analysis", I came across count_sort Algorithm. However, I have read elsewhere that "Quick Sort/ Merge Sort" are the best and the most efficient sorting algorithms. I found this confusing because the complexity of count_sort is O(n+k), which is better than Mergesort and Quicksort which...
We started following the Agile Scrum methodology and we have completed about 10 sprints. One observation I had is that not all in the team are taking up the responsibilities of completing the tasks and user stories by themselves and everytime they have to be instructed or allotted with some tasks. Also the estimate the...
There are 2 entities. One is admin. The task of admin is to define slots for appointments which will be taken by applicants. The admin will choose a default time for the appointments like 10am to 2pm and then 3pm to 5pm. Now the confusion how to save this information in database. In a single row which contains start...
I am working on a huge web application in which I need to add transparent failover feature. I understand the necessary steps to make a web application distributable, the most difficult thing being: to ensure that the objects stored in the session are serializable. I want to know which type of variables exactly should I...
I am designing database for a school system. I am having to create a lot of tables and a lot of link tables to maintain a structure in the system. I am trying to maintain foreign integrity and trying to create unique data entry as possible. But this will create problem with queries when I start building out the system....
I'm reading a paper describing a NLP work, and I hardly catch the concept of a term, "latent parsing". Original paper: http://web.stanford.edu/~angeli/papers/2013-acl-temporal.pdf The figure in the page 6 seems to be helpful (I can't upload the figure because of my reputation)
By reading various source code, I see that there is different ways of binding an ICommand to a RelayCommand : From the constructor MyAwesomeViewModel() { this._fooCommand = new RelayCommand((x) => Bar(x)) } Directly from the command property private ICommand _fooCommand ; public ICommand SearchCommand { get...
I'm trying to find a language construct equivalent to higher order functions in the top 10 languages from TIOBE index. Here are my results so far: C - function pointers Java - anonymous methods, lambdas Objective-C - function pointers, selectors, blocks, delegates (as explained here) C++ - function pointers, lambdas B...
I have some fairly simple code (C#): /// <summary> /// Truncates a string to a maximum length. /// </summary> /// <param name="value"> The string to truncate. </param> /// <param name="maxLength"> The maximum length of the string. </param> /// <returns> /// The original string if its le...
In web MVC most designs I've seen, (just choosing model layer as an example) the domain problem class, say students, always inherits the superclass "Model." The name is irrelevant, but why do they always inherit classes instead of interfaces? I've seen others that have interface -> abstract class -> concrete class. B...
Is the following a statement of best practices in Node.js with regard to web applications? If not, how could it be improved? The statement The lifecycle of any web app has at least two phases: a setup phase, and a ready phase (when the application is ready to respond to requests.) In the ready phase, IO operations (di...
We are localizing all parts of our website to many languages. We use XML localization files. I think this scenario is so common, and even there should be a standard solution to this, but still I couldn't find any good advice, and every developer here has different opinion about it, so I'm asking you. Suggest the follow...
I've recently been looking at how me and my team uses Git and how our workflows work. We currently use a feature-branch workflow which seems to work well. I've also seen some individuals on our team use workflow based on git stash. The workflow goes something like this: Work on a main branch (like master) Make commi...
I came across this piece of code. It didn't look that right to me. Is this the right way to implement super in JavaScript? If not, what is the right way? function Person(name){ this.name = name; } function Student(name){ Person.call(this, name); } Student.prototype = new Person(); var a = new Student('test'); ...
I've seen lots of code like the following example. It's in Python, but the same mistake is made in all languages with managed resources: f = open('foo.txt', 'rb') for line in f: print line That's it. The error is that close(f) wasn't called so the file handle is kept open until some indeterministic time in the future ...
I saw Martin Odersky's "The Trouble with Types" presenstaion. He divided programing-languages in two dimensions in the "Type Systems Landscape" chart; A "Static/Dynamic" dimension and A "Strong/Weak" one. I searched to find a definition for "strong/weak type systems" and its difference from "static/dynamic" type-system...
See my Update at the bottom for more. I occasionally have projects where I have to output some data as an Excel file (xlsx format). The process is usually: User clicks some buttons in my application My code runs a DB query and processes the results somehow My code generates an *.xlsx file using either the Excel com ...
In http://semver.org/ — which in my perception seems to be the most widely used convention in versioning — it is recommended to increase the major version number when a change that breaks/modify the API is introduced. There are two related scenarios that I don't see how to apply this guideline though: What if my code ...
We all know GPUs are much faster than CPUs for a wide range of applications. When someone asks why we are not just programming for GPUs at all, one of the most common answers is that GPUs are not good for everything - i.e., they fail to do some things that CPUs do easily. Well, no wonder: after all, they are not meant ...
I see that the market is full of mobile apps based on card/board games. For example, do a search for "Taboo" and there are many results which are not published by Hasbro Inc. Is this legal? The top "Taboo" result says in the description that they are not associated with Hasbro--does this absolve them of infringement is...
I've been with my software team for about three years now, and just recently I brought up the concept of variable naming conventions (across all languages, but C#/VB.Net specifically). We really don't have any solid naming conventions. I was met with serious resistance - so what?, does it really matter?, blank stare...
Since, I am fairly new to large scale app development in Android and Java, I thought I would ask for advice. My team is faced with developing a prototype of a fairly complex medical software. Although it is only a prototype, I think it might be a good opportunity to learn a new platform and get into some good habits. O...
A friend of mine, a beginner PHP programmer, needs to link the product his company develops with a third-party product (a set of web services). He received the "relevant" documentation (a few hundred of pages of unreadable stuff) from this third-party, have read the PHP documentation related to SOAP client, have read a...
When we started our application we had the choice of going with the traditional MS-SQL normalized database or with a NoSQL database (RavenDB is what we tried out). Here is a simplified version of our schema: <Order OrderNumber="1000" OrderVersion="1" ...> <Products> <Product Code="X58" Price="$5.50" Quantity="3" ...
This days I'm reading some tutorials/advices about Kanban process and Agile methodologies, but I have two big questions about this Kanban methodology. What I understood is user stories are about adding bussiness value, like a feature which our customers can use. The main problem is we have a lot of features that looks ...
I have many model classes that are mapped from/to tables using EF. Two of them are User and UserCookie, which are stored in tables Users and UserCookies. public class User { public long UserId { get; set; } public string Fullname { get; set; } public string Email { get; set; } (...) } public class Us...
I want to start a new project and I just got in touch with Play framework, which has a ruby on rails -like approach that called my attention. I am not an expert in rails, but I think that the productivity in these frameworks are great. I am following some tutorials but I am wondering: Play has the Model, which is used ...
Suppose I use this ActionScript API released under MIT license to build a software: http://www.cove.org/ape/docs/api/ Can I sell that software? Do I need to give the source code of my software away? Is anyone receiving my software permitted to resell the software?
We are a group of developers working on a web application that accepts forms filled and sent by our users and present it in an overall view. Our main form view looks like this: There are multiple forms on this page. The form on the left is the parent form which contains general questions about the project. The right p...
We are two developers that have no previous experience in sharing one PHP project. In particular, cakePHP. We both use NetBeans and we have set the project up as a "PHP application from a remote server". For the project we also use git + bitbucket for version control as well. Now the problem is that whenever one of us ...
I'm developing a system to handle sending transactional emails to our customers. This is how it works: An event occurs during the order's life cycle, for example 'shipped' This event will trigger the creation of an email in the database (email queue) A separate windows service is polling the db table for new emails...
I'm developing a WPF application using Entity Framework for my database communication. The application has a hierarchy of tabs where each tab has a db context. Each tab allows the user to view some particular object, make changes, save, update, close or open tabs for related objects. My crux is that some tabs contain i...
I'm a web developer. I most often come across this critical situation when the website layout fits with the design when run on Windows 7 or 8 and Mobile Operating Systems (Android, iOs, Windows 8). But when the website is visited by old operating systems like Windows XP and Windows 1998 the whole layout collapses very ...
At one of my employers, we worked on a REST (but it also applies to SOAP) API. The client, which is the application UI, would make calls over the web (LAN in typical production deployments) to the API. The API would make calls to the database. One theme that recurs in our discussions is performance: some people on the ...
I have a scenario where my Java process will be receiving a stream of binary data: public class DataHandler { public void handleData(DATA data) { // TODO: Do something with data } } I am trying to figure out the proper typing for DATA. I could use a byte[]: public class DataHandler { public void ha...
In scheme when defined (define f (lambda (a b c d) d)) (define l (list 'a 'b 'c 'd)) Why it does not do argument destructuring? I mean arguments should evaluate first, why destructuring is not part of that? (f . l) What are reasons that this expression is not equal with following? (apply f l) Edited to make it cle...
I'm building an API for an ad serving platform that will allow you to request tracker data for ad campaigns. Campaigns often exceed hundreds of millions of requests, which means there will be many terabytes worth of data. Therefore we need to prevent API consumers from requesting too much data at once (such that the re...
In Chapter 3 of his book The Art of Unit Testing: with Examples in C#, Roy Osherove describes the concept of testing state change of a system. The example code under test he uses looks like this: public class LogAnalyzer { public bool WasLastFileNameValid { get; set; } public bool IsValidLogFileName(string fil...
I am trying to implement a domain event system that only fires its events when the associated unit-of-work commits successfully. The main reason why I want to do this is because I have other sub-systems that read the database that expect those changes to be in place when handling the event. I also don't want event ...
Today I realized painfully that for some decisions you need a good overall understanding of the system. Otherwise, the risk is too high that your assumption turn out to be wrong. Imagine that you are a developer for an online web shop. To understand the system, you have to understand many connected subsystems, for exam...
I'm trying to learn how to produce quality object-oriented code and have been studying concepts like SOLID. I'm currently working on an entity-component-process system for a small game engine. Currently, I have it implemented as such: There is a ScreenStack which contains a stack of Screens Each Screen has an EntityMa...
In our team, the product owner only gives us a 1-liner summary. The developers then come up with a PoC, which the product owner reviews and the cycle repeats. The challenge here is 2-fold: Time: We have to create the PoCs asap, so that they can be reviewed The Developers are actually defining the look and feel of the...
I want to use the WebFont icon library FontAwesome (FA) for all the icons in my project. They are using SIL OFL 1.1 for the fonts and MIT License for the source files. My problem is that, I want to use the FA fonts in my project, however I don't want to be tied to their CSS files. Is it possible for me to use the fonts...
I just solve this but want know more efficient way to do matrix multiplication M : ------ 1 1 0 0 0 5 3 2 0 f[n] = M^n I have implemented using Exponentiation_by_squaring Is there more efficient then this ?
We have a use case where we store table-like data, but we know about the schema of the data only at runtime. In our application, a power user defines a schema and normal user can create records and make relations between those records. The problem that we are having is that when doing complex queries over the related ...
Okey, so I have for a while now been thinking of rewriting the minecraft server, this time in a language called golang. It's just a example project that I can learn a new programming language through.. My question is: If I -rewrite- the minecraft -server-,: I read the Minecraft EULA, and they only talking about -modif...
I know there are multiple posts on similar problems, so please be kind with me. I am asking for suggestions I have not thought of and for good advice. I have a java "project" that is structured in a server-client pattern. There are some classes that are common to both parts but most of it is either server (backend and ...
In Object Oriented Programming, we're taught to think in terms of Polymorphism (the idea that the implementation is decoupled from the interface - and that it makes sense to think of the interface first). This is expressed by Eric Gamma (author of Gang of Four Design Patterns Book) Program to an interface, not an im...
Currently I am in process of writing large batches of Unit-Tests in the Project I am working on. Additionally we recently Introduced GUI-Testing. This project is a relatively simple webapp, on basis of Java EE 6. Now my colleage did write quite some GuiTests, and I did write quite some Unit-Tests. For both tests we nee...
I've recently been investigating SpecFlow and can see the value of it for writing client/stateholder specs which can show a feature's progress however I'm nervous of introducing them to a client... Imagine a feature: Given I'm on the "MyAccount" page And I enter "Liath" into the "Name" textbox When I click "Save" Th...
I have some experience with document-based stores (MongoDB and CouchDB) and I am interested in exploring wide-column databases. Based on my initial exploration I can grasp a basic understanding of how wide column stores are different, but I do not really understand in which type of operations they are a better fit than...
This question came up in one of my college classes. The professor only gave the answer that it was more descriptive, but it seems as though <b> and <i> are rather explicit in their meaning and is easier to type than <strong> and <em>. What were the official arguments for the deprecation of these tags?
I'm building a multi-tier enterprise application using Spring. I have different layers: Controller, Business and Provider. Within the application I've built a custom error handling mini-framework that is based on a single RuntimeException which has an error code to discriminate different kind of errors. Error codes ar...
I have more or less 0 knowledge in low-level topics, so forgive my possible ignorance. I know that in languages such as C, pointers hold 'memory addresses', i.e. strings (or binary data?) written in hex such as 0x52A132F3. Judging by the term 'memory address', I assume this number actually leads to some place in memory...
I've been spending some time on 're-tuning' some of my OOP understanding, and I've come up against a concept that is confusing me. Lets say I have two objects. A user object and an account object. Back to basics here, but each object has state, behaviour and identity (often referred to as an entity object). The user ob...
We have a django app hosted on heroku. I had a situation: A user entered an email in a form on page1. If the email existed in the database he was redirected to Login page otherwise to register page. In the register page the form was filled with the same email entered on page1 using request.session that was populated...
I have developed websites where users would register with a username of their choice and an entry would be created in a database table that holds their username and some sort of salted password. They would then use this account to interact with the services that the site provides. Now I am interested in providing the a...
I understand most of the basic Git/Github concepts by now, however I still have trouble understanding the bigger picture. These are some things that I have managed to get working so far: Push commits Work with branches Integrate Github with Travis CI, a continuous integration system Via Travis CI, automatically build ...
I am curious as to how dynamic web applications play with content delivery networks such as cloudflare, amazon cloudfront, etc. I understand the concept of a cdn obtaining a cache of your static pages and then serving those pages from their various servers relative to where the request is coming from. However when it c...
Say I have a Base class called Car and it has 3 derived classes say Ford, Honda and Audi. The issue is, all three derived classes have exactly same code but minor difference in calling member functions of their respective engines (these engines have separate class). For example, Ford class calls code which is exac...
The MASM32 documentation clearly states that the GPL violates MASM32's license, and therefore cannot be applied to projects built with MASM32. The MASM32 project cannot be used to create open source software or any other project under any form of licence that requires the user of the MASM32 project to surrender the ri...
I'm currently working on a game and wanted to add some scripting support. Due to trying to keep the entire codebase in managed c# (Excluding Monogame), I am using a custom language for the scripting (No managed only implementations of Lua exist...except AluminumLua which is incomplete). In such a language, basic provis...
I'm trying to teach an object oriented design principles course (on SOLID) at a training institute. I also want to teach the students a few OOP design patterns such as factory, singleton and one other. I know there is no 1 to 1 match between SOLID principles and OOP Design patterns, but I want to introduce the students...
I have a MyObject which has an x and y coordinate. as far as I can see, I can store it in three ways: class MyObject: def __init__(self, x, y): self.x = x self.y = y class MyObject: def __init__(self, x, y): self.position = [x, y] class MyObject: def __init__(self, x, y): ...
I'm currently working on designing a small web application (MVC5) and I'm to the point of designing my database. I have the schema I want worked out and I am quite proficient in SQL Server. (I have my SQL 2012 MCSA.) I'm going to be using entity framework 6 as my ORM. I've been quite interested in the code-first approa...
I have a World class World: def __init__(self): self.size = 10 self.n_busStops = 10 self.busStopMatrix = SpatialGraph(self.size, self.n_busStops, 1.0) self.buses = [Bus([0,1,2,3,4,5,6,7,8,9])] Now each of the buses are going to move around the world, dropping off and picking up pas...
According to one page on code.google.com, "left recursion" is defined as follows: Left recursion just refers to any recursive nonterminal that, when it produces a sentential form containing itself, that new copy of itself appears on the left of the production rule. Wikipedia offers two different definitions: In ter...
My team uses Agile as a development approach. Currently, each task has four states which are todo, in progress, testing, and done. We've just started doing code reviews, and I wonder if I need to create a code-review task or I should add time for code-review to the estimation?
I'm interested in building a browser-like rendering engine. I understand a bit about how OpenGL and GUI toolkits work. But how do browsers actually put pixels on the screen? Are they like software rasterizers that scan every line and paint whatever's in the render tree? Or do they act like GUI toolkits and call functio...
I couldn't find a better title for this... I am trying to create an Access Control for my application and I am having serious trouble with building not an insane system, mainly for performance as this system will reside in an SQL database and will be used excessively throughout the app (every query will be using it for...
I have inherited an ASP.NET website application and the previous developer has used what I believe are some DDD concepts. I am new to DDD and I have to admit I am struggling with the practical side of it having come from an N-Tier Transaction Script background. One of the problems with the site is that it is slow. Ther...
What algorithm can be use for task scheduling based on location? For example there are 100 students and 5 lecturers available. Each lecturer must get same amount of student using location allocation which is allocation of students depends on the nearest place to lecturer. The system must assign automatically students t...
When I'm doing large scale refactors I'm often commenting out the contents of methods and using NotImplementedExceptions for stuff that I still need to refactor. Problem is that this is interfering with 'valid' NotImplementedExceptions. I'm thinking about introducing a custom RefactorException, that I quite easily find...
I have a 'sequence of tasks' to undertake on a zip file. It can be simplified into these steps: Validate that the file is a ZIP file and is valid Unzip the file Validate the contents are as expected Turn the contents into a product I am currently using the Command pattern and it looks a little something like this in...
We (2 developers) are developing a cakephp app that is running on a remote server. In NetBeans we both have project set up as "PHP application from remote server". The problem is that whenever one of us modifies any of the files, they get instantly updated on the server, but not in the other developer's IDE. We have gi...
I have java application which takes a file, which is created by a process running on terminal. I start the process using a small shell script. Then run the Java application and it reads the file created by the process. Whenever this system runs created file need to be removed so that the process creates it using the sa...
I created XML parsing logic that forces XML to be formatted like this: <fooList> <fooObject value="SomeValue1" /> <fooObject value="SomeValue2" /> </fooList> And then I started to think that a more elegant way would be <fooList> <fooObject>SomeValue1</fooObject> <fooObject>SomeValue2</fooObject> </fooL...
I have a project of a community website, where people can alter/manipulate photos that they upload, in a particular way. For example, a person could select various contours and control points on their nose, and do the same for an image of another person's face, and hence morph their own photo so that it distorts the n...
My team is in the process of updating a legacy project. We've decided to incorporate the Repository Pattern along with Entity Framework in our Data Access layer. Below is a high-level view of this organization: IRepository<TEntity> is a generic interface used to perform common operations on an entity set: public inter...