instruction
stringlengths
34
19.9k
I have a list of integers. Also, I have a function which returns True when the element is non-zero, and returns False when the element is zero (let's call it FUNCTION1). So, how to define another function (using FUNCTION1), which will give us a new list and only include the non-empty elements? For example, we have [1,2...
I'm writing a handy library (we'll call it Thinger) that goes off and fetches an XML document, does some X-Path query on it and does something helpful with the result of that. (What I'm actually doing is far too boring to bother you all with, this is just a simplified example.) Because I'm a wise and lazy programmer I'...
I have sets of probing data from an internal monitoring tool which represent the availability of different services (databases, webservices and so on). Now my task is to visualize this data and I reached a point where I should make a decision concerning the data interpretation for the most recent data set. Quick overal...
I've just been told by my boss that I will receive a negative performance review on Monday. He wants to talk to me about why I am so slow and why my bug fix rate is so low. I love programming and solving problems but I actually do find my job really really hard. I've actually been a programmer for about 10 years. But t...
I would like to know how transparency is defined, and what is the measurement for this in the context of a broker architecture. For example : from a developer point of view, [in the broker architecture] distribution is transparent. you talk to a broker one way or the other and it introduces an object model in which dis...
I have seen and used both of the methods to hide the on screen keyboard while coding Android: getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); and: InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(myEditTex...
We build products which often integrate with third party systems. Sometimes these systems error, which in turn causes our system to error. For example, we call a web service when a user updates their data after we've saved to our own database. While testing, the service on the other end is not functioning correctly....
In my PHP web page (index.php), I have a simple script that calls a "page" class, and then builds the page from it. Index.php executes methods within an instance of the 'page' class, such as "add_to_body("bla bla bla")". It can then call a "build()" method, where the page class will return a string with the user input ...
Based on this page, I can see that only Apache License 2.0 is compatible with GPL v3. Now my question is, in layman's term, how do I make those two work together? My current situation is that I am developing an application that is made from a GPL v3 licensed programming language. I want to put some form of security on ...
I'm working on a legacy system that has a helper class that is symbolically linked into many different .Net projects within a solution. The logic is riddled with compiler directives that change it's internal behavior based on which .Net project it happens to be compiled in. For instance, there's a compiler directive t...
I'm a team leader of a team of 8 programmers in a company of about 20 technical people. They're working on a range of projects, these projects also involve people from other teams that are outside of my control. My organisation is not doing proper agile development, and they're somewhat resistant to change, but I've be...
What notation do you use for the average time complexity of an algorithm? It occurs to me that the proper way would be to use big-theta to refer to a set of results (even when a specific try may differ). For example, average array search would be Θ(n+1)/2. Is this right? Explanation of average search time being Θ(n+1)...
This is a question driven by curiosity. I am learning Oracle database and Oracle database handles Blob data in a separate tablespace, which I believe reduces overhead while trying to read large Blob data. I am wondering how MySQL handles Blob? I am actually planning to start a project and I wish to give a try on saving...
I do not see how the MoSCoW Method's "Must, Should, Could, Would" prioritisation is better that simply 1,2,3,4? If I receive the requirements from the customer, they already are prioritised, usually using this range. Also what is so interesting on this MoSCoW thing, why it is so 'famous'?
I'm thinking of making a Python-JavaScript converter/compile. I've been wondering about the pros and cons of the following methods to parse the Pythonic code, into JavaScript equivalent. Working with the output of ast.dump(ast.parse(code)) Working with tokens. I've been trying weigh the pros and cons of these method...
I have a situation where I would like your input and think over / solve algorithm. The specs There are inventories with a specified amount of capacity. 'X (width) and Y (time)' creates together a total space. '60 * 100 = 6000'. In reality "width" are a business value unit, but we can talk width here. Now there a...
I am writing an interactive program in which it takes speech input from the user for a specific list of commands. The list of commands will be stored locally in a graph and based on the usage their weight will be modified. The speech input is taken and processed into text and then it's executed by bash scripts. I am th...
I have a commercial application that uses a Qt Solutions component. Until recently, this component was licensed under the LGPL license, so I was forced to use the component in the form of a shared library. According to this post http://qt.digia.com/Product/Qt-Add-Ons/Qt-Solutions-Archive/, the Qt solutions have been r...
There is a good example on Wikipedia regarding the violation of SOLID principles. The ISP was first used and formulated by Robert C. Martin while consulting for Xerox. Xerox had created a new printer system that could perform a variety of tasks like stapling a set of printed papers and faxing. The software for ...
tl;dr How would I represent GUI as agents in a multi agent system. I am learning more about Multi Agent Systems. I like the concepts of such systems, it makes a lot of sense and it sounds very useful when I want to create a large system devised of smaller parts for the Web. So, I created a basic Agent class, taught my...
I hope this is the right place for this type of problem. An Object of my class Movie can have several keywords ( like 'fight club', 'brad', 'fincher'), and be part of different categories (like 'Drama', 'Best Movies Ever') I implemented them as ManyToMany: @OneToMany(targetEntity = Keyword.class,fetch=FetchType.EAGER)...
I am attempting to create an list which should be sorted by a particular field in a colon separated string. I have an array of strings with the following values: name1:535 name2:697 After sorting this list, I would have it sorted by the number in the second field: name2:697 name1:535 How should I go about doing this...
I have an exam coming up and I'm looking at past papers to get some ideas of what to expect. I'm a bit stuck on the following one and would really appreciate if someone could give some example answers. Write preconditions and postconditions in OCL for each of the following operations (included in the Stack class in th...
RSpec allows users to share context across tests / examples, which would reduce the number of code lines in my app by a significant amount. On the other hand, somehow related to the question of sharing codebase between tests, one of the reasons why I'm using Factories and not Fixtures is because I don't want tests to b...
I'm trying to learn node.js and create a web application, and although I'm doing my best to just use only node.js to create it, I'm having a very difficult time finding resources and examples that describe the process without using other frameworks or libraries. Specifically, how can I serve HTML and CSS content withou...
Since a few days I am fighting my way through implementing arithmetic coding. I found a really great source of information which made me understand how it should work. Long story short, it implements arithmetic coding on integers using two registers: HIGH and LOW. Those register store a fraction, ex. HIGH = 98765 //me...
I have a Season class. This Season has a few properties: among them, a list of Games. This should be populated from the same source that populated the rest of the Season properties. I have a test to ensure all items in that list are of type Game. There is no hard requirement that a Season must contain any Games, so t...
In C# if i declare a constant variable is any memory allocated to it as it acts as a compile time replacement? How long is the variable's life?
The advantage of using tabs for indentation is that people can configure their editor to use the tab width they are comfortable with. The only argument against this seems to be that people don't want their code to look differently based on editor settings. However, since code is ultimately being written to be easy to r...
I've been working on this project for my company. Currently I am embedding my SQL statements inside the program itself as and when they are needed. I do have two seperate classes - QueryBuilder Class (Contains all the queries) DbConnection Class (Executes the queries against the database, takes care of connectivity a...
I have a main template like website I have made that will allow me to quickly roll out and make new websites on demand when I need them, for my personal use. I'm wondering what is the best practice when using a Git repo is for this practice. My goal is that if for example down the road I'd like to make a change to all...
I'm preparing a presentation about Agile methodology for managers (not programmers) and I'm looking that, from a side, the Agile talks about functional perspective*^ (in Scrum we have planning game) but, from other side, it lacks any (standard) definition of **functional measure. In my opinion it's strange: how I can g...
I have recently been moving through a couple of books in order to teach myself Java and have, fortunately, mostly due to luck, encountered very few difficulties. That has just changed. I read a section on the following under inheritance and the whole superclass subclass setup When a new superclass object is created, i...
As mush as FP has done, in the end, all our programs are structured. That is, it doesn't matter how pure or functional we make a them - they are always translated to assembly, so what actually runs behind the hoods are instructions, states and loops. We are kind of emulating FP. As a hardware noob, my question is: why ...
It's time Haskell had a modern REPL like Mathematica's (or better). Make each calculation run in a separate thread, so user has control over each computation box's resources (ability to pause, play, cancel, replay, set memory/stack/time limits, etc). Allow for graphics output as well (how?). Then detach these boxes fr...
What exactly does "Security through obscurity" means in the context of stroing unencrypted passwords? I'm using a small program (I won't name it, to not enlarge enough large shame on its author) that uses my Google account for some tasks. I've noticed, that it stores my password in plain-text unencrypted file. Just a s...
I would like to know what options are available for documenting a project which has already been developed, as the developers who worked on didn't write even a single page of documentation. The project has no other details other than many pages of scripts with functions written and modified by developers who worked on ...
Is there a way to show and save all "final" definitions entered into a Scheme REPL into a text file? Say, if I have defined in the REPL: (define (increase x) (+ 1 x)) (define (multbytwo x) (* 3 x)) ; let us say this was an error (define (multbytwo x) (* 2 x)) I want to save this into an .scm-file with the ...
I want to see all user-made definitions in a Scheme REPL, both loaded from files and entered at the REPL. Is there any way to "dump all definitions"? E.g. if there is: (define (plusone x) (+ 1 x)) (define (plustwo x) (+ 2 x)) (define (plusthree x) (+ 3 x)) then I want to see all of these definitions, but o...
I am confused as to what the problems could be if a constructor was inherited from a base class. Cpp Primer Plus says, Constructors are different from other class methods in that they create new objects, whereas other methods are invoked by existing objects. This is one reason constructors aren’t inherited. Inher...
While trying out the below applet, I saw that this path finding algorithm called Jump Point Search yields significantly faster result than A* and Dijkstra. http://qiao.github.io/PathFinding.js/visual/ A*: 46 seconds Dijkstra: 1 minute 39 seconds Jump Point Search: Less than 3 seconds Needless to say, I'm quite astou...
Let's assume that we have a simple GIS-like application, which presents (using Google Maps or anything similar) recorded tracks. Each track consists of points (data portions) with geo-data and additional information, like speed, altitude and similar attributes. Basing on these additional params, I want to calculate som...
My company has so far been developing a medical device, which is connected via USB to a desktop system (running x64 Windows 7) to run the image analysis and do everything GUI related. I am familiar with both Windows and Linux programming, C, C++, C++11 and C#, but now our new project coming from management would be a h...
When Enum is used as below, say if we have enum Designation { Manager = 0, TeamLead = 1, Associate = 2 } then write the below code if (designation == Designation.TeamLead) //somecode Now if we decide to change the enum element from "TeamLead" to "Lead" then we have to modify the above line of code as well...
An asm.js application is very fast (near native C++ speed): http://kripken.github.io/mloc_emscripten_talk/micro4b.png But how is it possible to write one in C++, convert it to LLVM code, then do some trick with emscripten/asm.js ? I haven't found any tutorial about it. And if I write the code in C++, then how to use ...
I'm trying to build a general understanding for what's common in this situation so that I can decide if it makes sense to pursue it further. Are installers welcome in a typical corporate environment with the following? Change control process Dev/QA/Production environments Designated deploy teams for various areas (fi...
I am fairly new to Angular.js, and one that confuses me is how to best use modules in an application. It seems to me that modules can contain any of the other common constructs in AngularJS (controllers, directives, filters, services, etc.), but from here I am unsure which module(s) should contain which things. Shou...
Recently I've been browsing source code of large applications written in C++ to learn a bit but I couldn't help but notice that most if not all use a lot of IFDEFs and class-less functions (where they could have been class members/methods). An example is Qt Creator IDE source code: http://qt.gitorious.org/qt-creator/qt...
I have some questions about VPS and web hosting. As far as I understand, VPS is a virtual machine on which we can do anything as we can do with our local machine. Install software, change settings etc. Web hosting is where we have only a folder in which we place our web site in. However, most of the provider currently...
In electrical engineering class we learned that signal lines are not ideal, so it takes time for the signal to reach the other end of the cable, and if we doesn't take this into account, it can lead to crazy phenomenons like: Imagine we have a tank game, where tank1 (played from Europe) shots tank2 (controlled from th...
Single responsibility ( reason to change ) of an entity should be to uniquely identify itself, in other words, its responsibility is to be findable. Eric Evan's DDD book, pg. 93: most basic responsibility of Entities is to establish continuity so that behavior can be clear and predictable. They do this best if they...
Through most of my dev experience, I've never had to deal with much variety of access control architectures. They've all been pretty straight forward: Group [Create, Update, Delete] - User 1 - User 2 Group [Update, Delete] - User 2 Which, for all intents and purposes, works well. The problem I have is the...
i'm using Ruby 1.9.3 I figured out that you can use an array, or a hash as hash key in ruby: h = Hash.new h[Array.new] = "Why?" h[Array.new] # Output: "Why?" h[Hash.new] = "It doesn't make sense" h[Hash.new] # Output: "It doesn't make sense" But an object works differently... h[Object.new] = "LOL" h[Object.new] # Ou...
We have a team of roughly ~8 devs who regularly work on the same feature over the course of a 3 week sprint. It isn't quite pair programming, but in our current workflow devs regularly push up incomplete code for a colleague to complete. This worked fine before we introduced Gerrit, but now our commits need to represen...
I've been using Python for a little while now and I am enjoying it, but a few of my friends are telling me to start using a language like C# or Java instead and give these reasons: Python is a scripting language Python apps don't port well to people who don't have Python It's hard to make good GUIs in Python since it'...
I recently took over the maintenance of 10-15 SQL Server databases and to my surprise found out that the team does not store the code scripts anywhere. They currently deploy changes to each environment without any paper/code trail. The code for applications that use these databases are all stored in TFS and I need t...
There are a few claimed benefits to Node.js that I typically hear. Some (many?) I agree with. There is one that I completely do not understand, which is the one language argument: "You can now use one language on both the client side and the server side." This does not make sense to me on many levels: most people alre...
In most MVC frameworks, Controller class contains multiple methods, each representing one action. Then annotations and reflection is used to call those methods appropriately. But from OOP point of view, the whole class has many responsibilities, eg. one for each action. Then each action should be represented by it's ow...
Why not use a RTOS with microkernel architecture for web servers? The scheduler is deterministic and all requests will be handled quickly leading to faster response time? It's easy to extend an OS based on microkernel architecture, since everything is like a client-server communication via message passing. Also, the se...
I am interested in building a custom Websocket server for college project. I have a good familiarity about HTTP 1.1 and knows quite well of how it works. I am asking this question assuming that Websocket clients (browsers) have their protocol specification since Websocket clients connects to Websocket server through UR...
Suppose I have a web app where sellers add their products and set them as available for sale. Then I show a list of products in my mobile app, where I get products via my REST API. My problem: suppose two clients view the same product(and there's only 1 item available from the seller) and they make simultaneous order. ...
I am making an Android application which reads several JSON files and inserts the read information into tables in my database. For instance, there are three files: countries.json { "countries": [ { "name": "United States", "org_ids": [ { "id": 1...
I previously asked this question about creating an algorithm for joining records from multiple databases, and since then, I have built a rudimentary version of it (which doesn't allow for inter database table associations to keep it simple for the moment), and now I am trying to test it. So far, I have tested doing joi...
I have some concurrent key-value store implementations that are implemented with hash tables and search trees that I would like to compare. I would like to benchmark them with a real world application where several threads stresses the key-value stores. I already have some micro-benchmark that stresses the key-value s...
One thing I cannot find anywhere is: is this approach limited to non-critical software? Because in critical (or just when customer wants us to follow his rules) we have no freedom in testing and just follow the procedures. Am I right?
I'm interested in what algorithms or rules I can programmatically implement to generate RGB or HSV colors for plotlines to keep them visually distinct from the neighbors. I know that in professional mapmaking, there are algorithms or rules that make sure that no two adjacent countries on a map are the same color. I can...
I am trying to improve my knowledge and ability with graphs and graph algorithms and have noticed something curious: as far as I can tell no "mainstream" language contains support for graphs in its standard library. Trees yes, graphs no. The only language that comes even remotely close is C++ with Boost (which isn't te...
I'm developing a simple web application in node.js. Users can log in from any page in the application, so I handle authentication in the server's code and logic, and the application's server-side code checks to see if a couple session variables are set. If they are, the application continues with user-specific inform...
I was looking for an answer to the question of what a DAO should return when a search ends up to be for an entity that does not exist. There are some generic previous questions related to returning null, but I am looking for an answer specifically in the context of the DAO retrieve scenario. To be clear, when I say N...
We are building a Game Client and Server, our system is broken into four major projects: (Client and Server, Shared Interfaces, Source Art). In addition, both client and server have a set of libraries where we put shared code for client and server respectively. As you can imagine this leads to a lot of projects, I coun...
So, we've got a guy who likes to write methods that take Objects as parameters, so they can be 'very flexible.' Then, internally, he either does direct casting, reflection or method overloading to handle the different types. I feel like this is a bad practice, but I can't explain exactly why, except that it makes it mo...
I've refactored a program to remove its dependency on an sql database by storing all the state in a memory model. However the manager liked the ability to easily inspect the domain state just by doing an sql join/filter on the database at any time; and he wishes to maintain some similar domain inspection ability. We ...
I know that an app developed with PhoneGap is slower than a native one because at PhoneGap the whole code must be interpreted at runtime into a native one. But could someone explain or has a good in-depth website which explains why a native app retrieves data (a picture or text) from a web ressource faster than an app ...
Our specific situation is that we are creating an agreement between ourselves and another team for shared control or use of a PHP based web application that we have been building. We have a set of standards and conventions documented in our technical specs. However, I have been asked to define them in terms of an i...
I am trying to design a table to store references to multiple tables as a "target" of the item in each row. An example should clarify what I am trying to do: Imagine you have 4 tables (images, videos, comments, likes) with likes being similar to CREATE TABLE `likes` `target` int(11), `user_id` int(11), `created_at` tim...
I'll admit it, I haven't yet mastered the language, but my experience with it tells me that Javascript is a highly flexible language, allowing prototypal inheritance, dynamic typing, functions as first class citizens and so many more cool stuff. I think such features bring some inconsistencies, but that's nothing new, ...
I have a View Controller or a View that implements delegate and dataSource methods of UITableView. These methods are not going to be used outside this class. So is it a good idea to make the declaration of the UITableViewDataSource and UITableViewDelegate inside the .m file with a private category? For example : Instea...
I have this personal rule to start all function/method names with a verb. My verb of choice for functions or methods that get a value based on some data structure or object is get. I'm wondering if that's a good idea. The good thing about get is that it doesn't really say anything about how that value is being retrieve...
I am about to begin writing a program in c# that will read Addresses from a source file create a Geocoding request, sent it to Google Maps API, get the response choose the coordinates from the xml and then store them in a database. My question is what is the proper type of source file considering performance and easy i...
I will be taking an advanced PHP UNiversal IT Test (UNITT) for a position I am applying for. However, I am unfamiliar with the term 'unitt test'. What is a unitt test and how would a company execute one? If anyone is familiar with this, please let me know the best way to prepare
I have been learning UML and have a basic understanding now, but I keep seeing these sort of high level architecture diagrams. Here's one from Microsoft: Source: A bad picture is worth a thousand long discussions. Is this a UML diagram? Are there any rules to follow for creating these types of diagrams? I would like t...
I am a relatively new to the world of software development and I've used the Ruby on Rails framework to develop relatively simple applications before. I know that frameworks can be extremely useful in terms of getting applications up and running quite quickly. However I also know about the well documented problems tha...
I am creating an application that visually displays world regions, e.g. to place markers within an administrative region. Does a dataset exist with geometrical or geographical (long/lat) descriptions of the world's current country borders (and possibly other administrative divisions)? Ideally the dataset would be in a...
Why? Depending on your source the Intel compiler is likely or most definitely the compiler generating the fastest executables for the x86 architecture (5 to 100 % execution time improvement). Intel offers its compilers for Linux under a non-commercial license for free (I think I read it is free somewhere on their page:...
Wonder if anyone could shed some light on this messaging construct: The documentation says that messages appear btwn brackets [] and that the msg target/object is on the left, whilst the msg itself (and any parameters) is on the right: [msgTarget msg], e.g., [myArray insertObject:anObject atIndex:0] OK, simple enough.....
How do you deploy your website in Azure so that it looks exactly like when you run it in your localhost? This is a very simple website that I created following the ASP.NET MVC4 tutorials. However, I added a new background image and it doesn't show. Is there anything else I need to do to make sure all of my files are b...
Here are reasons why one would want this: 1) We often don't use all the dlls but we force customers to install the entire .NET framework. It would be great to just deploy the dlls we need. 2) We often want to update our application and the framework but that sometimes requires a machine reboot because other applicatio...
I've been looking att different web stacks, mainly rails and node.js. One thing that strikes me is that while rails is often used with a relational database Node.js seem to go hand in hand with Mongodb, judging by the blogosphere. Is there a specific reason for this? I like the modularity of node but I'm also sceptical...
At our company we have pretty large body of PrototypeJS based JavaScript code, which we are porting to jQuery for several reasons (not really important here). I'm trying to set up coding guidelines to make/keep things tidy during the porting. One observation from wading through the prototype based implementation is tha...
Say I have a web service with a method MyWebServiceMethod(string passedValue). The web service calls a method MyServiceMethod(string passedValue) where the value from the web service is passed along. The service calls a repository method MyRepositoryMethod(string passedValue) where again, the value from the service is ...
Suppose I have component A,B,C that all put some data into a database. Each component depends on data in the database inserted by the previous component. How do I test these modules in isolation? I already have tests at the unit level, but I now want to test with the database. I have seen suggestions to make a dump of ...
For example, what happens if a coder tries to code in purely functional-style paradigm in OO-paradigm language(Java)? Will it work? Or the OO nature of Java will not let it happen? Also, is applying wrong paradigm to language unfitting to it a bad practice or not? Is it like trying to drive a jet on road instead of fly...
I currently work in a company where the Waterfall model is deeply ingrained. We are pushing Agile principles but it's a long process. Meanwhile, I have to work in a Waterfall world with sequential projects phases. My question is about the analysis phase. I must provide a list of task and how long they will take. What t...
I am pretty new to Web Application programming and so to OOP Javascript and the new Client-Server interactions. I am encountering some trouble wondering about how much AJAX I should use or how much data I have to save "locally" . Explainig it better: at the moment , to manage the data that I obtain from AJAX request ...
Quick background: In JavaScript, the constructor function for each object type has a prototype property. The prototype refers to an object that each constructed object uses as the next step up in its prototype chain. When you want one type to inherent from another type, you can set the prototype of the child type to a ...
I am developing an application, which currently has about 150,000 lines of code. The previous developer didn't really use any discipline when writing code. Application is in production but is continually developed. I have read Martin Fowler's book (Patterns of Enterprise Application Architecture) and it talks about 'T...
Many applications do nothing to separate the interface from domain logic. I’ve been programming for a couple decades and have worked at more than a dozen shops and none of them have taken any measure of separating the interface from the domain logic. That is, they're all using the Autonomous View pattern. This runs...
Why does 0 evaluate to false and any other integer value to true is most programming languages? String comparison First of all, it may seem evident to any programmer, but why wouldn't there be a programming language - there may actually be, but not any I used - where 0 evaluates to true and all the other integer values...
I tried to find if there's a similar question but didn't even know what keywords should I use :) I got a method in an interface accepting an other interface as a parameter: bool CanDoIt(AnInterface subject) One of the implementations needs to fulfill the requirement that the method should return false for all concrete...
For some time in personal projects I have been using XSL to convert my raw XML data into human-friendly HTML/CSS (in simple projects, I have no JavaScript, so let's leave that out of the equation for simplicity). Now I'm trying to understand the MVC architectural pattern (not my first experience with it, but it is taki...