instruction
stringlengths
34
19.9k
I would have two questions related to cyclomatic complexity: Can I use this metric for a whole app? I guess I cannot, as it would be incredibly large number, considering functions calling functions etc. Is it just for module/method/unit? In Visual Studio, for starting app with just calling the Main method, the cycloma...
I recently came across some newly written code that was interspersed with lots of Debug.Assert (C#). Should we still use this widely despite the usage of TDD, BDD and Unit Testing in general?
I am tasked with designing and implementing a flexible UI solution for deployment across a series of "kiosk"-ed Windows endpoints. There is some debate about what is the considered to be the best technology solution for the actual UI itself. The requirements are: Must be hardware accelerated Must play WMV video (for l...
I deployed a Redmine installation yesterday and today I try to fill it with some relevant data. One issue I came across is the organization of projects itself. While I took a look at how Redmine itself uses parts of the software, they unfortunately have only one project set up and I haven’t seen any other examples. I ...
Possible Duplicate: Asking for a code sample of the company at an interview Last year I changed jobs twice.. In the interviews with the companies, everything was so ideal and perfect. Latest frameworks, design patterns, distributed systems, scalable and enterprise systems, etc.. But in both cases something was not a...
Sources usually mention that dynamically created variables are allocated on the heap, while functions' variables on the stack. Also the ones on the stack cease to exist automatically when e.g. the function which contains the variable exits. If I understand correctly, data fields of class are on the heap. I do not under...
Possible Duplicate: Why were Java collections implemented with “optional methods” in the interface? I was looking at the javadoc for Collections and I noticed the unmodifiableCollection/unmodifiableList/etc. methods and I thought to myself, could this API be better? Here's one of the API signatures: public static ...
Preamble One of the concepts used in writing Python code is "Easier to ask for forgiveness than permission", aka EAFP. Literally, this means that instead of doing checks, whether an operation is possible, you do the operation and "ask forgiveness" if what you do fails. Technically this means (just an example with no pa...
I am a founder and only developer of an open-source software designed for a small subset of enterprises. It was originally developed for and now runs at one of businesses of the type it was designed for. It's my biggest project and I wanted to make something even bigger of it. Creating a software developing company and...
Is it possible to use the Windows 8 Store controls in a Windows 8 desktop app? Controls like the FlipView and SemanticZoom would be useful. I haven't found any information about this and would presume the answer is no, but thought someone would have a more definitive answer.
I have an exam on Programming Concepts this Saturday and I am struggling to find some information to understand some concepts better. What is the difference between loop invariant and assertion? To me they look the same. Also, what exactly is while loop invariance theorem? Not sure whether it is me or it is ridiculousl...
I'm a big fan of using open source software but I mostly use community binary releases for the job. I'm wondering about companies that go the extra degree and build everything they use in their production server application infrastructure entirely from source, in-house, in an effort to promote transparency and supporta...
I'm fairly new to OOP (and programming in general), but what I find myself doing is that in the event that I don't need to pass a value from one method to another, I'll have my method calls centralized in some class within a Form.cs file. For example: public void CentralMethod() { MethodA(); MethodC(); Meth...
Possible Duplicate: Should developers enter bugs into the bug tracking system? Should I log trivial fixes? For a project I'll be doing in school soon I will be working with 6 other people. We will probably be using YouTrack to track our bugs and we can obviously see the value in this system. My question, however, is...
As part of the interview process we initially ask the candidates to do 'FizzBuzz' nowadays the percentage of candidates that can correctly answer FizzBuzz has increased dramatically - this may be due to it's popularity on the web. About a year ago, as a second question we began asking a question very similar to the ori...
I'm confused between aggregation and containment. I'm wondering if the following represent an aggregation or containment? class Auto { private string model; private int speed; class AutoCustomer { public string LastName; public string Address; public DateTime DateOfPurchase; ...
Today I got yelled at for developing an application on a production server. Quote, "developing on a production server is not acceptable - ever!" Here is the situation. I set up a development instance: http://example.com:3000 The production instance is: http://example.com I complete all my development work on http://ex...
Just wondering what the accepted convention is for Rails controller design. Currently, every controller in my app that I've written it set up to send a JSON response when necessary. Thing is, I only ever utilse HTML responses in my app. So is it a good idea to have them defined? For example: def show @dog = Dog.find(...
I need help understanding a problem I have, and that others surely have had as well. I'm working on a web-application that allows users to interface with a database. The application in general has multiple pages with tabbed navigation, that displays and allows most content to be editable. So far, it works well. I need ...
Why is it often said that the test cases need to be made before we start coding? What are its pros and what the cons if we don't listen to this advice? Moreover, does that advice refer to black box testing or White Box testing or both?
I need to describe an algorithm that finds the second smallest element in a Fibonacci-Heap using the Operations: Insert, ExtractMin, DecreaseKey and GetMin. The last one is an algorithm previously implemented to find and return the smallest element of the heap. I thought I'd start by extracting the minimum, which resul...
I was reading about some development interview practices, specifically about the technical questions and tests asked at interviews and I've stumbled quite a few times over sayings of the genre "Ok you solved the problem with a while loop, now can you do it with recursion", or "everyone can solve this with a 100 lines w...
I have a page Object, which has Paragraph and Image object Collections And each paragraph has only image_id(s) that are assigned to a paragraph. All other information about image is stored in Page->Image Now from the paragraph object I want to access the image information where paragraph has only image_id and all other...
The question in general is: is there a more effective way of implementation of table with structure like Dictionary<int, Dictionary<string, string>>? The reason I am asking this is because I have made few performance tests and it does not perform well for data with > 5M rows. Now, I dont really need this amount of data...
Neo4j eases relationship traversals => especially useful for a social network for instance. But are there any scenarios when it's advised to associate an additional relational database (or other NoSQL database that isn't specifically oriented graph) for specific query types. In short, can Neo4j be sufficient to itself ...
in my application, I have a request type associated with variety of API calls I make to the REST server. when the response from server comes in the same delegate method for web engine's response, I have to check the API type in the request object passed as a parameter to the delegate method and then take the correspon...
This is what I call a "combined" getter/setter method (from jQuery): var foo = $("<div>This is my HTML</div>"), myText; myText = foo.text(); // myHTML now equals "This is my HTML" (Getter) foo.text("This is a new value"); // The text now equals "This is a new value") This is the same logic with separate (theoreti...
Recently we had an issue on our site where someone attempted SQL injection via a cookie (we'll call it lastID). NOC was in a frenzy and angry about how the cookie as an attack vector could be ignored. They had a developer create a class for managing cookies that will sanitize lastID (and eventually other cookies) to ...
For my final project in school we have to develop an online shop. This shop should have a cart where items can be placed whether or not you are logged in. If you log out the cart shouldn't empty and should still be shown. So my question is would it make sense to store the cart as xml in the database(ms sql server)? The...
I have been trying to understand why the JDK 8 Lambda Expert Group (EG) decided not to include a new function type into the Java programming language. Going over the mailing list I found a thread with the discussion about removal of function types. Many of the statements are ambiguous to me, maybe because of the lack o...
What are the most obvious drawbacks to this idea for an enterprise(ish) model using the following technologies. Browser based and native developed GUI using Delphi to connect to Datasnap server (Delphi, obviously) via Rest which stores documents in A CouchDB Server But gets the structure for those documents from ...
A user on Stack Overflow posted a question related to overriding a native JS function. The question is here and this is the code: function throttle(fn, time) { var handle; var execute = function() { handle = null; fn.apply(this, arguments); }; var throttled = function() { if(!handle) { handl...
I have the following project structure I would like to implement. I would like to know if there are any pitfalls to structuring my code this way. It is going to be using Microsoft's WebAPI, an MVC 4 project, and Plain Old C# Objects (POCO). The explanation follows. First off there is going to be a class library project...
I'm working on a project which runs as a process, on a regular basis. The results of the projects daily run are used by other projects. This brings me to question how our team writes stories. The normal format, As a [role] I want [goal/desire] so that [reason] does not seem to apply, but at the same time I'm doubting t...
I'm developing a series of repository classes and a UnitOfWork class (plus its IUnitOfWork interface of course). I'm using Castle Windsor, which injects dependencies via constructors. My business tier has classes such as "CustomerBusinessLogic", with methods like RetrieveCustomer, SaveCustomer, etc. These in turn use t...
I am working on a project with legacy code where it does not have much code coverage. One of the idea to improve that is to enforce a rule that each code check-in must have test, not only test but functional test as well, so that we can verify that the existing code did not break. I would like to get some ideas, both p...
I am designing a simple GUI that will allow a user to create a GPX route by clicking repeatedly on a map panel. I am faced with a design dilemma for how to represent the nodes and route. This construct can be abstracted as follows: the user clicks n times on the screen in sequence to create a chain of n nodes after ...
I understand that two of the many more options for inter process communication can be : Shared memory Sockets Actually I saw these two options being exposed by Intellij Idea for debugging a Java application . I want to know what are the pros and cons of each approach .
It's more of a scenario, but it isn't far fetched at all. Let's say I have an Aggregate Root (AR) Warehouse which it's used to manage product stock. The Product itself is an AR in a different bounded context (BC) but in this BC is represented only by an id. In the Warehouse I can add a new product (must be unique), Ica...
I'd like to know what would be a better approach to invalidate/update cache objects. Prerequisites Having remote memcached server (serving as cache for multiple applications) All servers are hosted by azure (affinity regions, same data centers) Cache object size ranges from 200 bytes up to a 50 kilobytes Approach 1...
In what all aspects, calling a function with and without new keyword differ in javascript? I mean what all things are differing between? testFn() vs new testFn()
A bit of background (in case I'm mistaken)... I think I understand that (it's an oversimplification): manually entering codes into memory (or on a punchcard) is "first generation language" using mnemonics corresponding to CPU instructions would be a 2GL (like assembly language) C/C#/Java/Objective-C are all 3GLs SQL i...
I've been attending quite a few interviews recently and have been asked by companies to answer "design a [insert model]" questions more than a few times. Is this normal in the industry nowadays? I've been in the software world for more than two decades and have attended my share of interviews, but I am seeing this pa...
I'll be quite to the point, is there any way to make Javascript a bit more concealed than it usually is or is Javascript always out and open if you look in the source code ? This is about hiding proprietary algorithms that would dispense a service that does not exist yet (to my knowledge) on the market and is not reall...
Currently, I'm a long Eclipse user because my past and current companies always deal with eclipse. Recently I met some example java codes created using netbeans. I downloaded and tried Netbeans 7.x and 6.9.x, but they're more heavier and eating memory resources than Eclipse Indigo. So anyone know which past version of ...
This might be one of those "not answerable" or "just opinions"-questions but I thought I'd give it a shot. I'm developing an app with health care information with a friend who's a doctor. The basics of app are done and the information in the database is shaping up so now I've come to the question of wether, and if so h...
I am newbie to TDD (writing first project following TDD practices). I have fairly basic interface IProfiler and an implementation Profiler. interface IProfiler { bool IsBusy {get;} long Elapsed {get;} } A Simple Test IProfiler profiler = default(Profiler); [TestInitialize] public void Initialize() ...
I'd like to ask how to protect my code that is running on a client server from being altered and/or copied. It's running on Ubuntu Server with the standard Apache Php Mysql stack. Any software needed would preferably be open-source. I'd also like to terminate the application when there is a license problem. Doing thi...
I would like to use a timer in my C# program with millisecond accuracy to keep a camera in sync with some events and keep shooting a picture every 250ms (or 1/4 sec, or I might adjust it to even shorter times like 200ms or 100ms). The normal timer event can be used for this. But I wonder what would be the best way to d...
I don't know what best to give as title to this so pardon me if it sounds weird. I saw this question asked on IT Security and another site asking people to disable Java from their system or browser because it's vulnerable. As a lover of Java, though currently doing C#, I would love to still do more Java in future, but ...
As I have been learning to program, be it in my intern-ship or school, I have often come across situations where an extra piece of software is needed (from fairly basic to quite complex) and I am almost always told that I shouldn't waste my time developing a solution and use something someone else has already done. Doe...
I've heard people saying usage of JDBC (Java Database Connectivity) isn't recommended in Java applets. All I they say is: 'because of the security reasons'. What 'security reasons' do they mean? What would a potentially 'bad person' do when he/she found out about JDBC used in an applet, placed somewhere on a website? ...
I have a software patterns exam this week and one of the topics we are to study is Efferent and Afferent coupling. I understand a package has a high Ce (efferent coupling) if it depends on a number of other types. For example: class Car{ Engine engine; Wheel wheel; Body body; } This class would have a hig...
I'm resistant to calling the "main" class the same as the namespace, but I sometimes find myself needing it. Considering I'm using the Vendor.Namespace.[Subnamespace].Class formula, imagine this scenario: [MyFramework] [Database] Database Sql Schema DriverAbstract DriverInter...
In the C++ STL, priority_queue (heap) can be used with any underlying container, such as a deque. How does the implementation stay O(log n) if deques don't swap an item in index a with index b in constant time?
I want to understand how web accessibility experts deals with websites if they want to confirm that those sites are compatible with accessibility guidelines. Do they have to understand any server-side language? or just HTML and CSS? For example, if there is a company website which provides services for other sites to e...
Lets say I'm displaying a bunch of data (model) using a View class for rendering. However, a lot of the data has sub-data (models) complicated enough to require separate rendering classes. In my design, a View class has a model which it is rendering, and has many children Views which display the sub-data. In some cases...
In our company, we need to build a web interface onto an embedded Linux platform. I kind of see 2 options: You use a technology where the HTML and JavaScript is generated on the server side (Think JSP, Grails, but is is something that is using C++ and generates HTML/JavaScript) or you create a HTML5 'client' applicatio...
Stumbled upon this post that talks about making async web requests. Now simplicity aside, if in real world, all you do is make an async request and wait for it in the very next line, isn't that the same as making a sync call in the first place?
I'm rewriting a set of file readers that a former-colleague of mine created that read raw-point data of XYZ (Cartesian) coordinates or RTZ (Polar) coordinates. Currently the data is stored directly in the reader, making everything rely on the state of those objects. I'd like to separate the reader from the collected da...
I am implementing inheritance of something called Contexts. Each Context holds a link to its parent context. If that Context is the root Context, its parent is null. In order to walk up the inheritance tree and get the data from each Context, I want to do this (in pseudocode) private Hashtable getDataAsMap() { Hash...
So far all my development in C++ has been targeted to Windows, however I have always had it in the back of my mind that I will someday be targeting Linux. I am aware therefore of the need to select cross-platform libraries, and to keep my code as portable as possible (or provide alternative implementations for code whi...
Django creates a table name by joining the app label with the model name. A project can have many apps. If two have the same label, how can both be used in the same database? I'm currently using very long app names to minimize that risk (such as foo_bar_baz instead of nesting modules like foo.bar.baz - app label baz). ...
I want to make Python script that will accept input from Vim and send it to my web-site. So basically I want to make Vim my text-editor for blog articles. Of course, I need to authenticate and authorizate. I wanted to simply ask username and password. My college asked me why not to take login data from file. I answered...
I am new to web development and just started exploring the things. I read about how web page is processed and sent to client by a web server but I got confused with application server. what is the difference between them ? why app. server is needed ? and few examples of both of them .
I have been in various Agile projects and seen many release burndown chart styles. Most of them were handled manually since somehow all the tools that I have run across don't produce really useful burndown charts. In reality, we may not be dealing with all stories estimated and we just keep burning down. Many times, th...
I know pair programming is an agile software development technique in which two programmers work together at one workstation. One, the driver, writes code while the other, the observer, reviews each line of code as it is typed in. But I just wonder the strategy still work in the case. For example if they have a very ...
I have some experience in Java programming and enterprise application development. I have done OOP, data structures in C++ for my undergraduate studies. But I couldn't touch C++ for years. Now I am interested in C++ again and I would like to polish my C++ knowledge and become an expert in C++ . How do I start my journe...
We develop social-based applications for mobile. Every application consumes RESTful API web-services. When I implement login I usually store the username and password somewhere on device. Then I send them and as a response I get access to my profile. But I also know there's another way to do this. One somehow generates...
This isn't a rare case and occurs with me often and I spent countless time trying to debug the code. Latest example, this PHP code where I used $email for the parameter and for object as well. private function _mail( $email ) { if( filter_var( $email, FILTER_VALIDATE_EMAIL ) ): $email = new Zend_Mail(); ...
I am in the process of a creating a small web portal for the department I'm working in. For this is need to present some data, and have found the following: http://www.pchart.net/, which could seem to be of great help to me. The above is licensed under GNU GPLv3, and my question is whether it would be allowed for me t...
Context I'm currently working on a personal project involving functional reactive JavaScript, and I've come up with an odd question. Note that this question is not JavaScript specific, but that is the context in which I am asking it. Scenario When filtering a collection of data, you end up with a smaller set of data. T...
I have a function that accepts either a string or a dictionary as an argument. That is, it can be called as either: lookup_person({name: "John Smith", age: 57}) or lookup_person("John Smith") My first inclination is to use type or isinstance to distinguish the type of the argument, but I've seen a lot of ink spilled ...
Background Software engineering is the application of a systematic, disciplined, quantifiable approach to the design, development, operation, and maintenance of software, and the study of these approaches; that is, the application of engineering to software. My instructor, when explaining this definition has told me th...
This is what I guess would happen: If two cores tried to access the same address in RAM, one would have to wait for the other to access the RAM. The second time that each core would try to access the same address, they may still have that RAM cached, so they could access their respective caches simultaneously. If two...
Often what's displayed to a user (e.g. on a web page) will be based partly on security checks. I usually consider user-level / ACL security to be part of the business logic of a system. If a view explicitly checks security to conditionally display UI elements, is it violating MVC by containing business logic?
I have a function containing other functions. These function are called based on value of variable action. These sub functions are logically grouped - i.e., they all deal with file manipulation. Each function has 2 to 5 lines. I would like to improve the style. Is there a more concise way of achieving this end than wh...
Objective-C lacks private methods or java-esque final methods. This means that it is possible for a subclass to (accidentally) override some of the internals of a superclass. How does one prevent overriding methods in Objective-C?
I've got some code that I want to run when certain HTML elements are added to the page. To do this, I have a "runOnRender" function: runOnRender: function (func, args, interval) { var that = this; var guid = hb.getGuid().substr(0,7); var checkFunc = function () { i...
Most low latency/high frequency programming jobs (based on job specs) appear to be implemented on unix platforms. In a lot of the specs they make particular request for people with "low latency linux" type of experience. Assuming this does not mean a real-time linux OS, could people give me help with what this could be...
I have been stuck for some time on which is the fastest string search algorithm, heard many opinions, but in the end I'm not sure. I have heard some people saying that the fastest algorithm is Boyer-Moore and some saying that Knuth-Morris-Pratt is actually faster. I have looked up for the complexity on both of them b...
This question could go here or on S.O. perhaps... Suppose that your training dataset contains both categorical and continuous data such as this setup: Animal, breed, sex, age, weight, blood_pressure, annual_cost cat, calico, M, 10, 15 , 100 , 100 cat, tabby, F, 5, 10 , 80 ...
I have the following sample question for a compilers exam and wanted to check my solution. Convert the following grammar into an LL(1) grammar which recognises the same language: E -> E + T E -> T T -> id T -> id() T -> id(L) L -> E;L L -> E For my answer I have E -> T E' E' -> + T | ε T -> id T -> i...
We recently had a consultant tell us that if a feature can only be tested via automated UI tests (e.g. Selenium, Coded UI), then there is an underlying architectural issue. While this statement might be a bit extreme, it is along the same lines of the testing pyramid in that UI tests should make up a small portion of ...
In my company, we successfully working with agile practices - but without using iterations. The main reason is that we can't find a clean way to fit in QA in an iteration cycle. We understand QA as an extra bit of verification to a certain build (release candidate) before this build gets deployed to the customer. The p...
I'm making mandelbrot fractals in C using Xcode and I want to use parallel computing but everything I've tried so far doesn't work. Such as This Question and other how to guides. Whats the easiest way to use frameworks such as mpi.h to run my program in parallel?
I've been reading Martin Fowler's Refactoring. It is generally excellent but one of Fowler's recommendations seems to be causing a little trouble. Fowler recommends that you replace temporary variables with a query, so instead of this: double getPrice() { final int basePrice = _quantity * _itemPrice; final doub...
Disclaimer: Not as exaggerated as the title suggests, but it still makes me uncomfortable. I'm just going to express honestly, so take it with a grain of salt. Just pretend that I'm talking about that coding standard that you don't like working with. Edit: The fact that I don't like it, doesn't mean I don't use it or e...
I have been developing an Immutable queue in java, but the version I have developed is supposedly slow and I have been suggested to create a faster version of the same and I have no idea as to how to accomplish that. import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; public clas...
In ASP.Net MVC, in the razor view, you can type this kind of code: @Html.EditorFor(model => model.Name) (in this case, it creates a textbox for the field Name of the object which is defined as the type of the model) Now when i see the definition of the EditorFor method, it is this: EditorFor<TModel, TValue>(this HtmlH...
I'm looking at implementing a PHP based application, where by you have a certain route for example London to Edinburgh. Along this route, I want to calculate say a 10mi Radius or Polygon around the whole route/driving directions, check whether certain defined points/lat-lon's are within this radius. If so - Add them to...
I realise this might be offtopic here - but I couldn't find a better place in the stackexchange family. And this question has simply been bugging me for years.. What I wonder is: can an eula define WHAT you use an application for? IE: if I write a text editor, can I say "You can't write fantasy novels with it". I'm wo...
The company I used to work for before we had automated unit tests to test our work. However the coding standards and architecture was not very important for tests. Of course you had to indent code correctly and put your braces where you are supposed to put your braces, but no one would go nit picking through your tests...
Or more generally: to trigger compiler errors in test projects if something that can be checked at compile time is wrong?
I've written a recursive search algorithm to find the boundaries of a voxel data structure in order to render it more efficiently. I've looked around, and either it's such a simple and obvious technique that nobody's bothered to patent it, or it's novel and nobody's done it this way before. It's openly "published" on G...
I have a bit of experience with loop invariants but I'm not really clear on them. I'm trying to learn them through an example in Python. Can someone point one out or help me understand? I've searched both on programmers.SX and on the web but the only things I could find were invariants and design by contract -- nothin...
Possible Duplicate: To branch or not to branch? A co-worker is against branching. I use branching all the time. I put the team onto a basic 3 branch system. I create my own feature branches. Said co-worker tends to have good ideas, follow best practices and I tend to agree with him on many such things. Except ...
Given a mutable property, it generally makes sense to only hold/store that property in a single place. When the data needs to change you only need to update a single field, and you can completely avoid bugs where the different fields get out of sync. An extremely simple example could be: The 'right' approach: class Own...
Although it is a commonly held opinion that planning poker improves the accuracy of project estimations (a small sample of which demonstrated on this question), has any defined research been done on the subject? More specifically, I am looking for non-circumstantial information showing that planning poker would be an i...
I have built a QlikView script generator (QVS), that can be used to generate large script files for data imports from SQL Server to QlikView. QlikView does not like 'fully' normalised database structures (loops between several tables): for example, three tables A, B, C in SQL Server could have three PK/FK links; in Qli...