instruction
stringlengths
34
19.9k
I'm a 9th grader and I joined my school's robotics team in order to learn how to code Java and enter the programming team. However, I am so confused! Even after the first lesson, I had no idea what the teacher was talking about. I don't know if it's just me but, but I just can't understand any of the terms or how to pu...
If I present a user with a table of results from a database which only displays the first 1000 rows, what does the user expect when they re-sort the table? Do they expect only the displayed results to be sorted (on the client) or do they expect an entirely new result set from the db, sorted accordingly? For example, i...
I am a little confused, is it possible to implement a front end using common languages like html, css and javascript and then do server side processing using a language of your choice, say python or java? I am aware of what a LAMP stack is; I'm aware that rails is a full stack framework; I'm aware that you can use thi...
We have a software which purpose is to be used to help users build their own applications. It has to be very loose coupled with the infrastructure: for example, I can imagine users running it on MySQL database as well on MongoDB. We have modules of functionalities. In each module we do have what I call pure models - co...
ServiceOne.java private void doStuff(){} ServiceTwo.java private void doStuff() Where to put common code ? Shall I create a new service, but then what interface will it implement ? Or shall I just create a utility class ? Please guide on what is the best approrach.
My goal: To write a program where any two computers on the same LAN see each other, and can talk directly to each other without any servers or accounts. Every client must be just as strong as every other client, and maintain their own list of which clients are online. (I plan on using computer hostnames hashed with IP ...
Right now, when I handle a success / failure message, I handle both response types via the same listener and check the response type to decide whether it's a success or failure response. Like this: server socket.on('event', function(){ //process request if (success) { var data = { foo : 'u...
While I was studying Compilers,I saw an example in first and follow that illustrated how to 'find the first and follow' non-terminals in a grammer. But I couldn't get how FOLLOW(E')=FOLLOW(E)={ $ ,) } even though the first and follow algorithm states it like that. I don't understand why the FOLLOW(E') contains ')'. Do...
I'm pretty new in Java, but I've done plenty of research and I know what MVC is. However, to implement MVC in Java was a difficult task. I followed this tutorial, which helped me to realise that the event listeners usually embedded as an anonymous class can be segregated into a controller class - which makes it conform...
I have read the following text in the setuptools documentation: For maximum performance, Python packages are best installed as zip files. https://pythonhosted.org/setuptools/setuptools.html#setting-the-zip-safe-flag Why is it like this? one would think that the unzipping of the file would have negative impact on the ...
We have a ASP.NET MVC project with AngularJS and Entity Framework database-first, a news portal already in production for about a year. The project is mainly focused on providing content for users (articles, news and etc) and of course there is a lot of images. Currently we are storing the images in the File System and...
I've a large-ish software project that I'm the sole developer for (~80KLOCS and counting - I know there are much larger projects out there, but it's an order of magnitude larger than I've ever had to deal with before). If it's relevant, the code is split between PHP and JavaScript. I'd guess about a third of it was JS,...
My basic design is that the model is in a separate project from my website, and the project never references the website. That tends to enforce the model being agnostic of how it is being used. But recently I was trying to work in membership provider, and while the register portion of it sounds like something the mode...
Consider this highly simplified sample of relational data (each table may be involved in one-to-many and many-to-many relationships not shown here): people +-------+------+--------+ | name | born | gender | +-------+------+--------+ | Alice | 1980 | F | | Bob | 1975 | M | | Carl | 1994 | M | | Dot ...
I am learning Database connection from MySQL Connector/Python Developer Guide. This is the code I am using to insert data: conn = mysql.connector.connect(user="user", password="password", host="127.0.0.1", database="db") cursor = conn.cursor() query = ("INSERT INTO test(name,email) VALUES(%s,%s)") data = ("cool", "cool...
In the .NET code base of a product, there are #if pre-processor statements to define whether certain functionality should be available. Like so: shared logic #if version1 some logic #endif #if version2 some other logic #endif Personally I twitch at this structuring. I find it harder to read, and it makes me n...
Is it just giving different names to previously named method? Does it change with the language you use? Is it essential? I have noticed different APIs having deprecated methods, which actually seem easier to use.
I once read this, because I wanted to see if handlebars is the right view engine for me or rather something else. A thing that I wonder since then is the following, why is it considered bad, if a view engine encourages logic in templates?
I am trying to package a Python module for pip, following the guide here. One area I would like feedback on is best practices or convention for making my module configurable. The module is a library for talking to federated RESTful services / local datastores, and we use it both as a command-line library as well as a D...
I have tools for propagating database definition changes, but any data changes I make I write scripts for and run them in each environment by hand. There are some data changes/additions that have to be made routinely and I would like to create a GUI for handling this, but if I did that then I no longer have the sql scr...
I've been doing web programming for a long time now, and somewhere, I lost track of why we are doing what we are doing today (or how did we come to do things this way)? I started out with basic ASP web development, and very early on, display and business logic were mixed on the page. Client-side development varied wil...
This is a theoretical example for simplicity's sake. I use flat values in the regex to make it easily legible for almost anyone, since lots of {,(,[,\'s all jammed together can be a headache to read. Suppose that I have the following code. <input type="text" value="test" name="thing"> <input type="text" name="thing" va...
While studying about Optimization in Compiler Design I went through an article that tells about 'Algebraic Simplification And Reassociation' in optimization.It tells that using this(algebraic simplication) we could ignore code statements such as X = X * 1. But I would like to know whether anyone uses these type of sta...
Given an interface for the Strategy pattern like so: public interface Strategy { public Output execute(Input input); public Output getLastExecutionOutput(); } if I want to store the last execution result of any Strategy implementation is it correct to define an abstract class like this public abstract class Abstra...
While I was studying about Compiler Design it tells that we need 'finite automata' while designing a lexical analyzer like DFA or NFA. So I would like to know whether NFA is only used for conversion of (regular expressions to NFA and then to DFA). Is it possible to realize NFA practically? Or whether NFA is used becaus...
I am learning git. I am wondering why the git spec is explicit about how the commit SHA's are calculated? It is my understanding that the delta blob (the unit-of-work) is calculated into this SHA as well as information about the committing author. Why is this? Wouldn't a GUID suffice? Does the git architecture design f...
This page descibes one important difference between Factory Method and Abstract Factory: http://architects.dzone.com/articles/factory-method-vs-abstract The difference, according to this page, is that in Factory Method pattern the Creator (i.e. the entity creating new objects) and the Client (i.e. the entity using the ...
I have a device that stores raw binary log data as a BLOB in a MySQL DB. That process is a blackbox to me (closed source) which I cannot change. I know, however, how to decode that BLOB and transform it into some human readable data. Inside that BLOB data stream various information is stored, such as dates, text messa...
I am refactoring a base class, implementations of which are plug-ins, loaded at runtime by another class using reflection. The class I am refactoring uses a user ID of the form domain\user. I need to extend it to also work with domain email addresses. To do this, I have introduced an enum of user identifier types, e....
To make a platform-independent program in C++ I want to separate the GUI (separate for each OS, using native libraries/APIs) and the actual program. Obviously those two need to communicate with each other. Doing that by saving and reading XML files would be one solution. As it is kind of slow/always needs to be checked...
I am currently working on a web application that is supposed to resemble an operating system with GUI (it manages processes and windows). I have several constructors which deal with different aspects of the program, such as Process and Window. There are a few built-in programs which use a special API and a utility func...
While creating a RESTful API, should I use HTTP Verbs on the same URL (when it's possible) or should I create an specific URL per action? For example: GET /items # Read all items GET /items/:id # Read one item POST /items # Create a new item PUT /items/:id # Update one item DELETE /items/:id...
Original GLUT library is open source, even on GitHub, yet the license doesn't allow any changes to be released publicly (but you can change it for use in your own projects, as is often exercised in various tutorials still using GLUT itself). Most files contain this notice: /* This program is freely distributable withou...
Recently Microsoft has released a free version of Visual Studio: Visual Studio Community Edition the license says IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. INSTALLATION AND USE RIGHTS. a. Individual license. If you are an individual working on your own applications to sell or for any o...
So I'm working on a roguelike, and planning to represent the monsters using a finite state machine spot PC wander------------------->move ^ ^ | | \ | | \ killed PC | |evaded \ | close | \ | | hurt ...
I have just 2+ years of experience in application development. In those two years my approach towards development was as following Analyze requirements Identity Core component/Objects, Required functions, Behavior, Process and their constraints Create classes, relation between them, constraints on objects behavior & s...
We have three branches: master staging dev We branch per issue and each issue needs to go through testing and staging before being merged to master. We branch feature branches from master and work on that feature. When ready for testing, we merge the feature branch into dev branch and TeamCity deploys to test enviro...
Public api: getClients / getClientById - returns a json object like: { clientid: 1, name: "Client1" } getProjects / getProjectById - returns a json object like { projectid: 5, name: "MyProject", clientid: 1} Question: How do you design a library and set of objects to interact with this API specifically with ...
This is what most of my database-related library code looks like: lib.php <?php $dbh = new PDO(...); function doSomeDatabaseThing() { global $dbh; return $dbh->doStuff(); } function doSomeOtherThing() { global $dbh; return $dbh->doSomeOtherStuff(); } index.php <html> <head>...</head> <body> ...
I have been thinking about using 3rd party GPL based jQuery controls in our in-house ASP.NET project. As far as the 3rd party license is concerned, I think I can use any jQuery controls in my application as long as they are compatible with the GPL license. jQuery itself is released under the MIT license. The 3rd part...
What are the efficient ways to process huge lists (+10 millions), and things to consider while manipulating huge lists. First question, when should I use recursion, and when I shouldn't. In both cases, we are allocating memory to store data (the memory-complexity should be equal), using recursive approach with a huge ...
In an exercise of futility I'm trying to abstract and generalize a framework where to build any turn/rule based system. I've had a head start but after decompiling HearthStone I'm second-guessing that it may have higher complexity than I expected, at least for abstraction. So, I would like a peer review of the approach...
I'm not much of an expert in the area but I am aware that solutions already exist to managing database migrations in version control, e.g. sqitch and liquibase. However I'm currently planning a small hobby project and even sqitch looks like an annoying amount of cognitive overhead. Idea A migration is a (name, up actio...
I'm implementing cache structure using Redis, my domain is like this: There are multiple categories (3000+ categories). Each category contains multiple questions (around 20-30 questions per category). Each question has several properties like whether it's published, what's the type, etc When loading the questions, I'l...
I have a class that represents a process. In this process there are inputs boxes and output boxes. public class Process { public long ProcessId { get; set; } public virtual List<Box> InputBoxes { get; set; } public virtual List<Box> OutputBoxes { get; set; } } As you know, naming things is one of the harde...
I know that programs that are built on one OS won't work on another, like a Windows program on a Linux distribution, and that there are programs that translate those system calls into system calls that the current OS can read (Wine for Linux). However would it theoretically be possible for there to be an OS that can un...
I am looking at developing an app which has quite an extensive database. This app will be installed on multiple devices in a LAN and all users can update the data and other users will see the data as it is synced. We can use the network subscribe and poll feature in android to find available services but I was wonderi...
So the situation is like, I have few classes, all of which have a standard CRUD methods but static. I want to create a base class which will be inherited so that it can force to implement this CRUD methods. But the problem is, the CRUD methods are static. So I'm unable to create virtual methods with static (for obvious...
I have been thinking about a design problem and possible solutions in my own. I am pretty sure I am not the first one to have noticed it, but I cannot google for it since I do not know the standard naming of the different participants. It is NOT the state pattern. My problem is that, when dealing with ORM, I often end ...
The problem that I have is with versioning of a single mobile application (created with Cordova) and the WCF web services that it consumes. Situation: The latest version of the mobile app is always obtainable through the app store. The web services are distributed to customers, which do not update the web services very...
I have a Visual Studio Project that is using a MSBuild task to generate some code files. (The basis are xml files, and the generated code is quite lengthy, but noting special, just a lot of boilerplate.) I’m not sure how I should handle the generated files: Not include generated files in the project, and use MSBuild t...
I'm working with the Twitter API which provides only a single field called name, which includes the full name of a person. The application that we're constructing requires a first name and a last name. Now my question is how I am able to extract the first and last name from a single name field. I know that I can simply...
Quoting DDD theory: The application layer is thin in terms of domain logic - it merely coordinates the domain layer objects to perform the actual work. When it comes to modularization, and assuming that the module containing the domain entities and the interfaces of the domain services belongs to the domain layer,...
I found an article by Martin Fowler that has made me doubt my design choices, particularly about data objects. Martin Fowler has written an article about what he thinks is a code smell. In this article, he says: The best smells are something that's easy to spot and most of time lead you to really interesting problems....
I have an large php project. I used to document it with NaturalDocs, but I didn't include the documentation generation in the build process for a long time ( years ). I recently started using composer and looked into PSR. The only standard way to document my code seems to be docblocks for phpdocumentor. Since my code...
According to recommendations given here, F# modules should correspond to DDD bounded contexts, i.e. subdivisions of a business domain. The bounded context I'm working on right now has 2 aggregates totalling a dozen of types, plus some rather complex functions/algorithms. If I follow the prescribed style, I end up with ...
I have three or more different custom exceptions that a class can throw and I need to use try/catch in order to discover which exception was thrown. In my point of view this piece of code violates the Open/Closed principle, because if we look the definition we see: "software entities (classes, modules, functions, etc....
Let's say we have a Book that has a List of Authors. Order of Authors is important. We then have the update page, where user can 1) add new author, 2) remove existing author or 3) change the order. What I have as the input is the list of new authors. I find this problem often - there is often a lot of models with this ...
I have a WifiComponent in my Camera in my client application. It's responsible for handling the Wifi-related functionality of the Camera. The Camera represents a real world camera. This WifiComponent can either be enabled (in which case I can do things with it, like checking connection status and scanning) or disabled ...
I work with an interactive web portal that has a few single-page apps and complex html structure. The aim is to support all browsers that our customers use. We have implemented responsive web design to handle mobile platforms. We test on multiple platforms (mobile and desktop) to make sure that it works everywhere. I r...
This is more of an Architecture question, and I want to know all the possible pros and cons of the approach. In my org, we have an ASP.NET Application say "A", a Web API Project say "W", and underlying DLLs say "D" which calls "E" which is physically on different server. For most of the things (in SPA), we are making a...
At our office, we use JIRA to track issues reported by our QA teams. We also have Bamboo which builds each time we commit to our Git (Stash) repository. QA picks a build from Bamboo and they work with that build for about a week. Once all of the issues they filed on that build are resolved, they pick another build and ...
At my shop we have a couple .NET Web APIs that use OAuth tokens for authentication. Currently, each web API is both authorization and resource server. Users authenticate to all of these APIs using the same credential, but they currently need to authenticate to each API independently. I am interested in creating a shar...
I'm reading a book on general object oriented concepts to try and gain a solid understanding of everything. One thing that is throwing me off is the difference between Inheritance and Composition. I know that in terms of Inheritance, it is "is-a" with the subclass. Such as an Employee class inherits from the Person cla...
Wikipedia says, that closure - is a function, which has an access to variables, declared outside of the function. There is even an example: function startAt(x) function incrementBy(y) return x + y return incrementBy variable closure1 = startAt(1) variable closure2 = startAt(5) But according to most progr...
MongoDB is licensed under the AGPL, and interestingly, its licensing page says the following: To make the above practical, we promise that your client application which uses the database is a separate work. To facilitate this, the mongodb.org supported drivers (the part you link with your application) are released und...
I need some help understanding how two tree comparing algorithms differ. I am working with Microsoft's XmlDiffPatch (http://msdn.microsoft.com/en-us/library/aa302294.aspx) which compares two xmls. The library has some pretty bad documentation IMO however you can find some info here: (http://devproconnections.com/aspnet...
Working on an ecommerce project whereby a PHP application (back-end & non-customer facing) is currently responsible for processing an order from checkout stage through to generating profit/loss reports, processing the order and also performing various algorithms on behalf of a data science team. The algorithmic compone...
I'm currently developing a web application (using laravel) where I have a form that edit a resource. Something like this: <!-- URL: /editResource/3 --> <form action="/editResource/3" method="POST"> <!-- Input fields --> </form> When I send the form the web application will update the resource 3. But how I can pre...
I have been trying to find orthogonal matrix of order n where first row will be given as 1/√n, 1/√n, .... n times. The second row will be a vector such that dot product of it with the row above and below will be zero and so on. Means, in a matrix of order 3, the 3rd row will be the cross product of first 2 rows. How do...
I am wondering if there is a known algorithm for solving the following. Data: There is a number of sets containing items. An item can be a member of more than one set. Aim: return the minimum number of sets which between them contain all of the items, and avoid returning duplicate items as much as possible. For example...
I have a class library which is compiled with JDK 1.7 It uses several 1.7 features and classes and would be very difficult to get it recompiled in JDK 1.5. This needs to integrate with an old legacy application with is currently running on JRE 1.5. The integration itself will be quick because the library has just 1 cla...
I am building an app that displays very sensitive information and as such, I want to be able to either Disable the ability to capture the screen Redact the portion of my app that is on the screen during capture Detect that a screen capture was made via an event, hook, log etc Are any of the above even possible in Wi...
I'm developing a desktop application in .Net that follows a plugin architecture, something like this:- I have a "core" .Net solution, containing the desktop exe project, and a handful of class library projects. These classes provide all sorts of shared/common functionality, and are referenced by the application exe and...
Not sure whether this is the right forum to ask this but here goes. Using this solution - https://stackoverflow.com/questions/26571351/replacing-if-else-logic-with-state-strategy-pattern I was able to refactor my complex IF/ELSE check statements. One would like to nest this without having to use an external rules engin...
Is possible and, if so, common practice to initialize an object inside a class in Python? self.field = Class()
I had a generic task in my project which required changing some elements. Instead of making changes for each element I decided to create a plugin for the common task and then bind plugin with each element. I had no prior experience of creating plugin so followed an example on http://learn.jquery.com/plugins/basic-plugi...
Does standard UML specify how a variant (aka tagged union, discriminated union, sum type, etc) should be depicted in a class diagram?
When I read the HTML 4 Specification. The document says : Each markup language defined in SGML is called an SGML application. An SGML application is generally characterized by: An SGML declaration. A document type definition (DTD). A specification that describes the semantics to be ascribed to the markup. Th...
Is there any example of Smalltalk being used as a query language? What I am looking for is: a system or an application where the Smalltalk nature of the application is hidden or irrelevant to the end-user and portions of the language is exposed only for querying the object model underneath (be it application objects, d...
Working on relatively low-speed hardware, I need to grab a snapshot of a rapidly changing datastream and then post-process the snapshot data and save it to disk. I need help with designing the overall approach given the processing constraints from the hardware. The snapshot phase needs to complete relatively instantan...
Quick question as relates to database. Where would you store the value of "UserVerified"? (The one that occurs after the user has checked his email and clicked on the "Verify" link with the hash value at the end). Would you store it in the User table? (Along with username, hash) ? Or in the UserProfile table (along wit...
I am building a REST service. This services enables the user to create an entity that has an Address. For simplification, let say this other entity is 'House', so 'A House has an Address'. The system has to geocode every House so along with the Address, a House must have latitude/longitude at the moment of being create...
I don't like classes like *Service, with bunch of business methods - aka anemic model. I was thinking, instead, to have a class per use case. This was inspired (if not the same) from CQRS. Even if we are not using event sourcing, I believe that this kind of encapsulation would make sense. Then the service layer (applic...
I have a PHP application (a web service). It consists of files grouped in directories by theme like :      /customer         /search.php with this example content : Auth::authenticate($options); $db = new Db($options); $db->query("select ... "); echo json_encode($db->fetch_all(); A basic way to convert this code to ...
I have two types of users: a CRM user and a system user. We have a record of every CRM user, thanks to a nightly sync that we run (so we don't have to hit the CRM API every time). We have system users that don't have CRM accounts. We also have CRM users that aren't in our system. If a system user happens to have a CRM ...
On a web application for accounting services, I have the good old Invoice. To keep this example as simple as possible, each Invoice has many rows, and each row has its item with its price. At the beginning, the prices of the items are read from a PriceList table. Each time an invoice is emitted, i store the the key o...
Why does every serious Github repo I do pull requests for want me to squash my commits into a single commit? I thought the git log was there so you could inspect all your history and see exactly what changes happened where, but squashing it pulls it out of the history and lumps it all into one commit. What is the poin...
Could no amount of formal analysis, type/rule checking prevent it's exploitation? How about a fully verified kernel such as SEL4 ?
I've been trending toward functional programming for 4 years now, ever since I first started working with LINQ. Recently, I wrote some pure functional C# code and I noticed, first hand, what I've been reading about functional programs - that once they compile they tend to be correct. I tried to put a finger on why thi...
In the introduction to K&R there is the following text: Similarly, C offers only straightforward, single-thread control flow: tests, loops, grouping, and subprograms, but not multiprogramming, parallel operations, synchronization, or coroutines. What does grouping refer to? It is not in the index, and searches ha...
I'd like to create a developer task collector where I'd put all issues that I see need some work but are not User Story related (e.g. fix some not visible quirks in startup animation, scan code with lint, enable EasyTracker in application, clean unused resources, etc.). I don't know when we'll have time to work all tho...
I wonder what is your approach on following subject: let's say we have MVC structure with entities, repositories, controllers and service layer. My approach to use above was pretty clear for me: controller uses services services perform manipulations to data when needed, services use repository classess to save and ...
Let's say i have an interest in file conversions, but everything should be made by hand and i have multiple output formats (say: csv and excel). Once i get contacted by a client, i have to link services and convert files. What would be the fastest way of doing this? My guess would be to start with NodeJS and use librar...
While the concept of IoC isn't foreign to me, I'm new to Unity and I'm having trouble connecting the metaphorical dots, so to speak. In our project we have a class library for logic, then several class libraries with repositories implementing common interfaces (they provide access and allow CRUD operations on different...
While looking at various JavaScript libraries, I have noticed a relatively common practice of passing either the window or the document object as part of the arguments given to the library initialization function. Examples: DOM4 ContentLoaded EasyXDM fingerprintjs While I understand very well why that would be done f...
Im trying to replace an async filestream method, which is reading data from a Hid Device and feeding it to the UI. Ive considered writing the output into a log and then importing that log again, but that just seems to over complicated. The whole reason behind this is to be able to test the program without the controlle...
There are n items (n is known and > 1,000,000,000). I want to randomly 'mark' x% of n-items in stream. (n and x are known) Items are in stream ,one directional (you can't go back) processed item goes to output stream. Items should be picked randomly as well, meaning I can't take the first %x of items in stream. comp...
From http://www.openbsd.org/policy.html The original Apache license was similar to the Berkeley license, but source code published under version 2 of the Apache license is subject to additional restrictions and cannot be included into OpenBSD. This rationale mentions "additional restrictions" but doesn't say what the...
I want to write an 8086 CPU emulator in javascript, functional style. How would one conceptualise / design an 8086 emulator, or any CPU emulator that has registers and realmode memory access in a functional way? I can't wrap my head around how an emulator that is pure / mostly side effect free in the core parts, like m...