Throwing an exception inside finally

Static code analyzers like Fortify "complain" when an exception might be thrown inside a `finally` block, saying that `Using a throw statement inside a finally block breaks the logical progression through the try-catch-finally`. Normally I agree with this. But recently I've come across this code:               SomeFileWriter writer = null;      try {           //init the writer          //write into the file     } catch (...) {          //exception handling     } finally {          if (writer!= null) writer.close();       }      Now if the `writer` cannot be closed properly the `writer.close()` method will throw an exception. An exception should be thrown because (most probably) the file wasn't saved after writing. I could declare an extra variable, set it if there was an error closing the `writer` and throw an exception after the finally block. But this code works fine and I'm not sure whether to change it or not. What are the drawbacks of throwing an exception inside the `finally` block?


Organizing related projects and dependencies for nuget publishing

I've been working on writing .NET bindings for Rollbar, an error and message reporting service, like Airbrake. My library is working nicely and is published in the NuGet gallery. So now I want to take it to the next level of usability and implement an NLog Extension for this. This entails writing one screen's-worth of code and referencing the NLog library. It's a wrapper. I may also implement one for Log4Net. At this point it's already getting blurry as to how I should organize this and manage it with source control and nuget. One thing for sure is that there will be separate nuget packages so people don't have to install dependencies they don't want. My questions are:   1. Should I create separate git repositories for the base library and NLog extension and Log4Net extension? Seems like it would be easier to track changes have clearly separated build processes and such. It may make contributing to the project(s) easier...but I'm not sure.   2. Should I reference my Rollbar base library as a dependency of the extension libraries, or ILMerge it? The upside to ILMerge is the user only needs one reference and DLL. The odd part is with versioning. Like how to have version numbers that make sense when only the base library changed, or only the extension changed. Also, it seems like nuget doesn't list updates to dependencies of installed packages, only to the packages itself. I'd want updates to the base library to bubble-up as an update the user should install! I suppose one way to do that would be version-bumping the extension _and_ setting the version of the dependency library. This is my first foray into writing an open source library and publishing it and managing it. I'd love some feedback from people who have dealt with this so I can get it right! I'm using Albacore for my build process, for what it's worth. (Current code: https://github.com/mroach/RollbarSharp)


Disagreement Concerning Data Integration (I may not understand enterprise ETL tools)

I have been in an ongoing conversation concerning a project we are about to undertake at my place at work. The project concerns data integration. Our customers want to be able to integrate our data with theirs, either by sending data from their systems into ours, or by getting data from our system into theirs. I don't believe we are talking about 'big data.' Our entire database is less than 20 gigs. The individual transfers from our customers will be very small as well - on the order of 10s of MBs, if not smaller. A major goal for this project is to minimize the amount of work needed to be done by the customer, who tends to not be very technical. In the past, this problem has been "solved" by having our customers send us an xml file that is transformed by xlst before being saved to the database, or through a WCF application for exporting data. These are not seen as good solutions. My first thought was to create a REST interface with very good monitoring tools and libraries for our clients. Another option that is being considered are big tools like IBM datastage or Pentaho (or similar). My personal problem is that when I look at these tools, I don't see how they can help. It looks like they are aimed at setting up large scale data transfers that happen on a regular schedule with a given format. Adding a new import/export using those tools requires a lot of setup both for us and the customer, which we are trying to avoid. They are also not really useful for real-time data updates. Finally, they seem like they are trying to kill an ant with a flamethrower - they are heavyweights for a light weight problem. In contrast, with a REST setup, data can be transferred whenever required, and Setup only needs to happen in a very small area. Am I missing something when it comes to these ETL solutions? Am I not being fair to them?


Is there genetic relationship between ARM and PDP-11 architectures?

Reading about ARM architecture I found many similarities to PDP-11 architecture which did not exist between ARM and x86. For example,   * General-purpose registers named Rx compared to AX, BX,... for x86   * Uniform registry file (all registers permit all kinds of operations)   * Similar names for program counter (PC both on ARM and PDP), compared to IP in x86.    * Inclusion of Program Counter into general registry file (in PDP it also can be refereed to as R7, in ARM - as R15, both the last registers in the file).   * Inclusion of I/O ports into general address space (i.e. addressing them as memory) compared to a separated I/O address space in x85 (and special I/O instructions).   * Using 3-letter basic assembler mnemonics (TST compared to "test" in x86) with suffixes specifying data type (such as "B" for byte, compared to constructions like "byte ptr" in x86)   * Using BNE, BEQ and other B _condition_ instructions for branches.   * Use of "#" symbol before a number to specify an immediate value (compared to "." in x86) etc. So is there any historical relationship between ARM and PDP that makes them closer to each other than to x86?


Why is new product development always rushed?

If you are working on something **new** you have less than the required time to do it, and sometimes you are expected to work late, weekends etc (even when you are waiting on people who are not working those hours). I even had a boss once who came by and told me to make sure I had something to do on Saturday. This seems to be true even when no competitors are putting something similar on the market. If you are working on **feature enhancements** or **maintenance** you are encouraged to take your time, review your options, study up on things, etc. Sometimes I even get the feel that you are expected by leadership to catch up on your fantasy football and analyze topics like Game of Thrones, Call of Duty, etc. My question is: why not just take the extra time from the existing software development and spend it on the new projects that are starving for time?


Pros and Cons of working Remotely/from Home

I have never had the opportunity to work from home on certain days, but I would definitely like to try it if I can. What are the pros and cons? I'll list a few that I can think of. Pros:   * You don't need to do any work. (That's a JOKE)   * You can be a lot more productive. No commute, relaxed, no meetings, no interruptions Cons:   * Less of a team effort.   * Other team members can get held up due to having to wait for information for an off-site member Apologies if this has been asked before - I did a search but couldn't find a pros and cons discussion. Edit: It appears The Oatmeal has already covered this! :-)


Extending Composite Structure model generally/in Enterprise Architect

I'm currently on a project, which integrates domain specific techniques in the modelling tool Enterprise Architect through UML Profiles. The domain specfic model almost matches the structure of the composite structure model, with a couple of restrictions though, so I'm trying to use the model as a foundation for my restrictions. The questions: 1) How can I generally extend models (like composite structure models) which themselves lie in the M1-layer of Meta-Object Facility? 2) Is the element "Part" of composite structure diagrams a metaclass itself, which can be extended by stereotypes in UML profiles? Since the literature on these topics is not very exhaustive, I'm also looking for suggestions, too.


Charge client for SaaS development?

Situation: For many years, ACME corp has outsourced `Task B` to me. Over the years I've learned the ins and outs of `Task A` (manual labor). Together `Task A` \+ `Task B` = finished ACME corp product. So now I discovered an opportunity to optimize their `Task A` process. But to develop a system to help ACME corp to work more efficiently, I need to put in a lot of programming work hours up front. Maybe 1-2 years to prototype, test and finally deploy, then I'll be ready to confront them with my solution. It'll take another 1 year to successfully have them switch from the old way of doing things to my new method. So in this situation, what is the proper to way to charge? Should I just suck in everything in the beginning? Or charge them for initial development? Ultimately they will be required to pay each time they use my SaaS to complete their `Task A`. Note that my SaaS is only useful for ACME corp, I don't see much use for my SaaS product to the mass market.


How to manage source code customizations for many users?

When I wrote original code, I was using TortoiseSVN to manage versions, but later a new problem evolved. Customers desired customization on few things and now the list of customers is growing. I want to keep version control depending upon customers. I want to keep a root source code and than add version changes depending upon customers. Is there any simple way?


What is the best way to load balance javascript applications?

I write a lot of javascript applications and in many different circumstances the browser will become unresponsive or give a "slow script" error. Even when following best practices, initializing large data sets, complex animation, or when too many event handlers fire at once, I have to include extra setTimeouts or requestAnimationFrames around script blocks to load balance them. Seems like there should be some standard way of managing the browser load for large javascript applications. Any ideas? It seems like there must be JS application designers thinking about this, but I can find nothing on the web or on stack. _**edit_** I appreciate all the response. My question is _not_ "How can I write efficient Javascript?" which seems to be the question the current responses are answering. My question is: How can I balance the load of multiple sequential threads of javascripts running in the same browser? I am well aware of all the information posted in the responses so far and appreciate the posters, but I am looking for a framework or a design pattern that balances script execution in a browser. This question is common in many other languages and for devops, I am simply asking the same question for javascript.


Do you need Hardware skills to be a Robotic Programmer?

I want to know: _Do you need hardware skills to be a robotic programmer?_


Help me understand how to index a pixel in an image

I had a look at the code for the implementation of this paper  Graph-Based segmentation by Pedro F. Felzenszwalb But I didn't understand how in the below code that `y * width + x` is used to build a graph from an image.               // build graph     edge *edges = new edge[width*height*4];     int num = 0;     for (y = 0; y < height; y++) {         for ( x = 0; x < width; x++) {             if (x < width-1) {                  edges[num].a = y * width + x;                  edges[num].b = y * width + (x+1);                  edges[num].w = diff(smooth_r, smooth_g, smooth_b, x, y, x+1, y);                  num++;              }                   if (y < height-1) {                 edges[num].a = y * width + x;                 edges[num].b = (y+1) * width + x;                 edges[num].w = diff(smooth_r, smooth_g, smooth_b, x, y, x, y+1);                 num++;              }                   if ((x < width-1) && (y < height-1)) {                 edges[num].a = y * width + x;                 edges[num].b = (y+1) * width + (x+1);                 edges[num].w = diff(smooth_r, smooth_g, smooth_b, x, y, x+1, y+1);                 num++;              }                   if ((x < width-1) && (y > 0)) {                 edges[num].a = y * width + x;                 edges[num].b = (y-1) * width + (x+1);                 edges[num].w = diff(smooth_r, smooth_g, smooth_b, x, y, x+1, y-1);                 num++;              }          }     }


Algorithm to find last allocated job for each worker

Let's say we have n jobs numbered from 1 upto n and k workers numbered from 1 upto k. All the jobs are equally difficult, but some workers are more efficient than others, so we are given the time it takes for each worker to perform his job. In fact no two workers are able to finish their jobs in the same time. At first all the workers take care of the job numbered the same as them (first takes the first, second takes the second job etc.). If someone finishes his job, he starts doing the job with the lowest number that no one has started doing. In case of a draw (two or more workers finish at the same time) the worker with lower identifier starts doing the lower numbered job, the other the higher numbered. Workers work until all the jobs have been done. For each worker, we would like to return the number of the last job he completed. Example:   n = 10   k = 3   workers efficiency: 1->3, 2->5, 3->6 At first workers one, two, three start doing jobs: 1,2,3.   At time 3 one finishes his job and starts doing 4.   At time 5 two starts doing 5.   At time 6 both one and three finish their jobs - they start doing 6 and 7 respectively.   At time 9 one start doing 8.   At time 10 two start doing 9.   And finally at time 12 one start doing 10, the last job.   Therefore the answer is: 1->10, 2->9, 3->7. It is easy to solve this problem by simulating this procedure maintaining a priority queue of workers. The running time of this algorithm would be O(nlogn). I am wondering, how would one solve this problem faster, without simulating, for large values of n.


Languages & Their Licensing?

Firstly, apologizes for any bad terminology, lack of research, or poor delivery of my question. I should note that originally I had one big question, but I figured the first half is sort of independent, so I've posted it individually, link. My understanding of "commercial purposes" is so far based on the OP of that question. So basically my next piece of work will be the first to be involved in a commercial purpose, so I want to learn how to make appropriate technology choices that puts me on the safe side of legal concerns, **let's take Java for a case example** :   1. I will assume that the only thing I need to worry about is the licensing of JDK.   2. It seems that the license for JDK is this one, which seems to not put any commercial concerns except for contents of table 1-1 from this link, which are stuff I never heard about, and probably won't cross.   3. From #2, and from various implications that JDK mainly adheres to GPL, and from what I understood from GPL, it seems Java is in the green when it comes to commercial purposes, provided the owner of the executable has also ownership of the corresponding source code. **Q1:** So, are my previous conclusions correct? **Q2:** The research process was really exhausting from my end, are there some key elements to pursue when checking these stuff? or are there online resources/communities that already did most of this verification research? Forward thanks.


Is there too much abstraction in the Ruby on Rails community?

Rails, to me, seems like a perfect level of abstraction for most types of web development. However, having watched some seasoned Rails consultants build an application, I'm finding that they use Gems to an extent that it's often pretty difficult to figure out what's going on in the code. As an intermediate-level Rails developer, I've had a pretty hard time digging through their code to figure out how things work, and I'm really struggling to see the payoff of this approach. So is it me, or does Rails, by dint of the fact that it has such a vibrant community of contributors, kind of encourage over-abstraction?


Naming your software and uniqueness

When it comes to naming your software _product_ (whether an application or a library), what do you do? It seems impossible to choose a name which isn't already taken by some other piece of software, whether it's someone's small hobby project or a company selling it. We all know about Phoenix becoming Firebird becoming Firefox because it clashed with other software product names. How unique does a name have to be? Phoenix was the name of a computer BIOS - hardly similar to a web browser, wasn't it? And to take a counter-example, there's Fedora the operating system and Fedora the repository software, happily co-existing. Another counter-example is midori the Javascript framework and midori the web browser. What steps would you take to ensure the name of your application or library isn't taken by someone else, and how far would you look - in terms of the type of product - when looking for other things with the same name?


PHP, HTML, Javascript and writing good practices

I realized I have to write down a convention specification about HTML, JavaScript and PHP coding for me and my team. In web development, just like in C++, I'm definitely a fan of indentation and comments. Nonetheless, often in my work I encounter HTML+JavaScript+PHP code which suddenly brings up the headache. I'm trying to make my code readable, but what seems to be better to me (to indent & comment) seems not to fascinate my teammates, so I was wondering if there is a best or at least shared good practice when writing "hybrid" documents just like today's web pages, which day by day become more and more complex. I'm aware of the fact that probably it is in the nature of today's web pages' code to be a little bit intricated, but I wonder if a good convention concerning these aspects already exists.


Best practices for execution of untrusted code

I have a project where I need to allow users to run arbitrary, untrusted python code (a bit like this) against my server. I'm fairly new to python and I'd like to avoid making any mistakes that introduce security holes or other vulnerabilities into the system. Are there any best-practices available, recommended reading, or other pointers you can give me make my service usable but not abusable? Here's what I've considered so far:   * Remove `__builtins__` from the `exec` context to prohibit use of potentially dangerous packages like `os`. Users will only be able to use packages I provide to them.   * Use threads to enforce a reasonable timeout.   * I'd like to limit the total amount of memory that can be allocated within the `exec` context, but I'm not sure if it's even possible. There are some alternatives to a straight `exec`, but I'm not sure which of these would be helpful here:   * Using an `ast.NodeVisitor` to catch any attempt to access unsafe objects. But what objects should I prohibit?   * Searching for any double-underscores in the input. (less graceful than the above option).   * Using `PyPy` or something similar to sandbox the code. _NOTE:_ I'm aware that there is at least one JavaScript-based interpreter. That will not work in my scenario.


High-Availability Vs. Cloud Scaling

I work for a company that develops a web server that runs in a customer datacenter. The customer wants the server to have hot failover and I'm currently investigating HA approaches such as Pacemaker and LVM (might as well have the backup doing something so I'm using load balancing as well). It occurs to me that some of these features are also provided by cloud computing (e.g. private cloud) technologies. Specifically auto-scaling which is provided by EC2 and cloud foundry addresses load balancing and failover support to some degree. As a new application would I be better off spending my time trying to setup the application as a private cloud or by utilizing the tried and true HA architectures?


Compile and run submissions of online judge in the same or separate server?

I am going to make an online judge platform. I have looked for some online judge platforms on the Internet for reference (I mean the platforms which have the source code available, and can be hosted my others, not something like Codeforces). Most of them have a web interface written in PHP (or something else). When users submit the solutions of the problems, the submissions are sent to another programs (a server side program written in C++, Java or something else), which is hosted on or not on the same server, through socket. What is the benefit of this design? Why not doing so through PHP, with functions like `exec()`? Which design will you appreciate more?


Best way to choose random element from weighted list

I want to create a simple game. Every so often, a power up should appear. Right now the different kinds of power ups are stored in an array. However, not every power up should appear equally often: For instance, a score multiplier should appear much more often than an extra life. What is the best/fastest way to pick an element at random from a list where some of the elements should be picked more often than others?


Is a NoSQL database suitable for me?

I'm developing a WPF application whose core functionality involves creating a large object graph (often tens of thousands of entities) which the user can modify certain parts of, then save to a database. A graph can also be subsequently retrieved, modified and saved again. It's feasible that a user can create dozens of these graphs per day. The app also provides the user with different ways to search the entities in the database (predominantly text searches on various fields), presenting the search results to the user and allowing the user to select one, which will result in the relevant entity graph being retrieved in full and presented for the user to view and modify as above. Currently I'm using Entity Framework and SQL Express, but I'm uneasy about certain aspects of the architecture and design, and the client isn't keen on having to install SS. I've only recently come across the concept of NoSql databases, and sounds like they might be a good fit for what I'm doing, but I have a couple of questions. First, I'm assuming performance wouldn't be any worse than EF when reading or writing one of these object graphs? What about my app's search functionality? Will a NoSql db support this sort of thing, and what would the performance be like, bearing in mind the size and quantity of "documents" that I'm likely to have. What about lookup (reference) data? Would I duplicate such data in each NoSQL document, or would I keep it all in a single NoSql document and store their IDs in the main documents? Finally, any recommendations for a product? MongoDb and RavenDb seem to be the main OSS contenders for Windows.


A better JavaDoc?

The standard JavaDoc template(Doclet) didn't change much until the recent JDK7. In my opinion, JDK7 template only made it even more difficult to browse. I looked at several third-party doclets, but none is what I want. So I started to design a new open source JavaDoc template from scratch to improve the usability. Here's something I thought about,   * Searching. It should be done at client side to make it working on your local file system.   * IDE-like interactive navigation. The standard JavaDoc uses two frames to show packages and classes separately, which is far less usable than an Eclipse-like navigator. What made it even worse is that if you clicked inside the right side frame, the package index and class index will not refresh accordingly. You have no idea where you are.   * URLs. One drawback of the frames is that the URL do not change according to the frames. It's very frustrating that you can't send a JavaDoc URL to someone unless you explicitly check the URL of the individual frame.   * Look and feel. You don't need to be a designer to see JavaDoc is ugly. I want to make JavaDoc better and I want to make sure I do it right. The question for you to answer is, What you expect a better JavaDoc should be?


Strategy for versioning on a public repo

Suppose I'm developing a (javascript) library which is hosted on a public repo (e.g. github). My aim in terms of how version numbers are assigned and incremented is to follow the guidelines of semantic versioning. Now, there's a number of files in my project which compose the actual lib and a number of files that 'support it', the latter being docs, a test suite, etc. My perspective this far has been that version numbers should only apply to the actual lib - not the project as a whole - since the lib alone is 'the unit' that defines the public API. However I'm not satisfied with this approach as, for example, a fix in the test suite constitutes an 'improvement' in my project, which will not be reflected in the version number (or the docs which contain a reference to it). On a more practical level, various tools, such as package managers, may (understandably) not play along with this strategy. For example, when trying to publish a change which is not reflected in the version number, `npm publish` fails with the suggestion "Bump the 'version' field set the --force flag, or npm unpublish". Am I doing it wrong?


Can I take a year off without hurting my career?

I've been working since I graduated for the past year at a bank as a developer, first starting out maintaining a legacy application, then transitioning into developing new workflows. The work's okay, but my employer doesn't really understand how development works. I am considering taking an opportunity to teach English in a foreign country for a year. By the time I leave I will have been working for two years as a developer. Could taking a year off negatively effect my career in the long run when I come back to try and find employment?


Why do programmers use one-based indexing for line numbers in source code?

> **Possible Duplicate:**   >  Why isn't the line count in Visual Studio zero-based? Why isn't the top line in a source code file labelled line number 0? i.e. in a source file which was 10 lines long, I would expect line numbers would be 0-9, but they're not! Now `grep`, `awk`, `sed` etc all seem to number from 1, so I'm assuming it's an established convention for a good reason. It occurred to me recently that, for almost every other structure a programmer has to deal with in their day to day work, the convention is to count from 0 - and a source file is as much like a list of lines as a line is like a list of chars (afaik list of chars is invariably 0-indexed). I had to actually open up my text editor and sanity check that the top line of a file was labelled line number 1! I was just wondering if there _is_ a good reason for this or if it's just an unfortunate historical convention.


What simple game is good to learn OO principles?

I have to come up with a project propsal for my students, here are some details:   1. The design should be gove over OO concepts: encapsulation, interfaces, inheritance, abstract classes   2. Idealy a game, to keep interest high   3. No GUI, just the console   4. Effective time to finish this: ~ 6 days (1 person per proj) I have found one nice example of a game with carnivore and herbivore cells in a drop of water (array), it's a game of life twist. It is a bit too simple. Any ideeas? Aditional info: \- language is C# \- no AI and no complex rules


What's the difference between syntax and semantics?

I've always thought that referring to the syntax of a language was the same as referring to the semantics of a language. But I've been informed that apparently that's not the case. What's the difference?


Are the goals of Startup Weekend realistic?

I'm planning to attend Startup Weekend and I'm trying to see if what they're pitching is actually viable. On their front page, they say: > No talk. All action. Launch a startup in 54 hours. Is that realistic? Do these types of events provide the level of networking and information required to pull something like this off?


Should content be distributed with applications using Open Source license?

I have been developing a database-driven web application with extensive contents. The application is set to release using a GNU GPL v3 license. Whereas the content would be licensed using a Creative Commons license. To provide a brief context, this is an e-learning site, where I provide some kind of learning materials. Additionally, I am planning to provide a database dump along with the source code. The reason being, one would be able to setup and actually use the application given the contents. I have two questions in this regard:   1. Should I actually include the database dump along with the source code? If I don't, a user would require to create everything by his own, which is not desirable.   2. If the above answer is "yes", what license is applicable to the physical file containing the database contents? Please note that it is not possible to use any other type of licenses for the code and content, and both are to be licensed. P.S.: In case this question seems off-topic, could you please point to a more relevant site?


Why XML is meant to be Software and Hardware independent?

While studying the features of XML, I got to know that XML is software and hardware independent. Can anyone explain me why it is meant like that?


A good design pattern for a Web API where models/enities are searchable by foreign keys

I was hoping someone might have some ideas on how to create a RESTful web API where models/entities are searchable by a foreign key. I see a a lot of tutorials where the functionality consist of listing all records in the entire model or retrieving a single record from the model by a primary key, but not by an arbitrary/foreign key. It my be as simple as checking for extra conditions in the request but I thought I would get some advice all the same.


How do you deal with web designers who are too afraid to read and touch PHP code?

I've been hired to make a website and am working with a designer (who happens to be the guy who is in contact with the client and hired me, so no, I can't kick his ass out =) ) who's too afraid to touch into the php code, and is too newbie in html and css to give me good enough models, so the work of today will be going through his new html model of a half-programmed page and removing `<div>`s and changing classes and the such. Is there some kind of tool, or some better workflow in order to make this easier for both of us? Maybe I'm dealing with this the wrong way altogether, I'm new to web development, and I don't know enough HTML/CSS (and he supposedly does) to have him just give me a graphic mock-up and do the whole thing, so what we're doing is he gives me a static HTML page that looks like he wants, and I put `<?php ?>` around it =) Can anyone give me some advice on this?


In Scrum, who verifies "Done"?

I am a QA/Test manager in my organization and until today I verified the quality of the software (tests written and executed and bugs fixed). Who will verify this in Scrum? How do I know that the team wrote and executed all the right tests? On the other hand I'm afraid that if I continue to do the verification the team will not feel empowered enough. But I need some verification process that "Done" is indeed "Done". What do you suggest?


Is there an OSS license that works for this:

Say you started as SaaS service with freemium business model such 37Signals - Basecamp or Dropbox etc.. Is there an OSS license that says that you can use the source code etc.. but you cant release a SaaS based on it, esssentially released in good faith with non-compete expectations. e.g. if 37Signals released the source for highrise, basecamp etc.. someone could start 37signals4lesss.com (albeit once they built the same bit of provisioning logic) and damage the core business model.


Mimic the functionality of Urban Airship

My boss wants a feature that "mimics" the functionality of Urban Airship... in two weeks. What can I say to him?


Should we use a Maven Multi-Module Project in our Scenario?

**The Situation** I'm currently working in project that develops several RESTful services that partly interact with each other. As an example:   * Service A uses Service B   * Service C uses nothing   * Service D uses Service C   * most of the Services use a common Utillities project. There is NO actual code sharing between the services, they strictly rely on the defined RESTful API. Util contains helpers for test, helpers for the security lib, .... Currently every project is stand alone in their own git repository. During development there were some moments when this was slightly anoying:   * multiple places to do dependency management (services share dependencies to third-party libs)   * every project has to be (maven) released seperately (personaly i like that)   * when working "between" projects (working on a service and working on util because of that) lead to 2 review requests, because of 2 project (pull-requests) **The Question** One in the Team proposed as a solution to above problems to merge all git repositories and projects into one git repository and one maven multi module projects. Beside my own misgivings about the idea (no code sharing, only util as a common dependency, reliance on APIs between some (not all) services,...) i would like to know: **Are there known Advantages/Disadvantages of this Plan?** I don't like it makes a bad argument.


Separation of concerns and security

The system I am developing is designed to have multiple organizations, with users and roles for each organization. Some organizations can interact, some can not, and generally organizations are not allowed to see or modify each others data with some exceptions. I have a model class A that manipulates the data storage in a permanent storage container of some kind. I have a controller class B that validates input (including access rights verification) to objects of class A. The controller classes are in a separate library from the model classes. All user interaction is performed from view classes which are again in a separated library (in this case exposed as web services). However, it seems that there is a possible security risk in keeping access control logic separate from the model, since no security checks will be performed if the model is not accessed by its associated controller and is accessed instead by some other code due to some malicious attacker or programmer error. Should I place the security logic in the same model classes weaving these concerns together or should I keep the separation as I have now?


Multi cores/CPUs with locks

I'm not sure how the locks will work with multi processors/cores, I'm going to use shared memory in my application or FIFO, what worries me is the locks, I have a server with 2-CPU, how the lock will be able to lock a variable on one CPU while the another operation went to the 2nd CPU for the same variable? I'm in Linux environment using C, I've searched the web for some useful info, appreciate your help


Are there some good algorithms for implementing a Heap that minimizes fragmentation?

Right now I'm trying to create a Heap that requires 8-byte alignment, and was looking around online for some good methods that would minimize the amount of fragmentation. Less fragmentation is ideal, and even the ones that will slow down a lot are a consideration (but speed is also a sub-goal here) Has anyone had any experience with Heaps who could let me know what to watch out for when going about this? Any input is appreciated


Parallel Testing options in Agile Development?

I've read through some very good resources on the internet trying to find out if my initial proposed testing process is a valid option. So please any advice or recommendations are appreciated. Currently we have a `Dev` and `Test` environment which has served our needs fairly well so far. We are having QA and UAT test off the same `Test` environment, however our QA testers are complaining that having both teams test in the same environment is causing problems with verifying test scripts and I can see how this could be a problem. However, I don't want to have to wait for `QA` to be done testing before `UAT` even takes a look at it, this seems to be against the ideal's in agile development. I suggested the following new process/architecture to allow parallel QA and UAT testing: Have separate `QA` and `UAT` environments that allow different modules/versions to be tested in parallel. So we can have `QA` testing `ModuleA` while `UAT` is testing `ModuleB`. We basically need/want them to test different modules (or the same) in parallel without interfering with each other. I presented this to our Systems Engineers (so they can build the environment) and they said that `UAT` should never happen until `QA` is done. From my understanding of the agile process at this time, I would like to push my proposed process further, but maybe I'm overlooking something? Thanks!


Is it necessary to learn Makefiles when you have an IDE?

I have recently began studying Makefiles in Linux. I have ample experience developing applications with advanced IDEs, such as Visual Studio. My first impression and query after reading a few tutorials: is there any need to study Makefiles? Perhaps the IDEs are using it internally, but is this something everyone should learn eventually?


Is a day really 24 hours long?

I asked this question on Stack Overflow and it was closed as off-topic. I'll ask it here hoping it will do better. This might sound silly, but bear with me. I've been working a lot with intervals and dates lately. One question that bothers me: is a day really 24 hours long? I'm interested by the answer both from a theoretical and from a practical point of view. Let's take today for example, the day started on 13 Dec 2012 00:00:00 and according to (all) date-time implementations it will end on 14 Dec 2012 00:00:00. This is correct and the difference between the two dates is a complete 24 hours. The problem with this is that the end date is perceived as "tomorrow". Most people thinking that a day starts on 00:00:00 and ends on 23:59:59. So the question is: is today a closed interval at the start, and opened at the end, like [start..end), with the end being very very close to 14 Dec 2012 00:00:00 (so not really a complete 24 hours)? Or is it actually closed at both ends with a full 24 hours between them?


Contrary method subjects for identical method names

I've got method naming paralysis! Say I've got one class - "System", and another class "User". Now, if I want to notify user(s), I can call:               // this method can notify individuals and collections of users     System.notify(User,message)      but if I want to simply notify the specific user               // this notifies the user     User.notify(message)      My dilemma is that in the case of "System" - the subject of the **notify** method is the User(s) argument. In the case of the "User" implementation, the User itself is the subject. So, the classes have the same method, arguably performing very similar jobs - but the "direction" of the methods are contrary. Do you suffer from naming paralysis? How do you deal with it? What naming pattern would you use here?


With all of these services, how can I not be anemic?

Where do we draw the line between delegation and encapsulation of business logic? It seems to me that the more we delegate, the more anemic we become. However, delegation also promotes reuse and the DRY principal. So what is appropriate to delegate and what should remain in our domain models? Take the following concerns as examples: **Authorization**. Should the domain object be responsible for maintaining its access control rules (such as a CanEdit property) or should that be delegated to another component/service solely responsible for managing access, e.g. IAuthorizationService.CanEdit(object)? Or should it be a combination of the two? Perhaps the domain object has a CanEdit property which delegates to an internal IAuthorizationService to perform the actual work? **Validation**. The same discussion as above relates to validation. Who maintains the rules and who is responsible for evaluating them? On the one hand, the state of the object should belong to that object and validity is a state but we don't want to rewrite the code used to evaluate rules for every domain object. We _could_ use inheritance in this case... **Object Creation**. Factory class versus factory methods versus 'newing' up an instance. If we use a separate factory class, we are able to isolate and encapsulate creation logic but at the expense of opening our object's state to the factory. This can be managed if our domain layer is in a separate assembly by exposing an internal constructor used by the factory but this becomes a problem if there are multiple creation patterns. And, if all the factory is doing is calling the right constructor, what's the point of having the factory? Factory methods on the class eliminate the issue with opening up the object's internal state but since they are static, we aren't able to break dependencies through injection of a factory interface like we can with a separate factory class. **Persistence**. One could argue that if our domain object is going to expose CanEdit while delegating the responsibility to perform the authorization check to another party (IAuthorizationService) why not have a Save method on our domain object that does the same thing? This would allow us to evaluate the internal state of the object to determine if the operation can be performed without breaking encapsulation. Of course it requires that that we inject the repository instance into our domain object, which smells a bit to me, so do we raise a domain event instead and allow a handler to perform the persistance operation? See where I'm going with this? Rockford Lhotka has a great discussion about his reasons for going the Class- in-Charge route for his CSLA framework and I have a bit of history with that framework and can see his idea of business objects paralleling domain objects in many ways. But trying to become more adherent to good DDD ideals, I'm wondering when collaboration becomes too much. If I end up with an IAuthorizationService, IValidator, IFactory and IRepository for my aggregate root, what's left? Is having a Publish method that changes the state of the object from Draft to Published enough to consider the class a non-anemic domain object? Your thoughts?


Should I add an "Abstract" prefix to my abstract classes?

Suppose I have an abstract class named `Task`. Is there a standard or convention that would suggest I should name it `AbstractTask` instead?


what tools should I use for quality assurance and testing for front end javascript?

I am using jquery and HTML 5 techniques (like File API, HistoryAPI) extensively in a project I am working on. I was wondering what tools I can use for   1. quality assurance my javascript and front end code   2. unit testing my javascript and front end code Let me share some background info. If somebody asked me about this for PHP, I would say, use PHPUnit for writing unit tests, use PHP CodeSniffer and then with the help of Phing and Jenkins, put this all into a single build process. I basically want to know if something similar can be pulled off with javascript using Jenkins. Do share your actual experiences. Please advise me on the most beginner- friendly ones. Disclosure: I cross-posted in G+ community for javascript and HTML5.


Software licensing: free [as in gratis] and copyleft

I've been reading about software licensing as I feel that I'm at a stage now, where I should probably have some sort of a license associated with my code. What I am looking for is a copyleft (weak or strong) license that basically is very liberal. So I'd like the license to allow anybody to do anything with the code/program with the exception that nobody can ever make money from the code. I don't want anybody to be able to get my code and sell it, or to get my code and sell it or get my code, modify it in any way and sell it. I don't want anybody to be able to make money from any code I write. Aside from that, I don't care how it is used as long as the original author of the code (in this case, me) is associated with the code that I wrote. I've looked at the GPL license, the MIT license and a few others and I can't find what I want. Does anybody have any suggestions? If it matters, the license will be associated with C/C++, assembler and Ruby programs.


What are the security risks/vulnerabilities every C programmer must be aware of?

There are many security risks coming from having close contact to the hardware as opposed to using well-tested and proved APIs from high level programming languages. It is much easier to cause a buffer overflow in C than in a language such as Java. What are the risks or vulnerabilities (e.g. buffer overflows) that every C programmer should be aware of (I.E. vulnerabilities relevant to C programmers)? What problems could these lead to? How to avoid them, and what are common mistakes causing these to occur in programs?


Decision trees vs. Neural Networks

I'm implementing a machine learning structure to try and predict fraud on financial systems like banks, etc... This means that there is a lot of different data that can be used to train the model eg. card number, card holder name, amount, country, etc... I'm having trouble deciding which structure is the best for this problem. I have some experience with decision trees but currently I have started to question if a neural network would be better for this kind of problem. Also if any other method would be best please feel free to enlighten me. Which are the pros and cons of each structure and which structure would be the best for this problem? Also I'm not sure about this fact but I think decision trees have a great advantage over neural networks in terms of execution speed. This is important because speed is also a key factor in this project.


How can I get git to clone untracked files

I'm new to git. I'm using a development platform called automation studio. This development tool creates all sorts of files and directories which it needs to maintain runtime and IO information for the target processor. These informations are specific for each project. Therefore these file should not be under version control because they are provided and maintainded by the platform. Otherwise one cannot run the automation studio without these files. I put the names of these files and directories in an .gitignore file. Then I cloned myrepository to a bare repository on a server. Then I cloned back to mynewrepository on my local machine. Unfortunatedly in mynewrepository all files and directories listed in .gitignore were missing. Therefore the automation studio platform failed to work. How can I exclude these files and the content of these directories from versioning but keep the them all in the repository in order to clone back a fully working project for automation studio?


DDD, Saga & Event-sourcing: Can a Compensate Action simply be a delete on the event store?

I realize the above question probably raises a few 'what??'s, but let me try to explain : I'm trying to wrap my head on a couple of related concepts, basically the Saga-pattern ( http://www.rgoarchitects.com/Files/SOAPatterns/Saga.pdf) in combination with Event-sourcing (A DDD-concept: http://en.wikipedia.org/wiki/Domain-driven_design) A good post that wraps it together: http://blog.jonathanoliver.com/2010/09/cqrs-sagas-with-event-sourcing-part-ii- of-ii/ I'm getting to the question in a minute, but I think I have to try to summarize what I understand of it first (which might well be wrong, so please correct if that's the case) since this might well impact why I'm asking the question to begin with:   1. The Saga pattern is a sort of broker that given an action (end-user, automated, etc. essentially anything that is going to change data) divides that action up in business activities and sends each of these activities as messages to a Message Bus which in turn sends it to the respective aggregate roots to be taken care of.    2. These aggregate roots can operate completely autonomously (nice separation of concerns, great scalability, etc. )    3. A Saga-instance itself doesn't contain any business logic, that is contained in the aggregate roots it sends activities to. The only 'logic' contained in the Saga is 'process'-logic, (often implemented as a Statemachine), which determines based on actions received (as well as follow-up events) what to do (i.e: what activities to send)    4. The Saga-patterns implements a kind of distributed transaction pattern. I.e: when one of the aggregate roots (which again work autonomously, without knowing of eachothers existense) fails, the entire action might have to be rolled back.    5. This is implemented by having all aggregate roots, upon completion of their activity report back to the Saga. (In case of success as well as error)    6. In case all aggregate roots return a success, the internal statemachine if the Saga determines what to do next (or decides it's done)    7. In case of failure, the Saga issues to all aggregate roots that took part in the last action a so called Compensation Action, i.e: an action to undo the last action each of the aggregate roots did.    8. This might be simply doing a 'Minus 1 vote' if the action was "plus 1 vote' but it could be more complicated like restoring a blogpost to it's previous version.   9. Event-sourcing (see the blogpost combining the two) aims to externalize saving the results of each of the activities that each of the aggregate roots undertake to a centralized Event Store (the changes are called 'events' in this context)    10. This Event store is the 'single version of the truth' and can be use to replay the state of all entities simply by iterating the events stored (essentially like an event log)   11. Combining the two (i.e: letting aggregate roots use Event-sourcing to outsource saving their changes before reporting back to the Saga) enables lots of nice possibilities, one of which concerns my question... I felt I needed to get this off of my shoulder, since it's a lot to grasp in one go. Given this context/mindset (again, please correct if wrong) **the question:** When an aggregate root receives a Compensate Action and if that aggregate root has outsourced it's state-changes using Event-sourcing, wouldn't the Compensate Action in all situations just be a delete of the last event in the Event Store for that given Aggregate Root? (Assuming the persist- implementation allows deletes) That would make sense to me a lot (and would be another great benefit of this combination) but as I said I might be making these assumptions based on a incorrect/incomplete understanding of these concepts. I hope this didn't get too long-winded. Thanks.


How to handle User Story at end of sprint if users want changes?

We just adopted Scrum and completed our first sprint (yeah!) At the Sprint Review, we demoed a User Story for feature X. This feature X worked exactly how described in the User Story from initial business analysis and details we worked out during product backlog grooming and sprint planning. However, after the user saw feature X in action they wanted some tweaks (not shocking, purpose of the demo and feedback loop). My question is: **(a)** Do we consider the original user story done and create a new user story to handle the new requirements in a future sprint? **(b)** Do we consider the original user story unfinished, roll into backlog with more detailed requirements that will turn into more tasks in the next sprint? If **(b)** , in sprint planning do we re-estimate the story point weight of the story now knowing that 90% of the work is complete? So if it was originally 5 pts it might now be 2 pts?


Log defects for failures of other systems?

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. I can see both sides; on one hand the software won't work until the service is fixed, and so we need to track that somehow. On the other, there's nothing we are going to do that will resolve the defect and having a critical defect in our system sitting there seems to be a waste (and may concern others looking at the tracking system wondering why we have defects we're not acting on). My question is, should these be tracked as defects in our tracking system, or should our QA people not be logging defects if they know this is the reason (typically they do as they'll ask me if unsure)? Edit: A few people are making assumptions. The web service were calling is developed by another shop, and we are both being paid by the same client to integrate our systems. Our UI handles the error correctly it doesn't show a ysod. It tells the user they cannot change their account at this time. The defect being reported by our qa team is of course that the user ought to be able to change their account, but they don't know if the issue is something we need to fix or the other company. According to our requirements, we cannot save the users changes if the service call fails. Its been decided that these failures should be uncommon enough that this design is ok. Were also working with the other company to iron out some details that have come up during our testing.


What's the max age you can still be employed as a programmer?

I know some a few programmers at my work around 40 years old. I don't remember seeing a programmer at work who is 50+. We have 600 people, of which probably 100 are programmers. Is it uncommon to still be working as a programmer at 50+? One can argue, you would be better off managing people, but not everyone is good at that, and some people just want to do the actual work because of passion, etc. Would it be weird if you are still trying to work at 50, or even 60? I imagine it could create all sorts of social issues, i.e. working in games where most people are very young, straight out of college, etc. I feel it would make it hard to form friendships, due to age difference. Or how would your expertise be considered compared to others, etc. Anyone has experience or opinions about these?


MVC View Question

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 and some other HTML elements pre-added in, that index.php can echo. Essentially the page class is a template of sorts. I'm trying to have some kind of MVC hierarchy here (I'm a student learning about programming 'best practices' in my own time), my question is: would 'index.php' be a view? Or, would the instance of the page class be the view (as it constructs the page, but it doesn't actually show it, it returns a string), or: would the 'page' class be a controller? Also, is a view 'allowed' to talk to (eg: get data from) a controller (for example: by calling a method that controller owns)? Many thanks for your help!


What is the preferred strategy for editing data from a database?

We are redesigning an old VB6 application in Net. The application makes extensive use of a database and includes management of club members and their results in the competitions that they partake in. So, if we are editing a club member's name, address, etc. it is obvious not to send the data back to the database until the entire edit or add operation has been completed by the user. But how to do this when registering and editing scores of matches? The advantage of sending each added or edited score directly to the database is that it enables live updates of the rankings. The disadvantage is that undoing changes may be more difficult and that there may arise performance problems when the connection to the database has a high latency. The latter problem might come up at some stage, but for the unforseeable future we will work with desktop versions of the database. I would be interested in descriptions of best practices and live experiences. Thanks!


How Find operation works in a Binary Tree?

I am having a confusion in this Binary Tree Coding. I know the concept of binary tree and I know how those work and all, but in this source code i am confused with "Find" operation. I cannot understand how it works and all. Please help me, I am so interested in this area.               package binarytree_task4;                 class Node          {              private static class Equivalent {                  public Equivalent() {             }         }                  public Equivalent data;              public Node right;              public Node left;                   public Node(Equivalent data)              {                      this(data, null, null);             }                  public Node(Equivalent data, Node left, Node right)              {                      this.data = data;                 this.left = left;                 this.right = right;             }            }                class binarytree {                   public static void main(String[] args) {              }              private static class Equivalent {                  public Equivalent() {             }         }              private static class present {                  public present() {             }         }         private Node root;          private int size;              public binarytree()          {             size = 0;             root = null;         }                   public void printTree()          {             if(size == 0)                 System.out.println("Empty");             else {                 System.out.println("Tree contents:");                    inorder(root);             }         }                   public void inorder(Node present)         {             if(present != null)              {                 inorder(present.left);                 System.out.println(present.data);                 inorder(present.right);             }         }                public void Insert(Equivalent data)          {             root = Insert(data, root);         }                   private Node Insert(Equivalent data, Node present)          {             if( present == null)              {                 size++;                  present = new Node(data, null, null);              }                  else if(data.compareTo(present.data)<0)             {                 present.left = Insert(data,present.left);                     }                  else if(data.compareTo(present.data)>0)                     {                       present.right = Insert(data, present.right);             }                  return present;         }                          public boolean Find(Equivalent data)          {             return Find(data, root);             }                   private boolean Find(Equivalent data, Node present)          {                  if(present == null )              {                 return false;             }             else if(present.data == data)             {                 return true;                 }             else if(data.compareTo(present.data)<0)               {                 return Find(data, present.left);              }             else              {                 return Find(data, present.right);              }         }                        public boolean Delete(Equivalent key){                  if (Find(key)){                 Delete(key);                 return true;             }             else{                 return false;             }         }              public void delete(Equivalent key)          {              Node present = root;             Node parent = root;                  boolean isLeftChild = true;                       while(present.data.compareTo(key) != 0)                     {                      parent = present;                 if(present.data.compareTo(key) > 0)                       {                     isLeftChild = true;                      present = present.left;                  }                 else                                             {                     isLeftChild = false;                      present = present.right;                  }                 if(present == null)                                 return ;                         }                     if(present.left == null && present.right == null)              {                 if(present == root)                      root = null;                                 else if(isLeftChild)                           parent.left = null;                     else                                                  parent.right = null;             }                  else if(present.right == null)                    if(present == root)                           root = present.left;                  else if(isLeftChild)                      parent.left = present.left;                   else                      parent.right = present.left;                    else if(present.left == null)                     if(present == root)                                   root = present.right;                     else if(isLeftChild)                      parent.left = present.right;                  else                       parent.right = present.right;                     else              {                      Node successor = getSuccessor(present);                       if(present == root)                       root = successor;                 else if(isLeftChild)                          parent.left= successor;                  else                     parent.right = successor;                      successor.left = present.left;               }            }                  private Node getSuccessor(Node delNode)        {             Node successorParent = delNode;               Node successor = delNode;                 Node present = delNode.right;                   while(present != null)              {                            successorParent = successor;                  successor = present;                              present = present.left;                       }             if(successor != delNode.right)              {                       successorParent.left = successor.right;                   successor.right = delNode.right;                      }             return successor;         }               }


Is continuous creation and deletion of tables a sign of an architectural flaw?

Recently I had a discussion with a developer who mentioned that during program development, they routinely create and delete tables and columns on a regular basis while working on new features and justified things by saying that this is normal when using an agile development process. As most of my background is in a waterfall development environment, I wonder if this is actually considered proper under agile development, or if this might be a sign of an underlying problem, either with the program architecture or with their following of the agile process.


The Box Model: Internet Explorer vs. W3C

Today, the Internet Explorer Box Model problem is mostly a non-issue. Most web developers place a `<!DOCTYPE>` tag to enforce standards compliance, and nobody really cares about supporting Internet Explorer 5.5 anymore. However, some developers have come up with subjective, conceptual arguments in defense of the IE box model. They've claimed that the IE box model is more "intuitive" than the W3C model, because the W3C model measures the _content_ of the box, whereas the IE model measures the box itself: ![enter image description here](http://i.stack.imgur.com/y0Tkz.png) I can see their point of view, but it's basically a subjective argument, and the most important thing is _standards_ compliance. However, recently I've come to prefer the IE box model for serious **practical** reasons. The W3C box model makes it difficult to dynamically resize an element to the exact onscreen pixel width of another element. The reason is that the `style.width` property of an element doesn't account for the total onscreen size of the element: you also need to take into account any additional border and padding. This isn't a problem if both elements use the same CSS class - but if they have _different_ CSS classes, this can become incredibly challenging. Suppose we have two divs: A and B. A is hard-coded in the html as a 400px div, whereas B is dynamically created using Javascript. Visually, we want B to be the exact width of A. Under the old IE Box model, this is trivial. We simply say: `B.style.width = A.style.width`, or even `B.style.width = A.offsetWidth + "px"`. But with the W3C box model, this isn't so simple. Now we also have to worry about style sheets. If B has the same CSS class as A, we can just say `B.style.width = A.style.width`. But if it doesn't - and we might not _want_ it to for aesthetic reasons - we're in trouble. Now we have to take into account the total pixels in the border and padding of both A and B. This can be particularly difficult if the border and padding are specified in inconsistent units (a common occurrence since border is often a 1px line, whereas padding might be specified in ems). Then we're faced with the quasi- impossible task of converting to a common unit (em to px or px to em). All of this just to get two divs to line up exactly on screen. So basically, the W3C box model forces us to take into account CSS border and padding issues when we set the size of an element, whereas the IE box model doesn't, since the width measures the _entire size_ of the box (end-to-end), rather than the _content_ of the box. This makes it a lot easier to dynamically size elements in relation to each other. All of this seems like a pretty powerful reason to favor the IE box-model over the W3C model (at least conceptually - of course in practice the IE box-model is dead). **Question** : Why did the W3C choose this box model? Are there some _advantages_ of the W3C box model that I'm simply not seeing? Or am I simply exaggerating the problem here?


Best way to parse a file

I'm trying to find a better solution for making a parser to some of the famous file formats out there such as: EDIFACT and TRADACOMS. If you aren't familiar with these standards then check out this example from Wikipedia: > See below for an example of an EDIFACT message used to answer to a product > availability request:-               UNA:+.? '     UNB+IATB:1+6XPPC+LHPPC+940101:0950+1'     UNH+1+PAORES:93:1:IA'     MSG+1:45'     IFT+3+XYZCOMPANY AVAILABILITY'     ERC+A7V:1:AMD'     IFT+3+NO MORE FLIGHTS'     ODI'     TVL+240493:1000::1220+FRA+JFK+DL+400+C'     PDI++C:3+Y::3+F::1'     APD+714C:0:::6++++++6X'     TVL+240493:1740::2030+JFK+MIA+DL+081+C'     PDI++C:4'     APD+EM2:0:130::6+++++++DA'     UNT+13+1'     UNZ+1+1'      The UNA segment is optional. If present, it specifies the special characters that are to be used to interpret the remainder of the message. There are six characters following UNA in this order:   * component data element separator (: in this sample)   * data element separator (+ in this sample)   * decimal notification (. in this sample)   * release character (? in this sample)   * reserved, must be a space   * segment terminator (' in this sample) * * * As you can see it's just some data formatted in a special way waiting to be parsed (much like **XML** files). Now my system is built on PHP and I was able to create parser using regular expressions for each segment, but the problem is not everybody implements the standard perfectly. Some suppliers tend to ignore optional segments and fields entirely. Others may choose to send more data than others. That's why I was forced to create validators for segments and fields to test if the file was correct or not. You can imagine the nightmare of regular expressions I'm having right now. In addition each supplier needs many modifications to the regular expressions that I tend to build a parser for each supplier. * * * **Questions:** 1- Is this the best practice for parsing files (using regular expressions)? 2- Is there a better solution for parsing files (maybe there are ready made solution out there)? Will it be able to show what segment is missing or if the file is corrupted? 3- If I have to build my parser anyway what design pattern or methodology should I use? **Notes:** I read somewhere about yacc and ANTLR, but I don't know if they match my needs or not!


Developing pages in MVC website that will be specifically used as an iframe by another website

I have a website where I'm going to be partnering with another website. They want to view one specific page of mine, in their [WordPress] website. They aren't developers, so I looked into how to do this. At first glance, it appears as though the WordPress iFrame plugin is the easiest route. My next thought is, they'll probably still want to show their own header and footer in their page, while showing the content of my page in the iFrame. No big deal. I'm thinking of developing a View on my [MVC 4] website that will be used ONLY for their iFrame purposes. Since they'll probably want their own headers, I'll probably design a page that uses no layout, and just a custom header and/or footer that shows that the information is coming from MY website. Here are my questions: 1) The page that will be displayed contains MANY anchor tags, if that's embedded in an iFrame, what happens if the user on THEIR website clicks the link in the iFrame? Does the iFrame page change, or does their ENTIRE page change? 2) Depending on the answer to #1, should I just disable all hyperlinks/anchor tags in the iFrame page on my site so it doesn't cause any funkyness on their site? 3) What if I WANT some hyperlinks on the iFrame page so they come visit my website? Is that a matter of telling them to put a real link on their site to my own? 4) What security concerns do I have with allowing a page of my own to be accessible via iFrame from another site? Should I only allow traffic to my iFrame page when it's from their site? If it's not from their site, then re- direct to my "real" page? Thanks all!


Modelling work-flow plus interaction with a database - quick and accessible options

I'm wanting to model a (proposed) manufacturing line, with specific emphasis on interaction with a traceability database. That is, various process engineers have already mapped the manufacturing process - I'm only interested in the various stations along the line that have to talk to the DB. The intended audience is a mixture of project managers, engineers and IT people - the purpose is to identify:   * points at which the line interacts with the DB (perhaps going so far as indicating the Store Procs called at each point, perhaps even which parameters are passed.)   * the communication source (PC/Handheld device/PLC)   * the communication medium (wireless/fibre/copper)   * control flow (if leak test fails, unit is diverted to repair station) Basically, the model will be used as a focus different groups on outstanding tasks; for example, I'm interested in the DB and any front-end app needed, process engineers need to be thinking about the workflow and liaising with the PLC suppliers, the other IT guys need to make sure we have the hardware and comms in place. Obviously I could just improvise in Visio, but I was wondering if there was a particular modelling technique that might particularly suit my needs or my audience. I'm thinking of a visual model with supporting documentation (as little as possible, as much as is necessary). Clearly, I don't want something that will take me ages to (effectively) learn, nor one that will alienate non-technical members of the project team. So far I've had brief looks at BPMN, EPC Diagrams, standard Flow Diagrams... and I've forgotten most of what I used to know about UML... And I'm not against picking and mixing... as long as it is quick, clear and effective. Conclusion:   In the end, I opted for a quasi-workflow/dataflow diagram. I mapped out the parts of the manufacturing process that interact with the traceability DB, and indicated in a significantly-simplified form, the data flows and DB activity. Alongside which, I have a supporting document which outlines each process, the data being transacted for each process (a 'data dictionary' of sorts) and details of hardware and connectivity required. I can't decide whether is a product of genius or a crime against established software development practices, but I _do_ think that is will hit the mark for this particular audience.


Is there a canonical book on F#?

I'm planning to learn F#. I'm not a very beginner since I know Standard ML, C# and Erlang. Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information on F# (preferably with examples using WPF since I would like to use it for GUI- programming) ? What about that book makes it special?


When to use nested resources in a RESTful API

I have two resources: users and links. Users can have several links associated with them. I have designed my RESTful API so that you can reach the links associated with a user at the following URI: `/users/:id/links` However, I always need to have a URI for just links – sometimes I might want all links, regardless of user. For this I have: `/links` Does this sound okay? Having two URIs for links? I wonder if I should instead reach the links for a user with a URI such as: `/links/user/:id` or `/links/?user=:id` This way, I only have one resource for links.


How much is modern programming still tied to underyling digital logic?

First of all: I've got no academic background. I'm working primarily with Java and Spring and I'm also fond of web programming and relational databases. I hope I'm using the right terms and I hope that this vague question makes some sense. Today the following question came to my mind: How much is modern programming still tied to the underlying digital logic? With modern programming I mean concepts like OOP, AOP, Java 7, AJAX, … I hope you get the idea. Do they no longer need the digital logic with which computers are working internally? Or is binary logic still ubiquitous when programming this way? If I'd change the inner workings of a computer overnight, would it matter, because my programming techniques are already that abstract? * * * P. S.: With digital logic I mean the physical representation of everything "inside" the computer as zeroes and ones. * * * Changed "binary" to "digital".


Is it more secure to hash a password multiple times?

I've read a few times that when storing passwords, it's good practice to 'double hash' the strings (eg. with md5 then sha1, both with salts, obviously). I guess the first question is, "is this actually correct?" If not, then please, dismiss the rest of this question :) The reason I ask is that on the face of it, I would say that this makes sense. However, when I think about it, every time a hash is rehashed (possibly with something added to it) all I can see is that there is a reduction in the upper bound on the final 'uniqueness'... that bound being related to the initial input. Let me put it another way: we have x number of strings that, when hashed, are reduced to y possible strings. That is to say, there are collisions in the first set. Now coming from the second set to the third, is it not possible for the same thing to occur (ie. collisions in the set of all possible 'y' strings that result in the same hash in the third set)? In my head, all I see is a 'funnel' for each hash function call, 'funneling' an infinite set of possibilities into a finite set and so on, but obviously each call is working on the finite set before it, giving us a set no larger than the input. Maybe an example will explain my ramblings? Take 'hash_function_a' that will give 'a' and 'b' the hash '1', and will give 'c' and 'd' the hash '2'. Using this function to store passwords, even if the password is 'a', I could use the password 'b'. Take 'hash_function_b' that will give '1' and '2' the hash '3'. If I were to use _it_ as a 'secondary hash' after 'hash_function_a' then even if the password is 'a' I could use 'b', 'c' or 'd'. On top of all of that, I get that salts should be used, but they don't really change the fact that each time we are mapping 'x' inputs to 'less than x' outputs. I don't think. Can someone please explain to me what it is that I am missing here? Thanks! EDIT: for what it's worth, I don't do this myself, I use bcrypt. And I'm not really concerned about whether or not it's useful for 'using up cycles' for a 'hacker'. I genuinely am just wondering whether or not the process reduces 'security' from a hash collision stand point.


What is special about JDBC that makes it unlikeable for JavaScript

Quoting from Selenium Architecture > A natural implementation would have been to provide a database connection to > the underlying data store, using something like JDBC. Eventually, we settled > on an API that closely models the underlying Javascript implementation > because something that modeled typical database access APIs wasn't > sympathetic to a Javascript implementation I have used both Java+JDBC and JavaScript. And I know that JDBC uses a (connection, query, disconnect) model, but could not understand what is special about JDBC that makes it unlikeable for JavaScript?


Javascript Implementation Patterns for Server-side MVC Websites

I'm looking for information on common patterns for initializing and executing Javascript page by page in a "traditional" server-side MVC website architecture. A few months ago, my development team began, but abandoned, a major re- architecture of our company's primary web app, including a full front-end redesign. In the process, there was some debate about the architecture of the Javascript in the current version of the site, and whether it fit into a clear, modern design pattern. Now I've returned to the process of overhauling the front end of this and several other MVC websites (Ruby on Rails and MVC.net) to implement a responsive framework (Bootstrap), and in the process will again need to review then revamp and update a lot of Javascript. These web applications are NOT single-page Javascript applications (in fact, we are ripping out a lot of Ajax) or designed to require a Javascript MVC pattern; these apps are basically brochure, catalog and administrative sites that follow a server-side MVC pattern. The vast majority of the Javascript required is behavioral, pre-built plugins (JQuery and Bootstrap, et al) that execute on specific DOM nodes. _I'm going to give a very brief (as brief as I can be) run-down of the current architecture only in order to illustrate the scope and type of paradigm I'm talking about. Hopefully, it will help you understand the nature of the patterns I'm looking for, but I'm not looking for commentary on the specifics of this code._ What I've done in the past is relatively straight-forward and easy to maintain, but, as mentioned above, some of the other developers don't like the current architecture. Currently, on document ready, I execute whatever global Javascript needs to occur on every page, and then call a page-specific init function to initialize node-specific functionality, retrieving the init method from a JS object. On each page load, something like this will happen:               $(document).ready(function(){       $('header').menuAction();       App.pages.executePage('home','show'); //dynamic from framework request object     });      And the main App javascript is like               App = {       usefulGlobalVar: 0,       pages:       {         executePage: function(action, controller)         {             // if exists, App.pages[action][controller].init()         },         home:         {           show:           {              init: function()              {                 $('#tabs').tabs(); //et. al              },              normalizeName: function()              {                 // dom-specific utility function that                 // doesn't require a full-blown component/class/module              }           },           edit:               ...         },         user_profile:           ...       }     }      Any common features and functionality requiring modularization or compotentizing is done as needed with prototyping. For common implementation of plugins, I often extend JQuery, so I can easily initialize a plugin with the same options throughout the site. For example,               $('[data-tabs]').myTabs()      with this code in a utility javascript file:                (function($) {           $.fn.myTabs = function() {             this.tabs( {               //...common options             });           };         })      Pointers to articles, books or other discussions would be most welcome. Again, I am looking for a site-wide implementation pattern, NOT a JS MVC framework or general how-tos on creating JS classes or components. Thanks for your help!


How to convey lifetime requirements?

Usually I use std::unique_ptr to convey ownership and pass in raw pointers as parameters when no ownership is implied. However, I almost never consider a nullptr to be acceptable as an argument, so it would be nice to use references to avoid this, but I'm not sure most people would expect that the object the parameter references needs to exist for the lifetime of the struct A without looking at the source code.               struct A {         A(B& b)         :  bPtr(&b) {;}              void method() {             // use bPtr         }              B* bPtr;     };      The questions are: 1) Is the only option here to stick with pointers and always check for nullptr? 3) Does the fact that A needs bPtr to be valid mean it should take a shared_ptr? If so I feel like I would use shared pointers practically everywhere. 2) Are there conventions that can help convey lifetime requirements for parameters to users besides comments and documentation?


How to annotate method signature changes?

I'm developing a mini framework and I want to perform changes to existing methods. I know in order to deprecate a method I can use the `@deprecated` annotation. However, what annotation should I use to let the users know that I'm going to change the amount of parameters a method will receive or maybe the returned result? I'd like to know what annotations to use in PHP.


Should I continue my self-taught coding practice or learn how to do coding professionally?

Lately I've been getting professional work, hanging out with other programmers, and making friends in the industry. The only thing is I'm 100% self-taught. It's caused my style to extremely deviate from the style of those that are properly trained. It's the techniques and organization of my code that's different. It's a mixture of several things I do. I tend to blend several programming paradigms together. Like Functional and OO. I lean to the Functional side more than OO, but I see the use of OO when something would make more sense as an abstract entity. Like a game object. Next I also go the simple route when doing something. When in contrast, it seems like sometimes the code I see from professional programmers is complicated for the sake of it! I use lots of closures. And lastly, I'm not the best commenter. I find it easier just to read through my code than reading the comment. And most cases I just end up reading the code even if there are comments. Plus I've been told that, because of how simply I write my code, it's very easy to read it. I hear professionally trained programmers go on and on about things like unit tests. Something I've never used before so I haven't even the faintest idea of what they are or how they work. Lots and lots of underscores "_", which aren't really my taste. Most of the techniques I use are straight from me, or a few books I've read. Don't know anything about MVC, I've heard a lot about it though with things like backbone.js. I think it's a way to organize an application. It just confuses me though because by now I've made my own organizational structures. It's a bit of a pain. I can't use template applications at all when learning something new like with Ubuntu's Quickly. I have trouble understanding code that I can tell is from someone trained. Complete OO programming really leaves a bad taste in my mouth, yet that seems to be what EVERYONE else is strictly using. It's left me not that confident in the look of my code, or wondering whether I'll cause sparks when joining a company or maybe contributing to open source projects. In fact I'm rather scared of the fact that people will eventually be checking out my code. **Is this just something normal any programmer goes through or should I really look to change up my techniques?**


how should I handle server error during ajax logout?

I need to write a handler for server error during user logout. What is a common practice?               ajax.post({         url: '/auth/logout'     }).done(function (response) {         switch (response.statusCode) {             case 200:             {                 //update UI related to userinformation             }             case 500:             {                 //what should I do here?             }         }     })      Note: The ajax function is reimplementation of $.ajax() with the exception that it always calls done callback (custom promise object is always resolved and never rejected) **UPDATE:** On server I destroy session and delete auto login cookie if it's present. Is it a sensible approach (if server error is received) to delete cookies related to session name and auto login on client using javascript (presuming that I know their names)?


Inventory Management project Unit of measurement conversion issue

We are currently working on an inventory module. We have purchase requisition, purchase order, goods receipt modules etc. There is obviously the need for UOM or Unit of measurement conversion needed. User places purchase request in terms of **Sales UOM** , the metric in which they want to sell. The system places order in terms of **Purchase UOM** , in the metric they put an order to the supplier. However we are in a dilemma UOM conversion, we want to avoid fractions during conversion. > Eg. If one Purchase UOM = 7 Sales UOM, conversion will be 1/7 , this will > obviously create fraction quantities for both cases How can I convert the UOM's properly without suggesting the user to over purchase some goods (Rounding to nearest integer will do as long as there is no wastage)?


How can I be an agent of change amongst old coders?

I have been developing software for over 12 years now. I keep high standards when designing code from database normalization, to OOP, to learning and implementing the model view model pattern. Through my career, I have found that proper design always wins and allows an application to be extensible and thus flexible--it's an easy equation. Likewise, I have been very productive prior to starting my current job about three years ago. For example, my first year out of college I re-engineered a call logging application, created a product ordering application that used SOAP, including the application's install, and worked on many new features within that company's major application. I had no roadblocks per se. However, I have worked at my current position for three years and I do not have a finished application to show for it. The reasons for the slow development process are:   1. we are under-staffed    2. our database is poorly designed and was patched together due to time constraints and    3. there is no project management process in place.  When I interviewed for this position, I was told that they value proper design and that they want to implement a project management process yet I have found they really don't desire either scenario. I have tried to be an instrument of change and recommend a path and my manager agrees but doesn't approve the change. What do I do? Is the only change that I can do is to change jobs? How do I become an agent of change? I have spoken to an upper level manager and I get the same response: I understand and see the problem but it settles there. Now what?


Does limiting commitment in Scrum lead to complacency?

In my organization Scrum teams almost never finish all of their stories 100%. I suggested that we commit to fewer stories each Sprint, but the R&D manager says if we do that people will still not complete the work, but will just do less of it thus slowing down development. He says there is a Student Syndrome at work here. What is your take on that?


What should the main content area be called?

I'm working on a CMS that will be used by others and I'm trying to figure out what the main body of the site page should be called. Originally, I was going to call it "content" - but perhaps "body" or "page" would be better.               <html>     <body>         ....         print $content;         ....     </body>     </html>      This isn't just a question about markup class/id names. It's also about what the name means to people when they first hear it. I want people to know that ____ is the main area of the page.


Why should we use externalized property files for an application?

I am currently working on a rails project and have a requirement where I want to be able to map a country name's initial letters to its ISD code. eg: IND => 91, USA => 1, etc. The broader question here being (notwithstanding which framework you work on), what should be the best practice to store these things. Should you be using a property file (yaml, in this case)? OR Should you just make a table in the database and read it from there? OR Should you just have a hash_map like structure in your ruby (or any other language) code?


Older PHP v/s newer PHP version

My company is building a website with database. Programmer's used PHP 5.0. My Service Provider (shared) in the meantime upgraded to PHP 5.3.0. Fixes have been on going and seem endless... Do I move to VPS and install older PHP or should we rebuild with newer PHP? When working remotely with programers what is the protocol regarding delivery of all code? Please what is the industry standard? I need an independent to review their work. How should this be approached?


Best development model for novice game developers

A small group of friends (including myself) decided to develop a simple 2D game. We are all fairly new to software development, so I wanted to ask which software development model would likely work best for such a group. From the list on Wikipedia, the Waterfall and Spiral models seem to be the two best options. Our plan is to use C# with XNA for development.


How do sockets work over wireless connections?

I've only worked on client side(specifically, mobile) applications using Android, where all networking is handled at the HTTP layer using framework provided components like HttpUrlConnection. But push messaging systems like Websockets/XMPP etc, all maintain a persistent connection to the server. Even Google's GCM, which is baked into Google Play supported devices, maintain a persistent connection to the servers. My question is, how does this work without draining battery? If we make continuous HTTP requests sequentially, the battery drain is significant. How are these persistent connections maintained without encountering the same problem?


Is there a canonical book on C++/CLI ?

I know quite a lot about C++ but I know very little about .NET. I would like to broaden my horizons. Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information on C++/CLI (preferably with information about .NET in general as well)? What about that book makes it special?


Where does "isolating complexities" lie in the realm of design principles?

I was just curious, it's something I think most people are aware of as a technique: You have some abominable data that simply must be parsed and you can do nothing to simplify the algorithm for doing it, so the best you can do is isolate the complexity of that algorithm to one place rather than having parts of the algorithm strewn all over. Then after isolating it, cementing the boundaries of it with some interface or contract to ensure the complexity in it does not leak out. Where does this drive to isolate complexities live in the library of design principles? I don't think it is word for word one of the formally documented design principles, though I'm guessing there are one or two that overlap with this very closely.


What's wrong with Erlang?

(if anything!) I picked up Erlang last night again because I ran into a problem in Project Euler that I thought would be a perfect fit. After about a short time of coding, I had a solution that was extremely simple and elegant (for something I created) -- the main function being only a few lines. My question is what is keeping people from adopting Erlang more?   * For current developers, what do you feel is missing to increase adoption (libraries, language features, IDE/toolsets)?   * For people who tried but were turned off by the language -- what aspects were difficult to understand or missing, or did you find a functional language that was better suited for your tasks?


What list of database features/elements are necessary for a programmer to understand?

What database features/elements are necessary for a programmer to understand in order to create non-trivial applications? I was once asked in a job interview (by a DBA) to rate my understanding of database concepts -- I thought it would be interesting to get opinions. I'm looking for basic and advanced skills, also any opinions on where developers are typically the weakest (what lack of skills or knowledge creates the most problems). Also, is it better that developers are need-to-know, and pass more advanced work onto a DBA -- where does that "line in the sand" exist?


How can I check myself when I'm the only one working on a project?

I'm in between jobs in my field (unrelated to software development), and I recently picked up a temporary side contract writing a few applications for a firm. I'm the only person working on these specific applications. Are there ways I should be checking myself to make sure my applications are sound? I test my code, try to think of edge cases, generate sample data, use source control, etc. but since I'm the _only_ person working on these applications, I'm worried I'll miss bugs that would easily be found in a team environment. Once I finish the application, either when I'm happy with it or when my deadline expires, the firm plans to use it in production. Any advice? Not to use a cliche, but as of now, I simply work "to the best of my ability" and hope that it's enough. Incidentally, I'm under both strict NDA's and laws about classified material, so I don't discuss the applications with friends who have actually worked in software development. (In case it's not obvious, I am not a software developer by trade, and even my experience with other aspects of information technology/computer science are limited and restrained to dabbling for the most part).


Google Maps - Geofence a route

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 the waypoint list, re-calculate the route and re- generate the driving directions. I know there's various different API's for Google Maps, but I'm basically looking for some advice on which API's I should be looking through. I believe the phrase I'm looking for is 'Geofencing', and for that I've seen the Google Tracks API has methods incorporating that (https://developers.google.com/maps/documentation/tracks/geofences) - But I can't seem to work out how that would help me, or how I'd be able to use it. Is it possible to do the lookup in an alternative method? For example, producing driving directions using 1 API call, storing all of the waypoints of this route in a MySQL DB and then using something along the lines of http://stackoverflow.com/questions/1078386/see-if-lat-long-falls-within-a- polygon-using-mysql? to see if each point is within the polygon/geofenced route?


Can an EULA restrict what you can use an application for?

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 wondering this because many applications have clauses like "you can't use XY to make something illegal". And actually wondering if this has any use? It is like saying that when you buy a car you lose the rights to drive it once you drive through a red light, or go speeding. I see it as "non of the car designer's business".


Should I spend time prettifying unit tests?

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 code. This seemed reasonable to me as the tests were usually changed frequently and the idea was to quickly write a test and then start seriously writing the code. The new company has just got the hang of unit testing our work, but they expect you to spend time making sure the test code looks as pretty and well thought out as the code it is testing. I personally think it a waste of time since tests are internal and while test code should be neat, it does not have to be as perfectly engineered as the code that goes out the door to the customer. Am I wrong in my belief? What is the right thing to do here fellow programmers? Frequency of how often our programmers have to modify / extend / reuse existing unit tests varies, some more often and others less often. We are using Python Django and most of the test architecture is built-in and most tests are just simple functions. Very less setup/teardown needed.