instruction
stringlengths
34
19.9k
There's a class with a parametrized constructor that initializes a member variable. All public methods of the class then use this member variable to do something. I want to ensure that the caller always creates an object using the parametrized constructor (there is also a setter for this member variable) and then call ...
The best idea I have so far is to rotate first array by {0, 90, 180, 270} degrees and reflect it horizontally or/and vertically. We basically get 16 variations [1] of first array and compare them with second array. if none of them matches the two arrays are rotationally and reflectively distinct. I am wondering if ther...
Lately we've been looking at ways to improve automated testing and related tooling of our enterprise-level GWT web app. I've realized that in some ways, GWT is a bit hostile to automated testing, mainly because of the nature of the long GWT compile times from Java to JS. This makes unit testing somewhat challenging, bu...
If I declare in a header file, for example, extern unsigned long * Ptr; and the value of this pointer Ptr in the linker file. Will this adrress be 'constant'? Can I change its value ?
I believe the scenario is common mostly in business workflows - for example: loan management the process starts with a loan application, then there's the loan offer, the 'live' loan, and maybe also finished loans. all these objects are related, and share many fields all these objects have also many fields that are uni...
I'm writing an open source library which handles hexagonal grids. It mainly revolves around the HexagonalGrid and the Hexagon class. There is a HexagonalGridBuilder class which builds the grid which contains Hexagon objects. What I'm trying to achieve is to enable the user to add arbitrary data to each Hexagon. The int...
This is in the scope of a web application. I have a database which has a few nested relations. There is a feature which depicts the history of a large chain of relations. It is essentially a data analysis feature. The issue is that in order to search, a large object graph must be loaded - the loading time for this obje...
When considering the disk space of a storage medium, normally the computer or operating system will represent it in terms of powers of 1024 - a kilobyte is 1,024 bytes, a megabyte is 1,048,576 bytes, a gigabyte is 1,073,741,824 bytes, and so on. But I don't see any practical reason why this convention was adopted. Usua...
I've been studying the use of exceptions in various php projects (such as Doctrine and Zend Framework). Exceptions seem to be thrown when unordinary input/state occurs. A perfect example is Doctrine throwing an exception when you try to use a invalid query string. I think the creators of the doctrine api understood th...
I am designing an application with intention into making it a product line. I would like to extend the functionality across all layers and first struggle is with domain models. For example, core functionality would have entity named Invoice with few standard fields and then customer requirements will add some new field...
According to the Liskov principle, a construction like the one below is invalid, as it strengthens a pre-condition. I know the example is pointless/nonsense, but when I last asked a question like this, and used a more elaborate code sample, it seemed to distract people too much from the actual question. //Data models a...
When and how did this process of prefixing css with vendor specific prefix begin. Which browser/org start this and why was this started. I searched the web but found no details on this.
I have a fairly complex search problem that I've managed to reduce to the following description. I've been googling but haven't been able to find an algorithm that seems to fit my problem cleanly. In particular the need to skip arbitrary integers. Maybe someone here can point me to something? Take a sequence of integer...
I am creating an application from legacy code using AngularJS. I wonder what parts of my code should be moved into a directive. For example, iI had thought of moving a table which is used multiple times across the application into a directive. The tables alter from headings and size. Is it worth the effort or even a g...
My office has a suite of web reporting engines written in VB. All in all there's about 300 reports with varying displays depending on the data being input into them. I'm trying to establish an efficient way to deal with such a major diversity, but am struggling with creating a system that won't be a nightmare to code...
To randomly shuffle an array, with no bias towards any particular permutation, there is the Knuth Fischer-Yeats algorithm. In Python: #!/usr/bin/env python import sys from random import randrange def KFYShuffle(items): i = len(items) - 1 while i > 0: j = randrange(i+1) # 0 <= j <= i items[j], ...
Well, the thing is that I am just about to create a Desktop App (with .NET windows forms) And now I just wonder if it would be really a wise choise to use any IoC (StructureMap,Ninject,Spring .Net), I have used them before for Asp.Net web applications but what makes me doubt now is the fact that working with windows fo...
I've got two lists: List<Integer, ZooEntity> zoos; List<Integer, List<ZooEntity>> groupOfZoos; These operations will return collections of values: Collection<ZooEntity> cz = zoos.values(); Collection<List<ZooEntity>> czList = groupOfZoos.values(); What I want to achieve is to get list of all zoo ids. List<Integer> zo...
Background Tony Hoare's billion dollar mistake was the invention of null. Subsequently, a lot of code has become riddled with null pointer exceptions (segfaults) when software developers try to use (dereference) uninitialized variables. In 1989, Wirfs-Brock and Wikerson wrote: Direct references to variables severely l...
A colleague of mine came up with a rule-of-thumb for choosing between creating a base class or an interface. He says: Imagine every new method that you are about to implement. For each of them, consider this: will this method be implemented by more than one class in exactly this form, without any change? If the answer...
I'm learning some graphics programming, and am in the midst of my first such project of any substance. But, I am really struggling at the moment with how to architect it cleanly. Let me explain. To display complicated graphics in my current language of choice (JavaScript -- have you heard of it?), you have to draw grap...
Pretty simple question. Should package structure closely resemble class hierarchy? If so, how closely? Why or why not? For instance, let's say you've got class A and class B, plus class AFactory and class BFactory. You put class A and class B in the package com.something.elements, and you put AFactory and BFactory ...
I am using git as a version control system, and using git-flow as the branching model. I started a feature branch some weeks ago in order to maintain the system in a clean state while developping that feature. The main development continued on the develop branch, and changes from develop were merged periodically into t...
After learning functional programming in Haskell and F#, the OOP paradigm seems ass-backwards with classes, interfaces, objects. Which aspects of FP can I bring to work that my co-workers can understand? Are any FP styles worth talking to my boss about retraining my team so that we can use them? Possible aspects of F...
I have been asked to create a web service that communicates with Auth.NET CIM and Shipsurance API. My web service will be used by multiple applications (one a desktop and another a web application). I am confused whether I should build a WCF or an asmx web service. Auth.NET CIM and Shipsurance API have asmx web serv...
In my education I have been told that it is a flawed idea to expose actual primary keys (not only DB keys, but all primary accessors) to the user. I always thought it to be a security problem (because an attacker could attempt to read stuff not their own). Now I have to check if the user is allowed to access anyway, so...
choosealicense.com claims that the MIT license is “A permissive license that is short and to the point. It lets people do anything with your code with proper attribution and without warranty” (emphasis mine). Reading the license, though, I don’t see anything claiming that attribution to the original author has to be an...
maybe you are thinking that this is another dump question about language in URL, but I hope it is not! I've red many articles on this, but non of them was dealing with "sections of site" (described bellow). I am programming a new application platform in laravel/php and I am still not 100% convinced where to put languag...
In essence, I'm wondering how licenses affect the legality of using source code as data. By that I mean literally storing code in a database as strings and using it e.g. for some syntax highlighting experiments, or other such pursuits. I can think of a couple of scenarios: My project is closed-source, and I want to us...
I am trying to find an appropriate data structure for representing available navigations between a game's screens. Using a linked list, a node can only have one node after it : inappropriate. Using a tree seems up to the job as nodes can have many children nodes but it's inconsistent in the sense that a supposedly chi...
I've heard a lot about requirement gathering and use cases in theory, but in practice often happens that we ask ourselves "should we include this? should this be a use case? in which language should we write this particular requirement" and so on. These questions are mainly because of lack of practice, and since we can...
I am a software engineer at a medium sized company. We have a fairly robust testing platform running on TeamCity. It does unit tests on every checkin, and a daily unit test/BVT run. The problem is - we have a great deal of broken unit tests. Quite often, I bring up the pointlessness of unit tests if they are constant...
I am wondering, in view templates, what would contribute to me choosing between using arrays or objects for getting things printed out in arrays {{$user->zip_code}} vs {{$user['zip_code']}} I'm working in blade templates in Laravel/PHP fwiw. My feeling is that it makes sense to use objects: we can use methods if we nee...
Is it feasible or even possible to use relational algebra and/or relational calculus in the form of proofs to test/verify the correctness of SQL statements, functions, and stored procedures? It seems to me like it should be at least possible, but I don't know if there's a detail I'm missing that makes a 1:1 mapping bet...
Assuming the only tool for generating random numbers I have available is generating a uniformly distributed variable u on U(0,1). I want to generate a Nakagami Random Variable from it. I know I could just plug u into the inverse CDF of the Nakagami distribution, but unfortunately, the inverse CDF isn't trivial to compu...
How to update web application deployed on intranet? There is a Java Spring application that will be deployed on intranet of multiple customers. In case when there is a major update what should the developer do in order to ensure that all the customers have the latest version of his software? There is an option that an ...
The code I've inherited has a design that I'm not familiar with (I'm still new to the world of programming). It is a .net project and there are 3 classes in question here. public Class1 { public void DoSomething() { Class2 class2 = new Class2(); string myValue = class2.GetSomeValuePlease(); ...
I'm doing a project that uses svg-edit(JS drawing tool) and the page grows big. By now there are about 20 JS file in a page - plug-ins and so on. One of the editor's files breaks in some kind of 'Uncaught TypeError' but it's compressed and can not understand anything. I used several jquery plug-ins that are important ...
Which of the below is a preferred coding style (in c# .net) public void DoWork(Employee employee) { if(employee == null) return; if(!string.IsNullOrEmpty(employee.Name)) return; // Do Work } or public void DoWork(Employee employee) { if(employee != null && !string.IsNullOrEmpty(employee.Name)) { ...
I am trying to understand the difference a little better as it seem like they are the same thing. I have work in projects with no use of the requirements and everything is an acceptance criteria, and on projects that have both.
I'm looking at creating an implementation of Daugman's iris recognition algorithm, which is covered in his seminal paper on the topic. What I don't know is, if I implement his algorithm, do I need a license?
I can be completely wrong but I vaguely remember hearing from a podcast that according to Visual Studio's license, a developer who works with Visual Studio professionally at their work place automatically has the license to use it in their personal life. That means a developer may not have to pay for Visual Studio to l...
I've always liked the idea of having multiple inheritance supported in a language. Most often though it's intentionally forgone, and the supposed "replacement" is interfaces. Interfaces simply do not cover all the same ground multiple inheritance does, and this restriction can occasionally lead to more boilerplate co...
I have a good amount of experience working with objective-C and making iOS apps that work locally and with BaaS providers (Parse.com). However, I'd like to take my mobile development to the next level and I'd like tips on the order in which to do things and tips on which services/technologies to use. So, I need a datab...
I need some best practices or experiences of developer teams who had to treat the same issues I have at the moment =) Our company is developing a client software for years. The one and only dependency was to have an appropriate database. With each release (update) we also update (incremental) the database if necessary....
I'm still in the design phase of my REST API, and I'm a bit stuck on how to configure the resources. The API will be consumed by mobile devices (Android, iOS, and Windows). Communication through HTTPS. These are the features the API will support: View a list of previous reservations View a previous reservation Create...
I'm an extremely novice web programmer working at a 2 person shop building websites, and we're in the process of writing a simple website template system in PHP from scratch. My manager is entirely self taught. He has been insisting that we put our HTML directly quoted in variables, mixing our back end code with the fr...
So let’s say I make a script/small app that has a ton of my own code, and only a small section of it is comprised of a utility from someone else (let’s say a simple operation like sending files to the trash, or sending a notification), which uses a license, like MIT. Now, I want my script/app to be public domain (or MI...
I have a question about the efficiency of an algorithm: You have a list of x,y points Now I want to get all the points that are up to 5 units away from a reference x,y point How do you calculate it in the most efficient way? I just go over each point and calculate distance, and if that distance is less than 5, I add it...
When I do my code layout, I like to start with a rather high level view, and then start to delegate actual computation to class or functions that have a bit more detail. Then in these classes of functions, I do the same, layer by layer, until I get to the bottom where I have to do the 'real' action. Example: def build_...
We are trying to create an ASP.NET MVC 4 application using entity framework with domain driven development style pattern approach. As you can see in our part of domain layer, we have a complex design. We need to load entity with lazy as well as eager methods. Unfortunately we have big problem with these methods in enti...
If I wrote this in MySQL SELECT * FROM foo ORDER BY bar LIMIT 1 it would first order the result and limit it afterwards. I always get the lowest bar. I wonder if this is specified like this in SQL-standards and how to check that? All I found are some BNF's which do not explain how something should work, but only what ...
I have a project which will have basic and professional edition. The professional edition will have all the features of the basic edition. I am using git to manage the project's codebase. I consider that I will fork repo of the basic edition after I completed it. Then, I will start to code the professional edition on t...
I had the following DB schema: Customer Car Rental ------- ---- ------ Name Name Car_ID ID ID Customer_ID Date This is said to be non normalized as the date can repeat (multiple customers can rent a car at the same day). So the teacher said it should be like: Custom...
I am a new PHP developer (coming from .NET). The experienced php dev that I work with said that calling a static get method on a PHP class with an ID as a parameter is common in PHP. Is there a name for this idiom? Is there a reason why developers do this? Can someone point to a link to an example class? I would like t...
link : http://download.java.net/jdk8/docs/api/java/lang/annotation/Native.html In Java 8, there will be @Native annotations. Indicates that a field defining a constant value may be referenced from native code. The annotation may be used as a hint by tools that generate native header files to determine whether a header...
I would like to develop iOS apps but due to budgetary issues I can only afford an iPad mini gen1 or iPod touch 5th gen. Is it possible for me to make apps for all iPhones and iPads/iPods using just a single device? Another question is how does the latest iOS7 work on ipad mini gen 1/iPod touch and what are the limitati...
Why does the modifier access for the properties need to be public with Unity? I'm very interested in a detailed explanation for my question. I read about tips to do it in other ways, but not a detailed explanation about why this can't be declared explicitly in my code.
I work for a large company, which dictates the use of agile processes. For example, for our projects, we use cloud-based services that are specifically targeted at managing agile development. The specific engineering group I work for has not traditionally developed software (instead we help drive projects from a much m...
Today I lost a method that I was using since my co-worker redefined it to take its superclass instead. So after synchronizing with the repository I had trouble. Would it had been better in this case to use some annotation like @Deprecated instead of removing the method so that I would get an error message telling my th...
Is there a general term to describe a keyword followed by a statement block? E.G. if() {statement block} while() {statement block} try{statement block} finally{statement block} Or even something made up: controlScope{statement block}
I'm implementing a system that's basically a pipeline of XML documents: XML documents are retrieved over the Internet, validated, further processed etc. until they are ingested in a relational (non-XML) database. After the ingestion in the database they can be discarded. Since the various components of the pipeline are...
I am trying to understand object oriented code better and I decided to start at abstraction. If I am not incorrect, abstraction means that you hide information that isn't relevant to what task you want to perform, i.e. If I turn on the TV I would not need to know the internal that is going on. Or If I have a class that...
I am currently working on software for layered manufacturing (3D printing), and have come to a point where I no longer know what to do. I am at the stage where I must take a bunch of lines, and order them to create a seamless contour of a model. I have some basic ideas on how I am going to do this, but since I am using...
This is purely a design question and the example is simple to illustrate what I am asking and there are too many permutations of more complex code to provide examples that would cover the topic. I am not referring specifically to this example, just using the example to illustrate what I am referring to. In an if statem...
It's clear that the effectiveness of a neural network depends strongly on the format you give it to work with. You want to pre-process it into the most convenient form you can algorithmically get to, so that the neural network doesn't have to account for that itself. I'm working on a little project that is going to be...
I am wondering how to interpret the velocity update in a Binary Particle Swarm Optimization (PSO). To recap the velocity update : V(t+1) = V(t) + c1 * r1 * (XlocalBest - X(t)) + c2 * r2 * (XglobalBest - X(t)) I understand that the binary position vector maps to values in the discrete domain. However, ...
The developers of the Dart language tell that there is a virtual machine that executes statements written in Dart language. What is the difference between an interpreter and a virtual machine that executes a language? Until now the virtual machines that I knew, like Java Virtual Machine, Common Language Runtime, and Da...
I am aware that all the DevOps definitions are fairly vague, and this question is subjective, but it's still something I couldn't find an answer to. Is there any difference, prestige-wise, between DevOps and Software Engineers? Is the experience interchangeable? Are N years of DevOps experience interchangeable for N ye...
I was thinking of creating a text adventure game and after a small google search, I found out that quite a few (simple) text adventure games are created in Prolog. Why is that?
I am starting out with DDD and understand that aggregate roots are used to ensure transnational consistency. We should not modify multiple aggregates in one application service. I would like to know however how to deal with the following situation. I have an aggregate root called Products. There is also an aggregate ro...
The screen shot shows the magento product upload page. The left nav allows you to switch to different options for the product. Basically each option in the left nav appears as a different page. However when you save and close, it will save all the updates made on each page. Using Foundation4, html, css, js - what would...
I found that llvm could only generate assembly code. If someone want generate and link assembly code to native executable code, they should use external tool(GNU as/ld, for example. Currently lld is not ready, and there no more information about llvm-mc). This question's answer and other answers imply that Clang use B...
Well, the title is pretty much self explanatory, but I'll expound it a bit, and say the origin of my question. So, I've been wondering as to how the CPU knows when it received the RAM. I'm pretty sure it doesn't OR the RAM outputs together, because 0x00 is still a number, yet ORing that together says that the RAM has n...
Using globals makes your code hard to test thus more prone to bugs, not secure and unpredictable. That's why we pass the variables we want inside a function/object. So my question is simple: Do $_POST, $_GET, etc violate the encapsulation principle? I'm thinking that, to retain control of those variables in an OO way, ...
I'm writing a C++ library, and according to this site here: http://semver.org/, I should increment the MAJOR version when I make incompatible API changes. Is changing the name of a namespace considered an incompatible change in the API? I'm not quite sure. I don't know whether I should increment the MAJOR or MINOR ver...
I'm currently working on a group project to recreate the original Pokemon Yellow version in Java. We've only just started planning it out but they way we've drawn out the design right now is to have an abstract Pokemon class and have 151 (Count of the original Pokemon) classes that extend it, each one being a different...
Just found out that Intel processors now have Transactional Memory support !!!! I learned about Transactional operations in my dB/OS class, it is a very simple concept: entire operation is executed or nothing gets executed. How is programming under new Transactional Mem. model is different from Multithreaded model that...
On "hammerprinciple.com" website there are programming languages, statements about them and voting that associates languages with statements. In particular, there are statements: "This language is built on a small core of orthogonal features" "This is a mainstream language" Why they are so opposed to each other? Is b...
I've been asked to put together an application in RoR which has multiple roles for users. The idea is that a user will have a role, Admin, Moderator, User ect... and they will also have a department as well, HR, IT, Customer Care ect.... The app will have designated sections for each department to manage data and other...
I'm working on a distributed client-server system that uses TCP. The program's functions is to transfer money to an from the server, but also between the clients, a sort of MobilePay. When one client wishes to transfer money to another client, that client will need to accept the transfer before it is succeeded (one of...
I've built a flatfile db system that will work like mini-noSQL system and it split db to smaller files, and I did a SplFixedArray wrapper for it with a method for searching usage built on preg_grep. Everything working very good till now, but if the array became more than billions of indexes how to handle it? When sear...
I'm writing a simple chess engine in LISP. I actually know how the engine decide the move, it evaluates and reads some opening books. But that's not what i mean. This is my design. 57 58 59 60 61 62 63 64 49 50 51 52 53 54 55 56 41 42 43 44 45 46 47 48 33 34 35 36 37 38 39 40 25 26 27 28 29 30 31 32 17 18 19 20 21 22 2...
I've rolled my own SIMD-accelerated math library. It's gotten pretty complete, so naturally I went to conduct speed tests and optimize it. Btw this isn't premature optimization, the lib is actually complete in functionality, I really need it to be fast now. So anyway, I'm testing some vector dot product methods against...
At my current employer, we are using an open-source project hosted on Github as a component of our application. I have been working on this project to both add some features that we need and to integrate it with our build systems. My manager and I are in agreement that we would like to submit as much of our work on thi...
I'm very excited about Docker, if you're a developer in a big project you've suffered too much at the machine hands of environments and multi-platforms. One of the key selling points of Docker is that by snapshotting/committing image state you avoid the risk of building an environment with a different version, possibly...
I have a service(webservice) that is used to access to the domain logic. One of the methods of the webservice is createFoo, where Foo is my aggregate. So the class that implements the webservice's method calls my application service that contains the createFoo method which is responsible of doing some stuff and persist...
For a ticket reporting tool, I want to compute whether certain service level times (slt) are met. That is (a bit simplified): Was the timespan between opening and closing of the ticket within a certain slt. Now there is also something called a service window (SW), like mo-fr,9:00-17:00. Now to compute whether a slt was...
When I was starting to programme in Java, the fact that switch statements didn't take strings frustrated me. Then on using Enums, I realised the benefits that you get with them rather than passing around raw values — type safety (which brings easier refactoring) & also clarity to other developers. I'm struggling to thi...
I am designing an application, which will aid designing electric installations. I went for Domain Driven Design, as the topic is complex and the application will be growing with gained knowledge. However, I am newbie to this concept. For now, I have a problem to properly model the domain, especially to divide entities ...
Say that we are developing an application with modules (Sales, Accounting, Purchasing, etc). An example case here is : Sales module is the basic / primary module available, and Accounting module is a complementary module. SalesModule -. Product And AccountingModule -. Account -. Journal If we were to say that : I...
Abstract A common problem is to store objects (with graph), and to load them back. This is easy as long the stored object representation matches the executing code. But as time goes by, requirements change and stored objects do not match any longer the code. The stored objects should not loose their data, and the code ...
Was fascinated to read about the text adventure game The Hobbit which featured an incredibly robust parser called "Inglish": ...Inglish allowed one to type advanced sentences such as "ask Gandalf about the curious map then take sword and kill troll with it". The parser was complex and intuitive, introducing pronouns, ...
In F#, I want to build a hierarchical data structure in a way with a minimum amount of language noise. The actual problem is trying to build an RSpec inspired framework using F#. RSpec allows the construction of tests in a nested way. For example. describe Order do context "with no items" do it "behaves one way" ...
I'll express my doubt with an example. Suppose I have the following requirement: The customer needs a page in his website that displays all the products he has with a quantity field on the side of each product. The visitor of the website must be able to fill in the quantities desired, select one location and ask for ...
When designing a REST API, how deep should the resources levels go? For example; If I have the following database tables: Companies: ID, Name Employees: ID, Name, CompanyID Tasks: ID, Name, EmployeeID When exposing these through a REST API, it might look something like this (id is optional): Companies: GET /api/comp...
One of the advantages of using a DVCS is the edit-commit-merge workflow (over edit-merge-commit often enforced by a CVCS). Allowing each unique change to be recorded in the repository independent of merges ensures the DAG accurately reflects the true pedigree of the project. Why do so many websites talk about wanting t...
How do Valve create games that run on Linux, Mac and Windows? I imagine they dont really write one version for each platform bec that would just be a nightmare.. or do they? I imagine it is written in a portable C++ code (or C#?) but I wanted to know more details about this. I've developed an app on Adobe AIR and consi...
I encountered the following text in an article on the ModelViewPresenter pattern and my brain blue-screened: Passive View usually provides a larger testing surface than Supervising Controller because all the view update logic is placed in the presenter. I haven't come across this particular jargon before and I'm rath...
Recently reading a lot materials on Reactive Programming, one thing frequently mentioned is the 'PUSH' versus 'PULL' style of application. Event driven ( Reactive programming ) Some of the authors say that both these styles have their area of applications, but aren't most application domains we are trying modeling are...