instruction
stringlengths
34
19.9k
I have been learning python from no long time ago. But nearly at the beginning I stumbled on simple question: how to set a restriction (limitation) on object value or object's properties without making a difficult class description. There is no problem with python's unstrict typification. I search for the methods to co...
I am trying to make a program in Java which measure the complexity of a specific program with respect to its run time. Let's take a problem and code that problem in all possible ways with respect to time complexity, let's say we can write code for a specific problem in O(n), O(log(n)), O(n log(n)) and O(n^2). I will re...
I'm a little bit confused about code coverage criteria; especially condition and edge coverage. As stated in this book, edge coverage does not subsume condition coverage; BUT my lecture material defines condition coverage in the following way: Edge Coverage Criterion: Select a test set T such that, by executing a progr...
It seems to me that this is often encountered in practice and I was wondering if there is a design pattern for the following: Suppose I have a class that represents a card: public class Hand { private static Random rng; private Rank rank; private Suit suit; public Hand() { if (prng == null) ...
I have an admin controller that is just used for its index action which renders a view with the most recent updates to certain resources: class AdminController < ApplicationController before_action :authenticate_user! layout "admin" def index @events = Event.last(3) @foos = Foo.last(3) ...
I don't know how to word this easily but basically the software I am writing has a ton of actions and I want to assign hotkeys to every one of them so power users can work super fast. First off they are not actions related to the application itself, i.e. Quit, Maximize Window, About, Preferences, etc. But rather actual...
I've worked on a large financial transaction system for a bank that looked after Pensions and Investments. After 15 years of feature changes, the manual regression test cost had climbed to $200K per release. (10M LOC, $10M transacted per day). This system also interfaces with 19 other systems around the company moving ...
All of the below relates to a ASP.NET c# app. I have a Singleton Settings MemoryCache that reads values from database on first access and caches these, then invalidates them using SQL Service Broker message and re-reads as required. For the purposes of standard controllers, i create my Db Context in a request scope. Ho...
I would like to hear some improvement suggestions for mobile development (Android/iOS) project architectures. I would like to go for a "safe" design, modular and that can be easily maintained in time. As far as I know Android and also iOS platforms are built on MVC, at least have the Activities and UIViewControllers th...
While writing in C, I have always wondered about when is the best time to use an external variable. I generally prefer to pass a pointer into a method. Is there a correct time to use an external variable and a correct time to use pointers?
So imagine the following the happens (and that we're all using SourceTree): We're all working off origin/develop. I go on holiday for a week. My coworker has been working locally for the past several days without merging origin/develop back in to his local develop branch. He tries to do a push, gets told he has to me...
I have inherited of an application and need to reorganize and I hope I will be able to modularize the tons of Javascript that is everywhere. It is a multi-page webapp. Each page has a script tag in the header, which currently contains a DomReady handler which initializes all user event handlers for that specific page, ...
The commentator here offers the following criticism of green threads: I was initially sold on the N:M model as a means of having event driven programming without the callback hell. You can write code that looks like pain old procedural code but underneath there's magic that uses userspace task switching whenever somet...
The C99 standard says in 6.5.16:2: An assignment operator shall have a modifiable lvalue as its left operand. and in 6.3.2.1:1: A modifiable lvalue is an lvalue that does not have array type, does not have an incomplete type, does not have a const-qualified type, and if it is a structure or union, does not hav...
I'm interested in creating an chess endgame solving engine. The endgames in chess are usually solved using the endgame table-bases generated by retrograde algorithm. I have found that Artificial Intelligence and Genetic Algorithms have been applied to the chess programming. However, before starting the implementation ...
I distinguish three organisation levels while programming: the library level, the component level and the application level. A library defines functions to solve a range of related problems or preform related operations in tools and no policies manner. An application lets several libraries interact and defines policie...
I'm currently working with a company that uses Java / Tomcat / Spring for the back end of our web applications. As a front-end developer, I'm feeling more and more strongly that the back end should be a separate project from the front end, for a few reasons: 1) Building the project - many modern projects build with gr...
How should I go about evaluating the performance or execution time of C++ with CLR versus native C++? My personal bias is that I believe C++ with CLR to be slower since it has to run on a virtual machine. I will also admit that I have never really been a fan of Visual C++ due to the syntax that has been added, so I wa...
I am making a WPF application following MVVM model. I have seen some approaches for applying MVVM. I am concerned about my MainWindow.xaml. In some tutorials I have seen that MainWindow is only hosting a ContentControl, and in some first main page of the application. I am making a wizard type application. There are mul...
In the evaluator of a custom language, I would like to replace our own sort routines with std::sort or other routines, possibly tbb::parallel_sort. The problem is that we allow users of the language to supply their own comparison routine, and in the implementations I have tried, std::sort does not take kindly to routin...
Is it ever really acceptable to reassign the model for a view in MVC? (Or MV* where applicable.) In other words, for a single view instance, is it ever ok to reassign the view's model? That is, as opposed to using setters (mutators) on the model so that it does not have to be reassigned. Under what conditions (if any) ...
Kind of a best practices question: is it better to merge directly from the source to other branches or is it OK to merge from a merge? Using Subversion for source control. Scenario: Branch A has changes made and committed. Branch B and the Trunk both need updates. Case 1 Merge from A to B and again from A to Trunk. o...
While working with asp.net, I came to an approach that uses asp.net services for the data/business logic layer and html/javascript/jquery for the UI layer, because I could not reach the needed level of customization of the user interface with asp.net web controls. While I've seen plenty of books describing usage of asp...
Here is my Solution and projects: BookStore (solution) BookStore.Coupler (project) Bootstrapper.cs BookStore.Domain (project) CreateBookCommandValidator.cs CompositeValidator.cs IValidate.cs IValidator.cs ICommandHandler.cs BookStore.Infrastructure (project) CreateBookCommandHandler.cs ValidationCommandHandler...
I'm having trouble formulating this problem as an algorithm: I have a set of conditionals (combined with &&) and operations, for example: if (A && B) execute C else if (D && A) execute E I want an algorithm to find the optimal "if-else" tree that minimizes the amount of duplicate code. The optimal branching fo...
A new requirement has surfaced on an old codebase, that basically enables direct (internal) communication between two formerly not-directly related classes of users (stored in different tables with completely different schema and, sadly, the code is barely OO-aware, much less designed, so there's no parent class). Sin...
As a beginner to J2EE, I have recently started developing my own project from scratch using the Core of J2EE : Servlets & Jsps. I could not evaluate whether my project folder structure is right or not. Here is my project folder structure. Before asking question, I admit that I could not answer or neither justify if so...
My MVC (.NET) has some constant values through out the site, such as the phone number, physical address, email address etc. I'd like to store this value once, so future updates are easier for when they change their details. To make my question simpler, I've only focused on phone number. My question is where and how to...
Why does DrRacket (kind of Scheme) IDE highlights some of the identifiers as "keywords" (for example define, lambda, send*), and the others as "symbols" (user defined identifiers, +, -, abs, send, send+, etc.)? I am particularly confused by the difference between send* and send+. For reference, here are the beginnings...
Forgive me for my poor English, me and my friend were doing school homework, suddenly he asked me to read this line of code ptr = &array[1][1][1] (ptr is a pointer to an integer). He said ptr is pointing to the address of the second element of the second column of the second row of an array. I think he will be ri...
I'm starting work on a new personal project and I'm looking to get advice in regards to setting up my classes. My base class is a User. The User class will have the following general properties User ID User Name Password Address (this will be a complex/value type) I will then have a Subscriber class which is a User w...
I have a main application that can load modules (or plugins). Each modules can define one or more links (or items) that will be displayed in a side menu defined in the main application. Right now, my main application execute a list of ItemProviders which are loaded from the modules. These ItemProviders return a list of...
I have a bunch of classes that look something like this: public class MyGame() { private Graphics graphics; private Player player; public MyGame() { graphics = new Graphics(); //... } protected void Initialize() { player = new Player(); //... } pro...
Is there an algorithm that, given a sorted array, swaps all the first unique elements to the beginning of the array and the duplicates to the end, while remaining stable for both the unique subarray and the duplicate subarray, and that runs in O(n) swaps (and preferably one pass)? It should return the length of the uni...
I am using Microsoft ASP.NET Web API 2 and one of my end points has to internally invoke a legacy non-Microsoft web service (not asmx or svc) . Which layer should I invoke this in? I currently have : Repository layer: where all the CRUD calls to DB are done now. Domain Manager: where respective manager classes invoke t...
The question is fairly self-explainatory. Is it worth using VCS (Version Control Softwares) for hobbystic/small/personal projects?
After reading lots of pages on various sites, I came to the conclusion that abstract data-type (ADT) helps to separate the use of a data-structure from its implementation. We can easily map the data into a data-structure by using an already available abstraction. And this abstraction is called ADT. Please tell me if I ...
Lisp and Fortran were the trunks of two separate evolutionary trees, one rooted in math and one rooted in machine architecture. I see this in Hackers and Painters: Big Ideas from the Computer Age. And someone said that Lisp are Human oriented and Fortran are Machine oriented. Here human oriented means that the w...
I have gone through many Google App Engine tutorials, and I became quite familiar with how to do basic stuff like implementing a webapp2.RequestHandler, and using ndb.Models to manage your data. Now, I kind of reached a wall with a few small concepts that were either missing from the resources I went over, or I simply ...
I'm having quite some doubts here... If I have a table related to username/password login how can I assure there won't be any more matches of the same username and password in the same table using sql? For example: >username: username >password: password ^this user just signed up. So the following conditions apply: 1...
I have been asked this question and even after a lot of research, I cannot find the answer. When I design a database using Entity relationship (ER) and then re-draw it as UML class model (extended with Data modeling profile for UML), what are the differences and how both models can be (in their way) useful for db devel...
When you read C, C#, Java, Python, PHP and many other programming languages all the syntax is written in English. Simple code like this if (X+1 > 4) { } while (A == true) { } Is written in English even if the programmer's native language is something else. Would it not be more effective to allow the programmer to use ...
I'm trying to teach myself some design patterns using a book that I was recommended, Head First Design Patterns. I came to the chapter on the Decorator Pattern, and although I understand the purpose of it, I'm a bit fuzzy on it's layout. Here is their basic UML of the Decorator pattern: Imgur (Sorry for the link, but S...
My research-based company's name is already taken on github (mailed the owner without any luck), what is the most recognized naming conventions for company github accounts besides the name directly? the only ones I found was ibm-dojo and ibm-research
Why do need namespaces when we have nested classes. What can be done through namespaces, can also achieved through nested classes. so I don't understand the reasoning of having namespaces ?
I have seen many frameworks and modules and their standard they follow is like this UserInterface which have some predefined methods AbstractUserClass which implements userInterface Then GenericUserClass which extends from AbstractuserClass Then other classes extending from that generic Now I have seen that abstract ...
I was looking into an open-source game framework project written in Java. It has several classes that: Have public instance variables. Have getter/setters for such variables. Generally, I write getters/setters when I want to encapsulate some behavior that occurs when a property is modified. However, looking at the co...
We are trying to start a web base project that need to develop based on MS technologies such as C#,.net, IIS etc. This is a web application suppose to sell as a product with a single installer. Now we are discussing which kid of database we are going to use. Some says non-embedded database (Ms Sql) Some of them idea i...
I just stumbled upon Clojure reducers library. It looks a lot like loop fusion. However the term is not mentioned anywhere on the page. Is there a difference between the two?
Foreword: In this post, I will make the common confusion between O(n) and Theta(n) as complexity notations. I will write pseudo-code to talk about algorithms, using whatever notation I find to my liking. I know, yet another question about nested loops and complexity. I recently wrote a nested algorithm, that would w...
I am writing a client server application. I wanted to fully separate the server logic, from the view. The first thing I wanted to to, is to make a sort of a message log. The server itself should not know if the messages will be shown at a GUI, or on the console. What I was thinking, would be to have a handler method, t...
I am using a LGPL v3 library and have made upgrades to it. Before using these upgrades, I understand I have to publish them. That's al-right. Is it legal if I perform upgrades that use a commercial library of my own (upgrades will be published, but not my commercial library)? Note: usually, questions are the other sid...
I am working on a list comparator to assist sorting an unordered list of search results per very specific requirements from our client. The requirements call for a ranked relevance algorithm with the following rules in order of importance: Exact match on name All words of search query in name or a synonym of the resu...
I'm designing a multiplayer game server where the players are in rooms. Right now I have classes to take care of the client, networking, etc. I'm struggling however to find a design for this Room class. For example, when I want to change a client's room, should I call client.changeRoom(newRoom) or newRoom.addClient(cli...
I'm trying to find a way to collect data from different servers around the world. Here are the details: There is only one single PowerShell script on servers that encrypts data (simple csv file) and sends with preferred method (HTTP/HTTPS Post could be) There is no more control on that servers. Can't install any servic...
In Android, final strings are stored in a strings.xml file, which makes it easy to update text, reuse strings and to translate an app to a different locale -- because everything is in one place. However, in all the examples that I have seen of desktop applications all the strings have been hardcoded into each class. I...
Use case: For an administration UI, I want an interactive table widget with a number of behaviors: Collapse / expand (yes, this means the rows are a hierarchy) Update of data in a child cell based on a parent cell. Hiding or revealing of a row or an entire sub-tree based on a value update. Two or more form elements in...
ok, am just looking for a win loss code example. This can be for any language, just wanting the outline. Fairly new to programming, so dummy it up for me :) I can do (win-loss/total of win loss). Guessing that is a good standard win loss ratio, but I don't want a new person that has 1-0 to be ranked higher than someone...
I'm developing a small open-source javascript library, and I was wondering about the proper method for compiling the source into one javascript file. It's easier to develop if the code is split into multiple files, but libraries are included as one large file when used in another application. My current "compilation" ...
In alloc.h of djbdns-1.05 there's the following code: extern /*@null@*//*@out@*/char *alloc(); My question is about the goofy-looking /*@null@*//*@out* “decorator.” I assume this is “just a comment” with some significance to djbdns's build system. But I can't find anything referencing it in other files. Anybody know ...
Often you can see answers like “Avoid using C libraries in your C++ code“ or “This can be rewritten using STD/Boost in pure C++“. I understand C++ produces more maintainable code and has many advantages, but is it actually bad using C libraries when performance is a priority? I mean writing in what is sometimes called...
If java/C#/etc one might do something like create a constructor with a parameter, the parameter being the thing the rest of the object may act upon. How is this done in JavaScript? I'm trying to figure out what the best practice is with JavaScript to do something similar to this C#/Java Object. public class Blagh{ ...
Is it a bad idea to add a new method (that implements a new algorithm) to a class library for its new version and expose a version option the consumers can select? It is just for backward compatibility where an old application might need a constant sequence of random numbers for a certain seed number. The following co...
The book C++ Templates: The Complete Guide, (c) 2002, looks very appealing to me, but as it's 12 years old, I'm concerned it may be out of date. There are some highly favorable Amazon reviews dated as recently as a year ago, and I don't see any other very recent titles on C++ templates. Does anyone know whether a boo...
Is it really necessary to mention the same impediment (blocking issue) in every daily standup, if the whole Scrum team already know about it because it's been mentioned at previous daily standups?
I have read several posts which discuss coding standard for naming the unit test methods for improving readability. I follow this NameOfMethod_ExpectedBehavior_WhenSomeScenario, but now I am confused as to how should I continue with this in the face of overloaded methods. There can be several methods with same name but...
At choosealicense.com/licenses I am reading the Apache licensing, and see that under Permitted there stands Commercial Use: This software and derivatives may be used for commercial purposes. Meaning, they can use (and modify) my app, in a commercial environment (e.g. Microsoft, Apple). Or, they can commercialize my a...
There seem to be quite a few ways of communicating between directives. Say you have nested directives, where the inner directives must communicate something to the outer (e.g. it's been chosen by the user). <outer> <inner></inner> <inner></inner> </outer> So far I have 5 ways of doing this require: parent directiv...
I am writing a parser (a parser generator for PEGs) and am trying to figure out how to report errors. Grammar: rule: (a b)? a c ; Input: a d Question: Which error message correct at position 2 for given input? expected "b", "c". expected "c". So should it be taken into account that "b" was also expected at position...
I am very new to programming and my first task is to create a WCF service that will take an ATOM feed and expose it to my application. Now, I've read up on XML serialization and syndication but it doesn't seem to be what I need in my (lack of) experience. Here is a snippet of the feed. It's generated by a seedlist spi ...
Let's say that we have a structure like this: Application -- Modules --Module1 -- Controller -- PublicHelper --Module2 -- Controller -- PublicHelper Whereby a module's Public Helper can provide helper functions. In nearly every module helper, the help...
I've done some searches for "id mapping" and "external id mapping" and I can't find anything meaningful on the site or google, so, here's my question/scenario. I'm developing an application which will match some records from our internal system with the "same" records from an external (outside the company) system. The ...
I work in embedded systems. Right now, my organization has two full-time programmers and two occasional programmers. It's rare that the same project is worked on by two programmers. All code is stored on a network drive. There are folders for the current production code, another folder for the source for every released...
Here is how I see the main differences between the DAL and the BLL: The DAL directly query the database. The DAL doesn't create new information. It may execute complex sql requests, joining several tables, but the result of such a request never gives any information that wasn't already in the database. The BLL applies...
Current Scenario Our application allows users to upload (Amazon S3) and manage their files through our interface. Currently those users can download the files directly from S3/Cloudfront through our application. Adding a Zip feature We would like to add a feature to the system that allows users to select multiple file...
The hot topic in our organization is Service Design Approach. First Approach - The team wants to design services which essentially have one operation, can take any XML and return response XML message. The operation and the parameters are in the request XML message. Once the message is received the service determines t...
I am confused about this: what type of data can we store in register variables? I guess logically we can store any kind of data as register variables because they are variables, but really I am confused. I have tried to search on internet and in my book. I couldn't find the answer. By book I am referring to ANSI C's pr...
Consider a database table of Items that have a status flag represented by an integer. A few of the status might be: 0 - Past Storage; 1 - Current Inventory; 5 - Scrap; 6 - Rework; 15 - Processing; Now, I would like to avoid passing and querying for 'magic numbers' in my code, and in the past I have used a Dictionary ...
So there's this desktop application. And I am wanting to inform it's users that a new version has been released. Is it more correct to say that a new version of a desktop application has been 'released' or 'deployed' (as with a web app)?
I have written software and have granted usage rights to different companies per contract. Is it possible to change the software licence to an open source licence afterwards? At what circumstances is this impossible and how will this affect the current contracts? Like one of the companies is allowed to modify and resal...
The Situation We are writing a REST API that performs validation up-front. The code is written such that it tries to find as many errors as possible. However, each error might correspond to a different HTTP status code. Additionally, the client (the HTML) doesn't have a convenient way to parse/display the errors. The Q...
In some code I'm writing right now, I have something like this: if (uncommon_condition) { do_something_simple(); } else { do(); something(); long(); and(); complicated(); } Part of me thinks "It's fine the way it's written. Simple cases should go first and more complicated cases should go next....
I'm very new to git, but last week I installed it, set up bitbucket, and pushed my current project to my first bitbucket repo. All went well and I'm pleased with git as a simple, powerful, yet free way to back up my source code offsite, as well as keep track of my changes. My next step is to keep track of actual versio...
I'm writing a library to create and manipulate Word .docx files in Python. In general, I take a lot of influence from the Microsoft VBA/C# API for Word in designing the API, figuring they've given it a lot more thought than I'll ever be able to. Several times I've found the wisdom in designing it the way they did only ...
I have a DevelopmentConsole class. I am making functionality to register console commands for the subsystems. I don't want the console to know about them but also I don't want them to contain a debug code (like "Console.RegisterCommand..."). I think I should make an additional class hiearachy. For an example I have Pla...
[Normally I post on StackOverflow but as this is more a design/theory question rather than a code question I'll give it a shot here] Most of my applications currently use a core object model that I originally wrote 6 years ago and which has just grown as needed - as with most of my stuff, it was coded as is, without th...
If we make reference to the parent for each node in a tree, do we still have a tree (by definition) anymore? Wikipedia definition is: In computer science, a tree is a widely used abstract data type (ADT) or data structure implementing this ADT that simulates a hierarchical tree structure, with a root value and sub...
I'm a self-taught programmer. Up until now I haven't had too much problems building things I have wanted to. Historically, given an issue, especially one I have caused I haven't had much of a problem figuring it out. This all changed about two months ago, when I was offered my first position at a company whom I became ...
I appreciate that this question may be controversial. In a sense, it is the flip-side of the question "Business trying to make technical decisions". In Scrum, the development team is supposed to be collectively responsible for making design and technical and code-level decisions, to fulfill the customer requirements. T...
I have a service architecture composed of services that service common areas of the application. Examples of services would be: AccountService (manages client accounts in the system) BillingService (bills clients for products that are configured) UserService (manages user and groups under a given client) NotificationS...
Currently my company has a Visual Studio solition in an SVN repo that's organized as follows: SolutionFolder (~3.5 GB) |-> SolutionName.sln |-> .. Some source code folders... (~250 MB) |-> ThirdParty (~3 GB) |-> Tools | -> Tool1 | -> Tool2 Tool1 and Tool2 are build independently (have their own solutions), but...
When you create programs (like a socket server) that are designed to run on an operating system, such as Ubuntu, frameworks like Qt for C++ use something called a main event loop: app = new QCoreApplication(argc, argv); int rc = app->exec() Now programming language like C or C++ enable a program to make system calls t...
I've found a GitHub project I'd like to add some features to. After contacting the maintainer, the changes aren't in line with the direction he's going but he's interested to see what I do with it. What is the GitHub etiquette for using one repo as a base for another project that almost certainly won't ever be merged b...
Is there a way to have a "critical update" for my app on the Google Play Store that would require the user to update the app to keep using it? For instance, let say I push an update that brings a few bugfixes. Nothing mandatory, the user updates it if he wants to: that's a non-critical update. Now, say I correct a very...
I need to add a feature to some code in a big project and due to the complexity I find it very helpful to add detailed comments to many lines to keep track of what's happening. This is only for my own understanding however and I will delete the comments before pushing the code. The problem however is that if I do priva...
I have a project licensed under the GPL. However, it includes a bit of code from animate.css, which uses the MIT license. How would I include the appropriate licensing information for that CSS? I've included that bit of css (maybe 25 or so lines) in my main stylesheet, so I'd rather not have a huge stamp like what's on...
I am developing an Android app in which I have to add chat functionality. Also, I have to save the chat history. I will accomplish this task using SQlite. But, I am not sure whether should I consider using an ORM like GreenDAO or ORMLite or I should use traditional way of persisting data in SQLite. Actually, I am not c...
I am working on an application that expected to the user logs in when the application is started (as for example it is in Skype: the user open the application and appear to him a login mask when he insert the username and password to start work with the application) Now I am preparing some use case diagram and I am col...
I'm building a new report generator for our in-house survey system. (No I can not use any off-the-shelf software. These are highly customized reports.) I want to use Topshelf to host the generator as a service. Our current generator is a desktop-app and requires a user to be logged in on the server. I want to try to av...
I recently interviewed with some companies that do Agile, Scrum to be more precise and there are some things that don't quite seem like Agile to me. I'll take one case that particularly interests me right now, that of Scrum sprints. One particular project manager I talked to (yes, I said project manager) proudly stated...