instruction
stringlengths
34
19.9k
I am working on adding existing SQL scripts to version control. I have Team Foundation Server 2012 set up with Visual Studio 2008 and SQL Server Management Studio 2008 R2 with the MSSCCI. I am fairly new to TFS so I do not know if I am missing an easier way of doing things. Managing SSIS projects and even SSRS projects...
While I was writing a private helper method in Java, I needed to add a check for a precondition that would cause the method to do nothing if not met. The last few lines of the method were just off the bottom of the editing area in the IDE, so in an epic display of laziness, I wrote the check like this: function(){ ...
I'm working on a Java library for sorts for Magic: the Gathering. Well, without going into a lot of detail, in the game there are five different colors of magic: white, blue, black, red, and green. That's easy enough, that's a textbook example of an enum. However, there's a problem: there are several variations on t...
I have a legacy application in which the UI and business logic are already reasonably well-separated. There is a proposal to separate them even further, turning the core application into a "service" (without UI) and writing a kind of "UI Server" as part of it to which various UIs (potentially in various languages, and ...
I have the following small function that uses foldr to find the largest second number of a 2-tuple: listMax :: [(Int,Int)] -> Int listMax = snd . foldr (\(_,freq1) (_,freq2) -> (0,max freq1 freq2)) (0,0) My question pertains to the body of the lambda: (0,max freq1 freq2) I had to make it into a tuple with a dummy hea...
So i am right now exploring some topics in a proof course and it occurred to me to try to create a boolean tautology solver. I would like an algorithm that is more efficient than brute force. Problem Statement: given a string of '(', ')', '[and]', '[or]', ! and pieces of text that denote variable names (which by defini...
I have a flight planning system in .NET/SQL Server which needs to perform several validation checks. This needs to work on both a windows and a web client. Currently the checks run synchronously but this is slowing the system down, plus it is often repeating the same checks. Like "is this aircraft in the right start lo...
I have come from a transaction script world and I am just starting to take a look at DDD. I am unsure of the correct way to integrate a DDD design with database persistence. This is what I have: A service class called OrganisationService whose interface contains methods for retrieving and saving away instances of Organ...
I have a REST API to manage a booking system I'm searching how to manage this situation : A customer can book a time slot : A TimeSlot resource is created and linked to a Person resource. In order to create the link between a time lot and a person, the REST client send a POST request on the TimeSlot resource But if too...
I have always "custom developed" software for clients. This means: Develop the software Install SQL Express on client site Import DB, create DB user, set DB permissions etc. Install software on client site (multiple pc's) Voila! Now, I am looking at deploying your basic "end user" app, to a mass of unknown audience. ...
That must have broken a lot of peoples code bases right? Everyone who had a variable named "nullptr" (which I think would have been fairly common) has to find "nullptr" and replace with "something_else" before being able to compile with c++11. Does the standards committee assume that people will do that much "adjustin...
We recently had to re-invent a high-availability queueing engine like RabbitMQ (for various reasons). Naturally this turned out to be more time consuming and expensive than expected. What type of things would you avoid rebuilding at all costs? Which types of components should rather be reused?
I'm working on an open-source project and people can use it and modify it, no problems here. The only thing that I don't want to allow is that people exploit it and earn money using my work (because that's what my plans are!) What kind of license should I use to cover these requirements?
I see the main purpose of continue in programming, it can get you out from the rest of loop steps like: while(condition1){ ... code ... if(!condition2){ continue; } ... code ... if(condition3){ break; } ... code ... } I understand that condition2 and condition3 might depend on the inner code so i...
I was working on a project three months back, and then suddenly another urgent project appeared and I was asked to shift my attention. Starting tomorrow, I'll be heading back to the old project. I realize that I do not remember what exactly I was doing. I don't know where to begin. How can I document a project such tha...
I am learning about random forest and found this video https://www.youtube.com/watch?v=gdnIqGbqiYs&list=UUb9svouAi1XHRqlOs8LXbBg very useful. The first 8 minutes explain how to visualise how the feature space is partitioned as the tree is populated during training. In the video however, the partitioning is only explain...
I have a general question regarding best practices. I have a small team working on a medium-scale software project, which involves integrating code from different environments, etc. The project is a standalone piece of desktop software. Based on lessons learned from a similar prior project that went badly, I am trying ...
I have inherited a legacy web application many years which: Does not make use of Object Oriented principles, even though the language would permit it Has no unit tests, nor any sort of test suite, automated or not Generally ignores various general best practices making the code very hard to read and maintain Splits it...
I have 3 forms. Form 1 has information inserted into Form 2. After clicking a button on Form 2 to get to Form 3; on Form 3 I pull data and put it on Form 2. The problem with this is that I don't know how to get a single instance of Form 2 so that I can keep the data from Form 1 after pulling data from Form 3. This is a...
For example, there is a model of an event with certain attributes that can be adjusted by existing processes: maybe one that looks at a geo-location stamp and determines a nearby city; another that looks at the number of registrations and applies rounding; another that calculates local popularity based on attendees vs....
I'm working on a medium embedded application in C using OO-like techniques. My "classes" are .h/.c modules using data structs and function pointers structs to emulate encapsulation, polymorphism, and dependency injection. Now, one would expect a myModule_create(void) function to come with a myModule_destroy(pointer) co...
At work we have a varied number of websites selling second-hand products. The bosses have noticed that there's often some overlap between the products sold on some of the websites and would like to syndicate content from one site to one or more of the others. The main problem I'm having is that taxonomy on each site is...
I am currently working on a Ruby on Rails project which shows a list of images. A must-have for this project is that it shows new posts in realtime without the need of refreshing the web page. After searching for a while, I've stumbled upon some JavaScript solutions and services such as PubNub; however, none of the pro...
C++ has plain multiple inheritance, many language designs forbid it as dangerous. But some languages like Ruby and PHP use strange syntax to do the same thing and call it mixins or traits. I heard many times that mixins/traits are harder to abuse than plain multiple inheritance. What specifically makes them less danger...
Is it a fair assumption to say that an overloaded constructor for a class can be thought of as a 'duck' for duck typing? Let's say that ClassA has an overloaded constructor, it would stand to reason that the different constructors are there for a reason -- the object is being used in a manner that indicates all of its...
I've been learning about using a hashtable to efficiently check for items in a list without looping through the whole thing, but there's one thing that I don't get: Why hashed keys? It seems like: var wordList = { 'aa' : ['aa'], 'aah' : ['aah'], 'ahhed' : ['aahed'] }; Would work just as well as: var word...
When developing for the web, I often find myself wanting to pass a few variables from the server scripts to my javascript - data pulled from a database, and set differently on different pages running basically the same code. (Typically, this is something along the lines of example.com/slideshows/1 needing to know that ...
Background I am developing a WPF project. This is the basic structure: User Interface (WPF Project); Interfaces (class library, contains all the interfaces and the entities used by the application; Modules (every module contains the logic of a specific argument, e.g. File Management, and can eventually contains Wpf Us...
In a typical spring mvc validator class, while inserting an errorCode value in the Errors object, what difference does it make between using a String (props.somefield.req) like so errors.rejectValue("elementId", "props.somefield.req"); verses a declared static final String ? private static final String SOMFIELD_REQ =...
I have been dealing with programming for several years now (I am still a student but with a lot of internships). Mostly working with C++, Python and MATLAB, I noticed that whenever I download an SDK or a library from Internet/GitHub and look inside, the code is much more complex than mine, using error catches everywher...
I'm attempting to build a browser-based HTML5 application that has the ability to store data locally on a PC (not mobile device) when offline. This data is sensitive and must be secure. Of course the trick is trying to find a way to be able to access the secure data with Javascript. I've ruled out browser local storag...
I ran into an interesting theoretical problem a number of years ago. I never found a solution, and it continues to haunt me when I sleep. Suppose you have a (C#) application that holds some number in an int, called x. (The value of x is not fixed). When the program is run, x is multiplied by 33 and then written to a fi...
I know that programming languages can be defined in EBNF which can be converted into regular expressions. Right now I am working on a very simple BASIC interpreter for a project. The code has to be entered in a gui which should validate the syntax to later transfer the code to an embedded system where it is executed. I...
I want to build a cross platform(Android, iOS, Windows) mobile application. I want the UX of the application to be different on the different platforms so that it will be more platform specific and does not force different platform users to stick to a common UI, as this common UI might not gel well in terms of look and...
We're about to start with a new software and there are mixed opinions on the organization of software. I'd be delighted to hear what others might have to say in regard to the presented options as well as what other consideration one might refer to when making such a decision. Hierarchical approach Interchangeable appr...
A friend has written a programming language. It has a syntax reminiscent of SGML. He has written an interpreter for it, and an IDE. He and his colleagues use it in-house as a server-side language. It can also be used to write command-line tools. He wants to make it available to the public, in the expectation that peop...
I'm looking for a book to learn how to implement interpreters for programming languages. Thing is there are much more 'compiler books' than 'interpreter books'. So my question is: can I read a book that teaches how to build compilers, to learn how to build interpreters (at a very beginner level)? Is this a good idea? I...
Suppose you have a setup where there is an API Server and all interaction revolve around the API. There is the admin, public and third party components that interact with the API server. Suppose we have an e-commerce model, the components' have the following capabilities: Admin - ability to manage products, orders and ...
In my company we use MS Dynamics AX 2009. This is the ERP of the company. We have around 100 users. The servers of MS Dynamics AX are in the headquarters company. We are developping a new website using Play Framework and Scala language. However, the website server isn't in the headquarters company, the dedicated server...
The question is how to cope with absence of variable declaration in Python, PHP, and the like. In most languages there is a way to let the compiler know whether I introduce a new variable or refer to an existing one: my in Perl (use strict) or \newcommand vs. \revewcommand in LaTeX. This prevents from two major sources...
The WPF Combobox needs to bind a collection to it's ItemsSource and something to bind the selected item or value to. Until now, I've included both the collection and the selected value properties that I'm binding on the ViewModel that is responsible to the given view hosting the Combobox. Lately, I've been reviewing ho...
I have to develop an Android library that should frequently communicate with a server in the background. Access to the lib Object should be guaranteed everywhere in the Apps that will use it, so I decided to extend the Application class from Android API and return the instance created when an App is started, every time...
I have a sequence of permutations formed using these strings: "A", "BC" and "D". The permutations are: BCAD ABCD BCDA DABC ADBC DBCA Now I need to reverse engineer this; i.e. I have a text file containing the sequences, I should be able to tell the strings that are used to construct the permutations. What algorithm I...
In a running multi-year multi-team project there is a set of stories that have been fully estimated and closed, having fulfilled the definition of done. Time has progressed and possibilities in Jira Agile have advanced, making it more useful to group user stories using an Epic to describe the total goal of the set of s...
What is / are some recommended ways to write JavaScript as to control behavior of showing HTML on screen, while keeping well-maintainable code? Basically, I started to look for ways to keep HTML/CSS out of JS (assuming it's the recommended practice), but I might as well check into the latest ways of writing JavaScript...
Currently, I'm working with a group on building a model. This model simulates interactions between many "agents" in a region. Agents can be any entity such as a city, a farmer, a business etc. Each agent is represented by its own object within java. Each agent will need to be able to interact with all of the other agen...
Let's say I have a database of persons who have some properties. For the sake of this problem let's say all of these properties relate as N-N. I can either create two tables for each property (one for different values and one for cross-referencing them to the main object). Or, I can make the following structure: Basic...
I had learned sometime ago that abstract classes should always abstract their functions to an interface. So instead of having something like this - abstract class a{ public int i; public int foo(); } class b : a{ public int foo(){return 42;} } we have something like this - interface Ia{ public int f...
I have an ERP, coded with Java and the database in MYSQL Community edition. When I was going to sell it to a client he asked me for the sources to my application (with the belief that it is GPLed). I already got an upfront payment from him. But now he asks me to deliver the source code for my ERP with the executable. ...
For a distributed system, there is a requirement of observing the progress of smaller applications on distributed computers (runtime 5 - 20 minutes). There is a web fronted, which right now only shows a list of those smaller applications (called jobs), with the state of each of them, like preparing, running, finished S...
As I get it, domain events imply loose coupling and separation of responsibilities. That's fine. But if domain events are allowed to cross aggregate's boundaries then it is a question how to guarantee that all concerned entities are materialized from persistence storage? For now it looks like events can only bubble thr...
In C#, the following code is valid interface I{ int property{get;set;} } Which doesn't make any sense to me. This seems to break one of the most important principles of interfaces: lack of state (in other words, no fields). Doesn't the property create an implicit private field? Wouldn't that be really bad for int...
Let us assume I have the following C++ class: class MyFastMessageEncoder { public: MyFastMessageEncoder() : m_fieldEncoder(ENCODING_STYLE_DEFAULT) { } void set_encoding_style(const EncodingStyle encodingStyle) { m_fieldEncoder.set_encoding_style(encodingStyle); } EncodingSt...
Let's say that hypothetically you wanted to build a website that delivered content to the visitors entirely using HTML and Javascript (AJAX to fetch server side data). The site would require login for certain functions. Let's also say, for the sake of discussion, you have the ability to create necessary web service met...
I am curious for solutions to this problem: Assume we are going to build an online-store. To better scale parts of the architecture, it is broken into independend subsystems. The typical scenario would involve an application server (or something similar), where the requests from clients come in. The flow for a login wo...
I have the following to try and connect to a server: testAddress :: HostName -> Int -> IO (Maybe Handle) testAddress host iPort = do let port = PortNumber $ fromIntegral iPort putStrLn $ "Testing - Host: " ++ host ++ ", Port: " ++ show iPort result <- try $ connectTo host port case result of Lef...
Say I have 3+ types of objects: function Sea() { var logs = [Logs]; this.getLog = function(ind){return logs[ind]} } function Log() { var bumps = [Bumps]; this.getBump = function(ind){return bumps[ind]} } function Bump() { var frogs = [Frogs]; this.getFrog = function(ind){return frogs[ind]} } ...
I have an idea that would require triggering a call or text message simply by pressing or dialing a certain number. Example: Pressing 2324 on the pin code. Despite it not being your pin code to unlock the device, my application (always running in the back) would detect your code "2324" has been typed in and send a call...
Often when coding I'll get stuck on a particularly tricky problem and will go about searching for a solution. More often than not this leads me to a StackOverflow question that provides a full or partial solution, often with code than can be used directly by pasting into the original code. In some cases this can lead t...
I write code in C. I have been striving to write more testable code but I am a little confused on deciding between writing pure functions that are really good for testing but require smaller functions and hurt readability in my opinion and writing functions that do modify some internal state. For example (all state var...
I don't actually know if my question is correct, but working on a webapp porting from ASP.NET world to Java + Spring platform I came up with this question in mind. Using Spring MVC, the new version of the the application, I'm obviously applying MVC pattern, but which was the ASP.NET design/paradigm. I know that ASP.NET...
We're close to start new project using sf2, and, probably, FosUserBundle. Keeping that in mind - what's the best strategy to define roles? App will be used by multiple divisions inside our company (every division has it's manager and regular employees), as well as external users, that can be divided into 3 groups (for...
The problem I have might seem trivial for some of you but in general I have a question about all those "free" software licenses (mainly for PHP libraries). Let's assume that I want to create project for end-user and I want to sell it to them and if possible encrypt my source code. For example for Zend Framework licence...
I'm creating a small game, where the computer generate pseudo random number in give range, and the user have to guess it. I also made the option to play computer vs computer. I mean the computer generate random number and the computer should guess it. The easiest way I found was to create for loop and increase a varia...
My application is a WPF project implemented in C# .NET (4.5) using an MVVM architecture with no code-behind in the View. In order to eliminate the coupling between the View and the ViewModel I'm implementing some of the WPF-specific behaviours as custom DependencyProperties that can be bound to 'simple' properties exp...
I recently came up with a problem which I would like to share some thoughts about with someone on this forum. This relates to finding a subset. In reality it is more complicated, but I tried to present it here using some simpler concepts. To make things easier, I created this conceptual DB model: Let's assume this is ...
Ok so for example I have an array of strings with each string as below: 364VMS1029 364VMSH920 364VMSH192 364VMSU839 364VMN2382 364VMR223 364VMR2X3 364VMN829 364VMN8757 364VMN831 How can I dynamically get the program to recognise the common characters among all strings in the array, which in this case is 364VM ...
It seems that thread-safety is always/often mentioned as the main benefit of using immutable types and especially collections. I have a situation where I would like to make sure that a method will not modify a dictionary of strings (which are immutable in C#). I’d like to constrain things as much as possible. However I...
Say I am building a website that uses two different types of data : Static : information that will hardly change, like movie awards or world countries names (I want fast access so no external API) Dynamic : information entered by users I have not written a single line of code yet. My static db is more likely to be qu...
Almost all the exceptions I have ever written have been very lightweight, containing a String message and optionally a throwable. In some situations I have included some application specific enum or some other field. public class MySpecialException() { private MyErrorCode errorCode; public MySpecialException(S...
I have here a Vb.Net employee management application. It has employees, managers, teams, trainings and so on. The way the application is set up now, data is read from the database in the startup form (frmMain) load event and kept in that forms public properties. After that all other forms (and there is many of them) re...
What I want to do is bundle XML Notepad (as is, no modifications) with the installation of our commercial product. Instead of telling the customer "go to http://www.microsoft.com/en-us/download/details.aspx?id=7973 and download XML Notepad". Any one who can offer insight on how to derive the legality of this from the l...
In DB2, it seems there is a strong separation between what a database is and what a tablespace is. Where as in MySQL and MS SQL Server tablespace and database seemed to be used synonymously. What are the differences, if any?
Here are some examples of temporary/local code. It is needed in order to work with the codebase, but would be harmful to be part of it: Project files. Paths may need to be edited in order to reflect the layout on the current PC. Makefiles. For example optimization may need to be turned off during debugging, but not fo...
I am caught between two conceptual models of how to construct objects, and am having trouble working out what standard I want to adopt. I prefer to program in .NET and often try to use RAII and read-only properties to make immutable objects with their data passed in through constructor parameters. This has been a majo...
A state-driven agent is an agent that performs an action based on its current state. The logic can be implemented through the use of a D-FSM that changes state depending on the Agent's "perception" and "stimuli" and perform actions on entering, being in, and exiting a state. I'm trying to implement this type of desig...
I'm trying to redevelop a mobile website so we can integrate it into a mobile app that is being developed by another department, but still keep it functional on the web. The app has its own menu, so it's redundant to leave the menu on the mobile site. We considered simply removing the menu, headers and footers from the...
I'd like to find out how do you guys handle the following situation: you have a class hierarchy, call it H1, with some polymorphic method that is supposed to accept an argument which type forms hierarchy H2 in the following way: the higher the class is in H1, the higher H2 argument it accepts. +-----------+ +...
I have a list of users that are being assigned to a certain office. I use checkboxes to select each user and when the client is done, a PUT is performed: PUT offices/:id users[0] : 14 users[1] : 12 users[2] : 25 The problem occurs when the server has users saved, but the client decides to clear the board. So he desel...
I need to fit at least 300 bytes (or much much more) into a QR code and think I can do this by mapping each byte into the associated ISO/IEC 8859-1 character located here. Since each byte (1-255) will only have one character associated with it, I can test the utility of the idea with this demo (the Email link has the ...
My project is organized in layers like Configuration Controller Service Repository Domain Our REST Controller is in the Controller layer. We need to connect to another API via REST calls and I'm not sure if I should make a new Controller or do it in the Service layer. I'm going to implement the REST calls with Spring...
For instance, lets say we have an nginx config pointing at foo1, foo2, and foo3, as well as a haproxy config pointing at foo1, foo2, and foo3, and finally, a deployment tool pointing at the same respective servers. How does one reconcile this? Build some sort of configuration generator for nginx and haproxy based on t...
I've been trying to develop web applications while at the same time creating the testing. I understand unit testing, I can declare a test method and test specific methods in my application. But I don't see what is the best way to use selenium web driver for testing. I tried to test the a specific site for broken links ...
In the process of conceiving a web application framework, I spent some time pondering the notion of RESTful paths. If I wanted to create e.g. a new topic, I might send a POST request to /topics. The parameters thereof might be something like: { topic: { body: 'Body' } } As such, the type of resource being created can b...
Being new to unit testing I would like to know if I am supposed to test the values of objects returned from methods when doing unit testing. As an example, consider the following classes: public class Person { public int Id { get; set } public int Age { get; set; } public string Name { get; set; } publi...
So I'm currently on a hunt for a new position as a Front-End Developer. I know JavaScript very well and can wax poetically about Closures, Currying, Prototypal Inheritance, Design Patterns, App performance and overall Front-End Architecture. But yet I still end up bombing job interviews. (FYI most of the jobs I'm inter...
I am reading a review sheet for a class and the instructor said this of the modulo operator: Remember that modulus (%) has a runtime of O((logn)^2). He continued to display this piece of code: //Assumes n > 1 public boolean isPrime2 (int n) { int sqrtN = (int) Math. sqrt (n) ; for(int i = 2; i < sqrtN + 1; i+...
I have a user and a notifications table. I want to make sure that every users sees a new notification once and only once. Not more, not less. The intuitive idea is to have a n:m relation table with userId:notificationId. But isn´t it a little too much overhead to create a new table just for that? What about NoSQL datab...
Background I'm currently working on a codebase for what is to become a forthcoming website's content "engine", where it will take in different types of standardized data (implemented with XML), parse it, and then generate content dynamically and accordingly. The data itself also includes a list of context clues or help...
One of the things I run into often is problems caused by programs which don't conform to ISO standardss. One example would be not using the ISO country tables but making up their own shorthands, which goes okay for the United States (US), or the Netherlands (NL) but goes spectacularly wrong for the United Kingdom (GB, ...
I read this question but it doesn't fully answer mine. In the linked question, the OP asks what he must do to have his custom media type registered. I do not need that. All I'm asking is, that if I am correct in assuming that, technically, all I have to do to create a custom media type is to, well.. just use it in my c...
I have been thinking a lot about Hypermedia REST-APIs for the last couple of weeks. One thing I am not quite sure about is how I want to model side effects on the server side. In my current project, I am using JSON+HAL as the content-type, and am making use of links and embedded resources. For example: Let's say some ...
I am fairly new to code review, but I have been coding for years during my PhD - which doesn't always make you a good programmer! If the reviewer changes your code and goes through it with you line-by-line, what do you do if you disagree? Sometimes you made choice X and the reviewer changes it to Y, and you had Y in y...
Either I am being a total n00b or just not with it today but I have been reading a few blogs lately and they talk about language specs. What actually is a language spec? Is php.net a language spec? The best article so far I have read is Grokbase on the PHP Language Specification.
Are there any real benefits of using interfaces over abstract classes in a domain model? Does anyone have any experience using interfaces in a domain model in a real project? From a technical perspective, DDD defines stereotypes like aggregate, value, repository, etc. Repositories then, for example, can be defined as i...
I previously asked this question on stack overflow. But have not received any responses that might help me. So I thought I would try here. https://stackoverflow.com/questions/24883527/best-way-for-me-to-approach-storing-single-boolean-results-for-overall-table Essentially I am creating a Java application that reads and...
I'm a Laravel (PHP) developer, and new with DI, Packages (workbench) and Repositories (Pattern). I want to know about the best concept/methodology for a more flexible design; ie. the project can grow and become something very modular. For example, after watching some Jeffrey Way videos in Laracasts I decide use that pa...
I'm starting now with REST (using Laravel 4.2) and Mobile (Android, iOS, SP, etc.) applications. Initially I'm checking if the request is ajax/json and then return a json response. But this condition is in a normal action (HTTP), so: if ajax/json return json, else return the view/template/layout Is it correct to do tha...
Hi I just wanted some feedback on a DDOS preventing php script that I'm designing. It is quite simple and I wanted some feedback on whether you guys think it would be effective. I'm currently using the ulogin framework as a base and have implemented API Keys. At the moment the user will send a request with a key. This ...
Specifically, what is contained inside code coverage data (.nccov or xml file) and how is an html report generated by this? Does the coverage data not include the actual percentage of code covered? Is this only generated when the report is made from the coverage data? Is the coverage data sort of a guideline for the re...