Does business logic really belong on the server?

A typical stack for a web application is a database, a server with server-side code, and a user with a browser with HTML/CSS/JavaScript. Before extensive AJAX, MVC in which the controller was the server-side code rulled. A server had to route answer requests for Dynamic web pages (i.e. templated html solutions like JSP and ASP). The server to coordinate the calls to the database and decide which dynamic page to use to answer the page request. The result of all of this is that server ended up containing the business logic, even though business logic isn't strongly tied to the idea of serving pages. Now that we are moving to "Web 2.0" a server servers static pages that use JavaScript to fill themselves and change what they are presenting. The can be in the JavaScript. The JavaScript often implements a RESTful service meaning that it is specifying database query. So the server is left to the roles of serving actual files and answering AJAX calls. And answering AJAX calls is merely session management and providing security. And really, what a user should even be able to see is data that should be specified in the database. So from there, should the server be relegated to the role of a dumb intermediary that only occasionally does something like send out an email or fire off a webservice? Could business logic all live in JavaScript (when it is not secret) or live in stored procedures when it is? Will it make sense to maybe even combine servers and databases or make ERP solutions like SAP function as servers?


strcpy memcpy reason for parameter order

Answering a question about order of parameters it struck me that strcpy (and family) are the wrong way round. Copy should be src -> destination. Is there a historical or architectural reason for the dest,src order in these 'C' functions? Something to do with optimization of the stack on the PDP-8 or something?


How should I implement code review in this situation?

My question is about how to put code review into practice in a workplace where nobody else has asked for it, I've never done it before, and I'm not entirely sure if it's worthwhile for this type of programming. I'm a contractor on an assignment that mostly involves tools engineering, data analysis, fixing code when someone's Excel template changes break a macro, etc. It's total cowboy coding: Requests are more "do what you need to do to hack together something that works ASAP, we need it in production tomorrow morning and we're only going to need it for a couple months" than "make a well-structured application that will be easy to maintain and develop under all foreseeable circumstances." The software engineering team is me and one other guy whom I supervise. We don't currently follow any kind of software development methodology beyond "make something that fulfills the functional requirements", and neither of us have ever worked anywhere that had any code review or design principles. Everything we make is either VBA or C# desktop apps, and each of us is usually working on a separate assignment rather than collaboratively building the same program. There is no version control system in place and we don't have server access to install any such system. What I'm trying to figure out is, given that the work is very ad hoc, what kind of code review, if any, should I put in place? Or is it even necessary for the kind of work we're doing?


What does "context-free" mean in the term "context-free grammar"?

Given the amount of material that tries to explain what a context-free grammar (CFG) is, I found it surprising that very few (in my sample, less than 1 in 20) give an explanation on why such grammars are called "context-free". And, to my mind, none succeeds in doing so. My question is, why are context-free grammars called context-free? What is "the context"? I had an intuition that the context could be other language constructs surrounding the currently analyzed construct, but that seems not to be the case. Could anyone provide a precise explanation?


Why is a click event triggered only after mouse click and release?

Every click event on the web works on mouse click and release. Is there a way to do a action on a click event before mouse release??


Good guidelines and practices for mandatory code review

We are trying out mandatory code review on each commit -- nothing gets into master that hasn't been validated by at least 1 person not the author -- for a couple of sprints. We have buy in from both developers and management (which is an amazing situation to be in) and we want to get some of the benefits that it is known for:   * obvious bug reduction   * more awareness of changes happening around the project   * the "I know someone is going to look at this so I won't be lazy"/anti-cowboy effect   * increased consistency within/across projects But we're introducing something that is _known_ to reduce velocity, and if done wrong could create a stupid bureaucratic step in the commit pipeline that doesn't do anything but take up time. Things that I'm concerned about:   * reviews devolving into just nit picking   * (hyperbolically) people opening up huge architectural issues as part of a two line commit review.   * I don't want to bias answers with other things. While we're all reasonable people and we'll be doing a lot of self analysis, we could definitely use some battle-won insight into what kinds of things we should be trying to accomplish in a review session to really make reviews work for us. What are some guidelines and policies that you have found to work?


Returning multiple values in Javascript

Often I am writing a function that returns multiple values, such as a pair of coordinates:               function get_coords() {       return ???;     }      If I was using a language like Python, I would use a tuple:               return (x, y)      Or, in an OOP language like Java, I would create a custom coordinate class:               class Coordinates {       public int x;       public int y;            public Coordinates(x, y) {         this.x = x;         this.y = y;       }     }      Then return like this:               return new Coordinates(x, y);      **On to JavaScript.** In JavaScript, we have the option of returning a simple object:               return {x: x, y: y}      or a Java-like approach, with a custom object:               return new coordinates(x, y)      Are there any reasons to use one above the other?


Why was ASCII needed?

With an encoding such as EBCDIC being in existence already (and being 8 bit to boot), what was the need to invent yet another encoding and a 7 bit one at that? Why was ASCII invented and what problems with EBCDIC did supposed to solve?


How to keep motivation in hobbyist programming projects?

There is already a couple of questions here about motivation, but they are related to programming as a job, teamwork and so on. I have been noticing, that in the past few years my motivation to code hobby projects is decreasing. It was already decreasing about something like 8 years ago, then it got better about 4 years ago, now it is starting to get bad again. Since I do not work, lack of motivation in a job isn't a problem. The projects I am interested in developing are a couple of computer games, and a ORM library for php. I want to program those things, but I feel like I lost the energy to do them. The symptoms are stuff like: unable to concentrate, coding for about 30 minutes then leave the project to do other stuff, loss of pleasure in doing the whole thing, among others. This thing bothers me, because it is (or used to be) something that make me feel happy and I don't wanna lose the good feeling of doing something that I like.


Responsibility for delegation of stories in agile

I've recently worked on a project where the Team lead was commenting he needed to figure out which stories we are going to be working on in a scrum. It was my understanding that stories are prioritized and perhaps a number of stories are added to a sprint from that list. At this stage during our scrum the developers each pick a story they are going to implement and off they go. I suppose if a number of stories have dependencies them the team lead might help facilitate the story priority within the sprint itself but not actually dictate which developer does which? None of us are juniors in the team and we all have equal knowledge about the domain. Our experience of particular facets of the layers i.e. UI, database, infrastructure vary but not dramatically so. So my main question is as to the role of a Team lead (and other developers I guess) within a sprint itself and delegation of stories. If it helps, the project was a MVC .NET application with some database backing. Our team consisted of 4 developers, 1 tester and a Project manager.


From Programmer to System Admin?

I know this sounds like a weird question, but do you think it's possible to go from a Programmer Job to a System Admin job? I mean the pros:   * You're a programmer, so you know scripting pretty well (for Cron Jobs/Bash Scripts)   * You usually know your way around a Unix System   * You could prolly debug stuff that isn't working.   * Most programmers are familiar with Computer Hardware   * You have a Degree which you worked hard for, and your familiar with setting up different software systems So do you think it's possible to go from a Programmer Job to a System Admin job? or probably not.


what is a proper way to register eventHandler

I was showing some of my code to a junior programer, and he asked me why am I registering functions for event handling like this:               button1.Click += new RoutedEventHandler(button1_Click);      and not like this:               button1.Click += button1_Click;      The only thing I could say was: because you just write `+=` and press tab two times... What is the difference between those two metods (if there is a difference)?


Can REST, Ajax and jQuery work well together?

I'm trying to use REST (usign spring MVC) as my Ajax backend but got some problems when using it with jQuery. REST best pratices recommend using HTTP status code, e.g. 200, 403, 401, etc, and I have no problem with a 200 status code, jQuery's ajax method have a done(data) callback that let me read the reponse in json format. But when I need to return some error in json format along with the status code, I got stucked. The fail(jqXHR, textStatus) callback doesn't seem to support json in the response. So if I return JSON from the serverside, it will be put in jqXHR.reponseText and treated as plaintext instead. So my question is, is REST good for Ajax? Why does jQuery treat the data differently in case of non-200 status code?


Patent in Europe

I'd like to build and sell/or free a software based on ffmpeg and some other mp3 library lgpl, So I know in U.s.a. there's a patent and royalty problem, But if I live in Europe I'd like to know if I can create software with mp3 encoder/decoder and mpeg decoder/encoder should I pay royalty? Or can someone (mp3/mpeg creator) put me in front a Court?


displaying multi-section html documents - best practices

I work at a research organization and we publish a lot of large-ish documents, usually organized in sections. What I want to know is how best to present these multi-section documents on our website. Presently, what I do is load the entire document as a single page, with each section as its own div. Then I show and hide divs as needed via a table of contents and "next" and "prev" buttons. The advantages to this are mainly: 1) that you can move between sections very quickly, 2) it produces consistent analytics (when a page is loaded, I know a report is being read). The disadvantages, however, are real:   * Readers can't take advantage of browser back/forward buttons to move between sections.   * It's complicated to create direct links to individual sections (I can do it with javascript but it's not easy for other people to grab and share).    * For long reports, you have to wait for the full report to load before you can move around (and that can include hordes of images and charts). Do other people have thoughts on better ways to organize this? Here's an example of the current system: http://massbudget.org/825


Is Microsoft Prism alive and active?

I've been doing a lot of reading these last two days on Microsoft Prism, but the thing I'm still not very sure of is what does the future look like for it? I know that version 4.1 was just released a few months ago, but besides Microsoft's own documentation, I haven't found many blog posts written in the last year on the subject, most of what I find is 2009-2010. It definitely looks interesting but the learning curve seems to be a bit steep and I wouldn't want to embark if it's going to become obsolete in the near future. Anyone has any insight on this?


Suggestions for a CMS markup language for PHP

As a learning experience, and as project, I am attempting to write a CMS module for ZF2. One of the functionality I would like to have is the possibility of adding dynamic contents in the pages by calling PHP functions in the view scripts. However, I do not want to give the users freedom in writing PHP code directly inside the page content, but rather implement custom view helpers (or widgets) to handle logic. For example: calling `partial`, `partialLoop`, `url`, etc. specifying arguments and all. I liked the idea of extending Markdown but this would get complicated when trying to add custom CSS class to elements, etc. Then I had the idea of simply doing a `preg_replace` on some patterns. For example, the string :               ### partialLoop:['partials/display.phtml',[{id:'p1',price:4.99},{id:'p2',price:12.34}]] ###      would be replaced by               <?php echo $this->partialLoop('partials/display.phtml', array(array('id'=>'p1','price'=>4.99),array('id'=>'p2','price'=>12.34))) ?>      Obviously, there would be some caching done so the page content is not rendered everytime. Does this sound good? If not, what would be a good way of doing this? Or is there a project already being developed for doing this? (I'd like to avoid heavy third party libs and something fairly or fully compatible with ZF2 would be nice.) Thanks.


dvcs - is "clone to branch" a common workflow?

I was recently discussing dvcs with a coworker, because our office is beginning to consider switching from TFS (we're a MS shop). In the process, I got very confused because he said that although he uses Mercurial, he hadn't heard of a "branch" or "checkout" command, and these terms were unfamiliar to him. After wondering how it was possible that he didn't know about them and explaining how dvcs branches work "in place" on your local files, he was quite confused. He explained that, similar to how TFS works, when he wants to create a "branch" he does it by cloning, so he has an entire copy of his repo. This seemed really strange to me, but the benefit, which I have to concede, is that you can look at or work on two branches simultaneously because the files are separate. In searching this site to see if this has been asked before I saw a comment that many online resources promote this "clone to branch" methodology, to the poster's dismay. Is this actually common in the dvcs community? And what are some of the pros and cons of going this way? I would never do it since I have no need to see multiple branches at once, switching is fast, and I don't need all the clones filling up my disk.


Storing and presenting custom table data

I have a web site upon which I want to provide users the ability to create tables of data. These tables will come from a predefined list of table definitions of which I will be adding to myself. This list will likely grown into the hundreds. The table definitions will be created as Java classes. They will define how many columns there are and their data types (string, numerical, boolean, pick from list). It will also predefine some columns as automatically calculated form other columns. The number of rows will be limited but this could range from 10 to 10000. Additionally I will give users an option to create a custom table type where they set the number of rows and columns and the column types (string, numerical, boolean, pick from list - no formulas). The tables must be sortable on certain columns (with secondary sort columns depending on the first). The data sorting will (probably) be done by the application rather than the database as it will include different logic in different table definitions. I might include a simple text search but not a filter. The table data may be updated but I expect this to be infrequent (days apart, mostly never). What I can't decide on is the best way to store this information. I am using a relation db (postgres). Since each row will be made up of various different column types I can't store the data in separate database rows with relevant field types for each column. On the web side I want the users to be able to view paged data. Users that don't have JavaScript enabled can put up with a basic table of paged data without sort options. Users with JavaScript enabled should have options to sort data. _Storage_ **Option 1** Create an XML doc containing all the data and store in one row of the database. This will be easy to read and write but means the entire web table must be loaded into memory even if only delivering a few rows to the browser. **Option 2** Create XML fragment for each row and store in separate database rows. Since data will be sorted by the application the order must either be calculated when the first page is displayed and then for further pages only the required rows returned, or when data is updated a predefined index is created for each sort option. The predefined index seems like the better option as it won't change often but will be read numerous times. _Delivery of data to the browser_ **Option 1** For JS enabled browsers get all the data using AJAX/JSON. The response would be cached on the browser and using JS populate a table with data. Further trips to the server shouldn't be required unless the data is updated (only detected when page is refresh using a last updated time embedded in the page). Subsequent visits to the page should use the cached copy of the data. **Option 2** Embed paged data in html. If JS is enabled then further updates using AJAX. I don't want to use HTML 5 offline storage to support older browsers. I think I have to go for both Option 2s to accommodate non JS browsers and to minimize the memory usage. Are there any other possible solutions?


Can symbolic AI 'learn' a data model?

Perceptrons, a simple form of supervised machine learning, must be trained with a set of known good inputs before they can "learn" by adjusting internal weights assigned to inputs, based on the accuracy of its results. Similarly, we know that reinforcement learning and unsupervised neural networks are able to learn without any known model of the problem; they can be designed to collect information about an environment only by interacting with it. Can symbolic AI be used to design a system that can achieve this "naive learning," or is this a property exclusive to certain soft computing techniques?


How to become a super user (programming)?

You try a new tool and it does not work. You google the problem and if you are lucky a random answer says you need to edit some weird configuration file and place it in a specific directory you don't know. You try but during the process things go wrong. Either because you don't understand the steps listed in the answer or because the solution is not exactly the same situation as yours. I can't be the only who is puzzled/annoyed when I am in these kind of situations. I find these problems a lot more scarier than when I don't understand a particularly algorithm. Often I can end up using 10 hours trying to get something to work without getting anything done. After that I just give up. I like programming but I really hate these moments when you need to integrate with a tool and you end up in situations as described. Often I don't even want to try new tools because I am afraid of this happening. My question is: Is there a way to get better at this? Is there a faster way to learn all this without just practicing? I have thought about getting books about unix and begin using the shell for every day use but I am not sure it is worth it.


How should I go about developing some basic C/C++ knowledge so that I can grok the concepts written in some Classic software programming books?

I know Java and JavaScript pretty well. I have never really worked on C/C++. But at this stage of my career I feel that the fact that I do not have adequate knowledge on C/C++ syntax(especially pointers *), I am missing out vital parts on reading some classic books in the field of software programming. Here are some of the books that I would like to read and understand thoroughly but unable to comprehend the example code as I do not know the C/C++ syntax:   1. Advanced Programming in the Unix environment where C is used.   2. GoF book where examples are in C++/Smalltalk .    3. Algorithm Design Manual by Steven Skienna where again C is used. I do not intend to work on C/C++ projects. So I do not want to spend a whole lot of time learning the intricacies of these languages but I would like to at least have some working knowledge so that I can understand at least 80% of the examples in those books. I do not want to miss out on the essence of these classic books. What should I do about this?


Best way for a technical manager to stay up to date on technology

My manager asked for a list of technical blogs he should follow to stay current on technology. His problem is he keeps hearing terms that he hasn't heard of (i.e. NoSql, sharding, agure, sevice bus, etc.) and he would prefer to at least have a fighting chance of knowing something about them without having to be reactive and looking them up. Also I think he wants to have a big picture of all the emerging technologies and where they fit in together instead of just learning about each thing in isolation. He asked about blogs but I'm thinking print magazines may also help. What should I answer him?


Do you use your personal laptop for work?

We're trying to get our company to let us use our own personal laptops for client work. We've agreed that any code/data will be encrypted using something like TrueCrypt, in case a laptop is stolen or lost. However, the company is still skeptical and not sure they want to allow us to use our personal machines for development. They would rather buy us laptops... but we want to use MacBook Pros and they don't want to pay for them. Even if they did buy us laptops, we would stil have the issue of needing to encrypt the code/data in case of theft/loss. Do you use your own laptop for work? What are the arguments for/against this? * * * **UPDATE:** Thanks for all the responses, its given us a lot to think about. This was originally brought up because we were asking for a "personal loan" to buy new laptops for ourselves, and then we threw in there that we would use these laptops for work too - since right now we use our personal laptops occasionally, e.g. at client site or weekend support.


Is agile about development or management?

On a debate over what Scrum is all about, I found that perhaps I totally misunderstood the agile thing. It appears to me that Scrum (which is certainly considered an Agile process) is all about managing features and sprints and roles and stuff with nothing to do with TDD, pair programming, CI, refactoring and other developer centric techniques and practices that I though (until now) are the heart of agile. Now I am facing a difficulty ! 1) Is Scrum agnostic to whether developers do agile practices? 2) Can you implement Scrum in a team that does not utilize automated tests? does not perform refactoring or does not adhere to the agile programming practices?


Agile MVP (Most Valuable Player/Programmer)

Recently I've been involved in an agile project (using scrum) where management came up with the idea that the team would nominate a developer 'MVP' as well as a QA 'MVP' at the end of each sprint, voted on by the team. The MVP then gets a small monetary reward and free lunch as well as a trophy to display on his desk. We've had two sprints so far with this reward system in place. The good I see from this is the following:   * More bugs have been fixed (which is what upper management wants to see, a number change in the direction they want)   * The MVP from each 'team' gets recognized and gets a self esteem boost (or is it an ego boost?) I've noticed a few what I would consider bad sides to doing such a thing (at least from a developer standpoint):   * There are a few developers who are so concerned with the number that the quality of bug fixes has gone down. Fixes in one area are causing regressions in another.   * There are a few developers who are cherry picking 'easier/quicker' bugs to boost their bug count. Could be good of bad here I guess.   * Higher priority (which a lot of the time correlates to 'harder/longer to fix') defects actually become lower priority.   * Blocking defects are not addressed in a timely manner, as usually they take longer and require more coordination with QA.   * The team aspect within the Dev team has been lost. The team aspect of Dev and QA working together as one hasn't improved either, but hasn't really changed too much from before.   * Work beyond bug fixes, or working towards THAT number, isn't easily recognizable/tracked. I do believe that each of the 'bad' above can be addressed to some degree, depending on how the team handles each. My question is, then, has anyone successfully pulled anything like this off, where you recognize an MVP per sprint? If so, what do you think contributed to that success?


On contract work, obligations to said contract, and looking out for yourself…

Without boring you all with details, my last two contract assignments were cut short; I was given 3 days notice on one, and 4 weeks notice on the other. Neither of these were due to performance – they both basically came down budget issues. On my second contract, I got the feeling that I may not have been a great place to stay for the duration of my contract. Because of money/time spent getting me in the door, and the possible negative effect of my employer/recruiter, I decided to stay at least for a few months (and start looking several weeks before the end of my supposedly “extendable” contract). These experiences have left me a little wary of contract work. It seems that if I land a bad contract, that my recruiter would take a hit (reputation or otherwise) if I quickly found another job. But on the other hand, the client company won’t think twice of ending the contract early for any reason. I know that the counter argument to this is “maybe your recruiter shouldn’t have put you into a crappy assignment”… either way, it seems that since I am relying on him to provide me with work, that I should try to not damage his reputation with client companies. I’m basically brand new to contracting (these were my first two contracts) so these concerns are new to me. **TLDR:** Is contract work, by its very nature, largely unstable? Am I worried too much about my recruiter? Should I be quicker to start looking for a new job even after just weeks at a new company (when the environment seems unstable)? If so, do I look through my recruiter or just find another position by any means necessary?


Choosing between Qt/C++ and .NET/C#

I have a desktop project I've been working on for a couple months that I want to run on Windows and Mac. When I started the project, I started writing it in Qt 4.8 in C++. Development has gone fine and the application runs fairly well on both Windows and Mac like I hoped. I would say it's about 40% complete at this point. For a little background information, the application is a variation of an email client. But I am thinking about abandoning what I've done so far in C++/Qt and purchasing a license for Xamarin Studio and writing the application in C#. There are a few reasons I am strongly considering this:   * I want to release mobile versions of this application too, and with C# a lot of the backend code could be reused on all platforms.   * I want to publish this app on the Apple **and** Windows stores. I know that you publish Qt Apps on the Apple Store but I have not read or been able to find anything about anyone publishing Qt Apps to the Windows Store. Not to mention, Qt 4.8 has no built in support for Metro UI (I would have to use Qt 5.0, which would mean rewriting a large part of the code anyway).   * Having worked in both C# and C++ for many years, overall I am "happier" developing in C#. However, I have a few reasons the stay the course:   * As I mentioned above, I am about 40% complete in the first incarnation of this project.   * A large portion of my program rests upon Lua, for which I'm able to use the native Lua libraries quite easily in C++, and I'm not sure how well the Lua implementations I've seen for Mono/C# work.   * Maintaining two separate UI code for the desktop app (hence, in Qt I can `#include <QtCore>` on Windows and Mac, but in C# I'd have to `using System.Windows.Forms` on Windows and 'using MonoMac.' on Mac) Honestly, at this point I'm inclined to start over in C#, using what I have in C++ as a guide and delay my release for about a month (about how long it'll take me to catch up considering other responsibilities in my life). I was looking for some input from people who have been in a similar situation. And I'm particularly interested in hearing from anyone who has used C# to publish apps on the Windows and Mac stores. What do you think?


Sense of unit tests without TDD

We have new (quite big) project starting, that we planned to develop using TDD. The idea of TDD failed (many business and non-business reasons), but right now we have a conversation - should we write unit tests anyway, or not. My friend says that there is no (or close to zero) sense in writing unit tests without TDD, we should focus only on integration tests. I believe the opposite, that there is still some sense in writing plain unit tests, just to make code more futureproof. What do you think? Added: I think that this is not a duplicate of >>this question<< \- I understand difference between UT and TDD. My question is **not about differences** , but **about sense** of writing Unit Tests without TDD.


Why are nested loops considered bad practice?

My lecturer mentioned today that it was possible to "label" loops in Java so that you could refer to them when dealing with nested loops. So I went home and looked up the feature as I didn't know about it and many places where this feature was explained it was followed by a warning, discouraging nested loops. I don't really understand why? Is it because it affects the readability of the code? Or is it something more "technical"?


Should I commit my generated parser to source control?

I'm using a parser generator to build a compiler. Should I commit the source files produced by the parser generator? I want to commit them to avoid a dependency on the parser generator during the build process and tests. However, if I commit them, it is tempting never to update the parser generator for fear of backwards-incompatible changes. Are there other advantages or disadvantages that I have not thought of? References:   * Do I check generated code in to source control or not?   * What Part of Your Project Should be in Source Code Control?


Beautiful user interface vs. more and more technical features?

I will understand if you find this is more a discussion than a technical question and if you close the topic (then, where would be an appropriate place to discuss about that? thank you in advance). The question : how do you decide between improving the user interface with a great design or adding more and more technical features? I would like to meet people interested in Windows coding beautiful user interfaces in order to improve an existing (very powerful but not good- looking) open-source project, which has a lot of potentiality! I know this is probably not the appropriate place for such a question, but maybe you would know a better place?


Why is it so hard to find anything on MS site?

I have always had this question in my mind and I would really be happy to get an explanation for this. Is it only me or do you also feel the same way that it's hard to find anything on MS site. For example, every time I need to download .NET framework I have to Google it. You never know what you can download, no category for downloads. You are simply left to a search field. You never know if you downloaded the latest version of the file. The tragically true is that you have to rely on their competitor Google to find anything on their site. I know that they are a big company.   * **But is it really that hard to have an organized way to publish information?**


Why is there no generic implementation of OrderedDictionary in .net?

Why did Microsoft not provide generic implementation of OrderedDictionary? There are a few custom implementations I've seen, including: http://www.codeproject.com/KB/recipes/GenericOrderedDictionary.aspx But why did Microsoft not include it in the base .net library? Surely they had a reason for not building a generic.... but what is it? Prior to posting this message, I did see: http://stackoverflow.com/questions/2629027/no-generic-implementation-of- ordereddictionary But that just confirms that it does not exist. Not **why** it does not exist. Thanks


How is coding on a 13" MacBook Pro?

I've been working on a 15" machine for years, but recently I was tempted by the 13" MacBook Pro. Because I'm often on the road, I was looking mostly for a lightweight machine, considering I've external screens almost in every place where I work. Is there anybody who's working on a 13" MacBook Pro that would give me a tip? Is it your best friend or you're gonna throw it out the window? Outside my world made of code and IDEs, I really don't care about apple rumors: should I wait because a new version of the MacBook Pro is gonna be released? Your help is appreciated, thanks.


Can AspectJ or AOP in general be used to test exception handling?

I'm reading a book's chapter ("Controlled Exception Test" in "Testing Object- Oriented Testing") about testing exception handling in a running system (not at unit level). The conclusion is that it is hard to automatically trigger an exception at a given layer in the system other then simulate a cause for an exception. Wouldn't usage of AspectJ or any other AOP approach solve the problem? With AOP I can create an aspect that will throw an expected exception and attach it to the method called before exception handling.


Should the commit history be used to convey critical information to developers?

Recently a conversation came up during a meeting regarding the rollback of a third-party SDK from the latest version and it was noted that the fact it shouldn't be used was already in the commit history. Other developers argued that this was a bad practice and there should have been something either in the source file (i.e. `// Don't upgrade SDK Version x.y.z, see ticket 1234`) or in a project level `README` file. The others argued that since the commit history is part of the project documentation that it is an acceptable location for such information since we should all be reading it anyway. As such, should the commit history be used to convey critical information to other developers or should such information be duplicated to another location such as a project `README` or comments in the relevant source file?


Avoiding Double POST

We are implementing a RESTful webservice that will allow client applications to POST documents to it and it will store the document returning a unique identifier in the response. The clients will mostly be Spring MVC applications, but do not have to be. The two client applications that we are currently working on have various JSPs which contains HTML forms that will contain file elements and other attributes. So a user will submit a form via POST to a Spring Controller in the client application. The Controller will read the bytes from the file and then POST them to the RESTful service, receive the unique identifier back, and store the unique identifier along with the other information from the form in the database. As each client can have multiple JSPs with widely varying attributes in the forms, we don't see a way to just POST directly to the RESTful web service. Is there a clean way to avoid the double POST? I could see the possibility of having a reusable pop-up window that takes care of POSTing the document to the RESTful web service and then holding the unique document id either in the session or a hidden field on the parent form. I can see two downsides to this: 1) the user may not like having the extra step of going to the pop-up and 2) the document could be orphaned if the user does not submit the parent page. EDIT / CLARIFICATION: the issue is not that a POST is being sent twice to the same resource, but rather avoiding have both a POST from JSP to Controller within the client application and then a second POST of the same data from the client application to the REST resource.


Haskell syntax for type definitions: why the equality sign?

I am a bit confused by the choice of Haskell syntax for type definitions, like in               data Foo = Bar      Namely: does the equality sign here really mean an equality in some subtle sense, or is it just a random notation choice? For example, in               foo x y = bar y x      the equality is really an equality: if this line is present, `foo a b` and `bar b a` can be used more or less interchangeably in the program. However, `data Foo` and `Bar` probably cannot be used interchangeably after `data Foo = Bar`. Whenever i resume my attempts to learn Haskell, i am a bit confused by this IMO counter-intuitive syntax and need to look up the documentation to recall the formats of the LHS and the RHS. Are there any alternative syntaxes for type definitions by any chance?


Means for (legit) cross-site scripting

Are there good means for allowing scripts from two or more domains to collaborate in the same browser page? I want to create an extensible platform, where I provide the model and some views, but also allowing third parties to create their own views as well. The idea is that all model manipulation will be done through its API, and only the model will communicate to the (main) server, but users will be allowed to include scripts from other domains that also use that API (those scripts might "call home" if they want to though). I know many sites already do that, for instance when they use a CDN to provide libraries like jQuery. However, I also recall reading that those libraries had to be "tweaked" somehow so they won't be mistaken by XSS attacks, though I couldn't find more info on the subject. I have only superficial knowledge of how browsers isolate contents for different domains, and to what extent that isolation occurs, so some pointers in that direction would be very welcome. I'm also aware of the method of using iframes to load "less-than-trusted" contents, and it seems that communication between the main page and its iframes is quite straightforward. I'd rather not use that method, but will do if there are good security benefits of doing so. However, I'm unsure if that's the case, since the iframe can call arbitrary methods on the parent page... ( _Edit_ : from what I understood of Florian Margaine's comment, the method in the linked question only works for same-origin iframes, is that correct? In that case, I can see the security benefits now) Can anyone with experience on the subject tell me how it works? These are the only options I know of, other suggestions are welcome too. I'd also like to note that, while there must be some level of trust between the user and the third party providing the script (since its very purpose is manipulating the model owned by that user), each user will be free to choose extensions at his leisure (i.e. the available scripts won't be restricted to ones I previously evaluated and endorsed), so any means to mitigate security problems to the users are also welcome. **Edit:** Let me clarify the question a bit. The goal here is not to make HTTP requests to other domains, merely to have a better control of what the different scripts do to the same page. From what I understood so far of the same origin policy, **different pages** can not communicate to each other unless they come from the same domain, but scripts **in the same page but coming from different domains** can do whatever they want. Is that correct? (if it is, then I guess my question is moot...)


Development platform for .NET development?

I'm currently in discussions with my boss about getting a new pc since my old one is getting ... old... I am the only "real" developer in the company (it's not a software company) and as such they haven't really bought any pc's with these kind of specs before. So, I made a list, because building my own, is cheaper than buying finished. http://www.prisjakt.no/product_list.php?do=lista&k=10529 And he thought it was kind of overkill. And I can admit, I may have gone a bit far on some choices (the raided SSD's for example), but I though it was better to go out high, then come down a bit during discussions. But what would you say is a comfortable platform to do .NET development on? I currently use Visual studio 2010, local SQL Server 2008 R2 (Developer Edition), 1-3 local VM's for doing testing, and I use Windows 7 Enterprise x64 as OS. I myself don't feel that this list is very overkill, not to mention that it's very future proof. I put on 240Gb of system-disk, and 4Tb of storage, so I won't run out of space anytime soon. It's a i7 quadcore, 16Gb memory... It's not the bare minimum, but it's not very exaggerated? 10000 NOK is about $1900 USD.


What is the acceptable error margin when estimating a project duration?

The company where I work is aiming to have a 10% maximum error margin.They expect analysts to not miss the estimate by more or less than 10%. I don't know what to think about it, since I got nothing to compare it to. What could be a good baseline to measure if we are estimating too wrong, for more or less? How much (in %) do you think is _okay_ to to miss?


How you would name a .NET port of a Java project?

Assuming that a Java project is called "bar" or "jBar". How would you name a .NET port (in C#):   * NBar    * dotBar   * BarNet    * Bar-sharp


How can I fetch data from more than one web services simultaneously in PHP?

I have 3 web services that are providing me data for my hotel booking engine. It is taking too long if I run them sequentially. Therefore I wanted to run them using threads, but I am not sure if php threading will support this and if it is safe, since all 3 processes that will handle the web service will read and write into shared tables. Can anyone advise me on how should I proceed?


Outsourcing functionality from Django view to C/C++

I'm developing a Django project that basically boils down to:   1. A user submits a form.   2. The Django view parses the form and compiles a representation of that form which is readable by some other 'function'. By 'function', I mean some kind of executable/callable where the Django view may be agnostic about what language that 'function' was written in, or even what hardware it runs on.   3. The Django view passes the compiled form into the 'function'.   4. The 'function' performs its business on the input, then outputs some data in a format readable by the Django view.   5. The Django view reads the output of the 'function' and renders the data to a format that is consumable by the user. In my specific case, the 'function' is a large numerical computation not suitable for plain-vanilla Python. Furthermore, this 'function' has already been developed in C++11 and Python can talk to the compiled binary via os.system and file IO. **My question then is:** _why should I not just use os.system orsubprocess from the Django view_ rather than a) redevelop the 'function' using one of ctypes | swig | Boost.Python | pyrex | cython; b) learn how to write Python extensions and re-write the 'function' accordingly? I have also considered turning the 'function' into a daemon, but I am not experienced enough with daemons to be able to gauge what the consequences of such a design would be. **Are there undesirable/undefined behaviours that would arise from using os.system/subprocess as described above for a Django project that was operating under load?** Is there something else I am missing that is super obvious to everyone else? There is also this related question. But with the scarcity of details in both the OP's use case and in the answers, I am cautious not to fall for my own fallacious confirmation bias.


Is it common to separate back-end and front-end into two positions on web development projects?

At a web startup, is it more common to have an engineer working the front-end AND back-end of the feature (basically in charge of the whole feature)? Or have engineers separated between the back-end and front-end? Which ones are more beneficial and for what situations? The downside, I've noticed, regarding having one engineer in charge of the whole feature is that the person might only be particularly strong in either frontend or backend development but not both, thus sometimes having a decrease in speed and quality. Having frontend and backend developers on one feature increase the speed of the feature and the quality AND it encourages collaboration. But I am concerned about having 2 engineers working on one feature which may be a poor use of resources since the 1 engineer can be placed on another feature to work on. What is the common/best practice for allocation backend/frontend engineering resources at a small early-stage startup? And then how will it change as it grows?


What does Scrum say about tech demos?

I'm sometimes suppsed to demo work and I wonder if the Scrum methods have specified something about how demos should be done? I've done quick demos and I've been asked to demo on-the fly while it's not realistic to expect that programming always moves only forward. SO I'd like to know if you can tell me since I follow Scrum, if there is anything there that can improve my technical demos? For instance how often and when a demo should be done?


Is it true that what you learn as a CS undergrad will be out of date by the time you graduate?

I've heard this statement thrown around a few time by technology/science pundits on the web. Does it have any merit? What exactly do they mean?


Teaching C++ to first time high school students: Where to draw the line?

I will be mentoring a team of high school students for the FIRST Robotics Competition, most teams here develop[ their robot software using C++. For many of the students on the team this will be their first introduction to programming. I wouldn't have chosen C++ for teaching programming to high schoolers (e.g. Python or Javascript would have been easier I think) but the choice is set. I want to teach them proper C++ (i.e. avoid a mixed C/C++ dialect, i.e. C+) but I don't want to scare them either with needless complexity. For that matter:   * Should I start using STL from day one, esp. `vector` or just stick with standard arrays? Arrays are easier to introduce but the pointer errors may be harder to catch.   * For I/O, should I stick to `cout`, etc. or do you think `printf` would be easier to learn?   * Are there any online resources for C++ that are suitable to use for such young learners? Thanks! **EDIT** : Thanks for so many excellent answers. In addition to _Accelerated C++_ , which is suggested by many people, I have found that _C++ For Everyone_ is an excellent text.


What are the benefits of being proficient in multiple programming languages?

I have a friend who refuses to learn any other language than Perl. How do I convince him that he can not go through his entire life with only 1 language? What are some arguments to open his mind up to new languages? What are the benefits of learning multiple programming languages?


Are there any standards for preparing a user manual of electronic device? I am trying to prepare a manual for a device. However, I could not find any format. If I find, I will take this as guide for me. If there is no standard, what should be in the manual or what should not be in?


Should a software developer get a yearly equipment budget?

I am looking at a new position with a new company. I have talked to some people in the past (in general, not at this company) that they had been given a yearly budget to buy new computer stuff to keep up to date. Now why I feel this question is worth asking here is that Joel comes right out and says an employer should pay for the best equipment money can buy... within reason of course. From The Joel Test: 12 Steps to Better Code > ### 9\. Do you use the best tools money can buy? > > Writing code in a compiled language is one of the last things that still > can't be done instantly on a garden variety home computer... > > **Top notch development teams don't torture their programmers.** Even minor > frustrations caused by using underpowered tools add up, making programmers > grumpy and unhappy. And a grumpy programmer is an unproductive programmer... Does anyone know if the industry has such a standard to offer an allowance or budget? I have never worked for a company like this, but I am thinking I should toss this in the ring for negotiations. Seems reasonable. How do bigger companies like MS, Google, and Apple handle this? If you say yes, give a range... I have been told numbers from $5k to $10k. Seems high to me, but hey I would gladly take it.


Starting again on desktop development

Years back I did a lot of programming in Delphi (mostly scientific). For the last few years I have been doing development work based on web technologies. I need to turn a couple of applications quickly for the desktop. I have looked at Qt and the learning curve seems a bit steep. Is going back to Delphi (say with Delphi XE) recommended? What are the advantages and disadvantages? Cost is not an issue.


Do large mercurial repositories suffer from a "push race"?

Reading a few "Why a DVCS is better" answers to several question on Programmers.SE they all seem to say that in general, DVCS is better since you don't have a commit race in large projects, IE commit, out of date so update, commit, out of date again, commit, still out of date, etc. DVCS limit this with the concept of the push. However in very large projects wouldn't there be a "push race", especially at the end of the day? I know in Git this is somewhat remedied by the constant branching for everything, but in Mercurial you don't branch, you create a new head. Problem I see   1. User attempts to push   2. Out of date (mercurial won't let you push if your local repo is out of date), so you pull and merge your local changes   3. User attempts to push again but while they were merging someone else pushed, so they are out of date again   4. Pull and merge again   5. Still out of date   6. Repeat Sound familiar? Is this an actual problem with very large and popular mercurial repos? What about inside a company when everyone does their final push of the day?


Do some programmers know some secrets that we others don't?

I will not bother you with details of my discussion so I will present it in the form of a short instance. A java guy has been following articles and publications of a famous programmer (a kind of Martin Fowler of my country). He says that he is sharing some secrets which other famous programmers don't share. I never believe that there are some secrets like wizards in the programming area. But some programmers who are not good yet in this area think that other famous programmers are success because they know some secrets that we don't. I totally disagree with this and I discussed it with someone and finally he said to me you are 2 years in this area and he (java guy) is 20 years professional programmer so he knows better than you. I wanted to be sure that I am not wrong. That's why I wanted to know this.


How to properly document functionality in an agile project?

So recently, we've just finished the first phase of our project. We used agile with fortnightly sprints. And whilst the application turned out well, we're now turning our eyes on some of the maintenance tasks. One maintenance task is that all of our documentation appears in the form of specs. These specs describe 1 or more stories and generally are a body of work which a few devs could knock over in a week. For development, that works really well - every two weeks, the devs get handed a spec and it's a nice discrete chunk of work that they can just do. From a documentation point of view, this has become a mess. The problem with writing specs that are focused on delivering just-in-time requirements to developers is we haven't placed much emphasis on the big picture. Specs come from all different angles - it could be describing a standard function, it could describing parts of a workflow, it could be describing a particular screen... And now, we have business rules about our application scattered across 120 documents. Looking for any document for a particular business rule or function in particular is quite hard because you don't know which document has this information, and making a change request is equally hard because once again, we are unsure about which spec to make the change. So we have maybe a couple of weeks of lull before it's back to specing out functionality for the next phase but in this time, I'd like to re-visit our processes. I think the way we have worked so far in terms of delivering fortnightly specs works well. But we also need a way to manage our documentation so that our business rules for a given function / workflow are easy to locate / change. I have two ideas. One is we compile all of our specs into a series of master specs broken by a few broad functional areas. The specs describe the sprint, the master spec describe the system. The only problem I can see is 1) Our existing 120 specs are not all neatly defined into broad functional areas. Some will require breaking up, merging etc. which will take a lot of time. 2) We'll be writing specs and updating master specs in each new sprint. Seems like double the work, and then do the devs look at the spec or the master spec? My other suggestion is to concede that our documentation is too big of a mess, and manage that mess going forward. So we go through each spec, assign like keywords to it, and then when we want to search for a function, we search for that keyword. Problems I can see 1) Still the problem of business rules scattered everywhere, keywords just make it easier to find it. anyway, if anyone has any decent ideas or any experience to share about how best to manage documentation, would really appreciate it.


Can a function be too short?

Whenever I find myself writing the same logic more than once, I usually stick it in a function so there is only one place in my application I have to maintain that logic. A side effect is that I sometimes end up with one or two line functions such as:               function conditionMet(){        return x == condition;     }      OR               function runCallback(callback){        if($.isFunction(callback))          callback();     }      Is this lazy or a bad practice? I only ask because this results in a greater number of function calls for very tiny pieces of logic.


What is the preferred object to store this type of data structure

I was in a conversation with someone who codes for me. He was frustrated with my approach to a particular problem. I am entirely self taught and very pragmatic - I am not a professional developer instead I sometimes write code to get something done and then pass it on to him to clean it up - make it robust etc. We are reading in large txt files that use sgml tags to mark boundaries between individual documents that are related to one another.               <opentagfor txt file>     <document>     <maybe some attribute tags of the document>     the     document     could be a uuencoded     could be html     or something else     can tell what type by the attribute tags     </document>     <anotherdocument>     <maybe some attribute tags of the another document>     the     document itself     could be a uuencoded     could be html     or something else     can tell what type by the attribute tags     </anotherdocument>      .      .      .           <closetagfor txt file>      The individual documents get consumed downstream. Sometimes they get written out to a file structure for indexing, other times some of their content is extracted and saved as 'data'. So my approach was to create a dictionary of dictionaries.                document_dictionary = {document_position_index:{attribute-tag-1:value1,attribute-tag-2:value2,document:the\n    document itself\n    could be a uuencoded\n    could be html\n   or something else \n  can tell what type by the attribute tags}, . . .}      document_position_index is the index position of the document in the original txt source file - has no relevant meaning at all. now if I want to do something with the documents I can do things like               for document in document_dictionary         if document['some-attribute-tag'] == someValue:             do something      The problem is this bad coding (specifically using an integer (document_position_index)) was frustrating to my developer. He said that it is bad form. I still after Googling for a while do not understand. So I would appreciate either a better explanation then I got from him or some pointer to the right direction. Is this the type of question that should be asked here?


Making Modular, Reusable and Loosely Coupled MVC Components

I am building MVC3 application and need some general guidelines on how to manage complex client side interaction between my components. Here is my definition of one component in general way: Component which has it's own controller, model and view. All of the component's logic is placed inside these three parts and component is sort of "standalone", it contains it's own form, data needed for interaction, updates itself with Ajax and so on. Beside this internal logic and behavior of the component, it needs to be able to "Talk" to the outside world. By this I mean it should provide data and events (sort of) so when this component gets embedded in pages can notify other components which then can update based on the current state and data. I have an idea to use client ViewModel (in java-script) which would hookup all relevant components on page and control interaction between them. This would make components reusable, modular - independent of the context in which they are used. How would you do this, I am a bit stuck as I do not know if this is a good approach and there is a technical possibility to achieve this using java- script/jquery. The confusing part is about update via Ajax, how to ensure that component is properly linked to ViewModel when component is Ajax updated (or even worse removed or dynamically added). Also, how should this ViewModel be constructed and which technicalities to use here and in components to work as synergy??? On the web, I have found the various examples of the similar approach, but they are oversimplified (even for dummies) or over specific and do not provide valuable resource or general solution for this kind of implementation. If you have some serious examples it would be, also, very helpful. Note: My aim is to make interactions between many components on the same page simpler and more robust and elegant.


What are examples of automating BDD specifications through the UI layer?

I understand it is better **to automate BDD specifications below the user interface** whenever possible. For example and quoting from Gojko Adzic's book: _Specification by Example_ : > Don't check business logic through the user interface My question is then: **_What are the specific use cases when using the UI layer does make sense in the context of BDD?_**


ActiveX, OLE, COM explanation or informative links

I've been programming a lot with C# on Visual Studio and many minor/other languages, but I'm having a really hard time to get the grasp of ActiveX, OLE, COM interfaces. All I got is that they're like dll, you can write something in a language and make it work on another. Searching here but found nothing, searched on google but I found only hardcore explanation of people assuming it's the easiest thing in the world and building explanation on the assumption you already know what they are, giving just a line or two of explanation about them. I really need to know what's better now (as I've seen on wikipedia ActiveX it's the evolution of both COM and OLE which are older standards...) and a full blown explanation of them, possibly with code in it. In C# and Visual studio it's all much easier. You can create dll and include them in your project without much effort... Please explain here or paste links here with all the explanations you know/can find... Thanks


Any experience with Mono on production servers?

I am curios to use .NET for some web applications (e.g. ASP.NET MVC 2). However my budget is limited so I would like to use Mono on Linux. I have never used Mono before, and I haven't read about any bigger sites that is using Mono+Linux on the server in production. What's your experience using Mono on Linux in production? How is the performance and stability compared to .NET on Windows Server? Is there any popular sites that is using it in production? Any articles available online were they share their experiences?


Quick algorithm to find matches between two arrays

I'm faced with the following problem: I have an array which is produced by the parsing of a yaml file which contains patterns in the following structure.               "Programming books"         Title:               a list of titles         Author:     "Art Books"         Title:               foo               bar         Author:               Mrs. Foo               Mr. Bar         Year:      the program is supposed to be given random input and find if there is a book with that particular Title,Author and Year. So far I'm using the following                foreach book_type,values from config{            tag_match = 0            foreach tag from values{                 tag_no = values.length()                 foreach value from tag{                      if value in input                           tag_match++                 }           }           if tag_match == values.length()                /* tag the book matched continue matching*/      }      The program is not supposed to receive many matching lines bu it is supposed to receive a huge amount of data. So far it has to do book_type.length() * tag.length() * value.length() iterations for each line of input, is there a better way to do this?


Where to place configuration files sources

I am developing a C# windows service application, which have different configuration files for development, for production system, for test system, like:               Dev.config     Test.config     Prod.config      Now we are using SVN version control system, and configuration files stored in projects directories:               -trunk       -MyFooService         -Configs           Dev.config           Test.config           Prod.config       -MyFooService2         -Configs           Dev.config           Test.config           Prod.config      Prior publishing service to production you should get respective configuration file from that folders. How do you think, it is correct? Or configuration files should be placed in another repository? Or in another folder or should not be placed in VCS? Or may be it will be better to place files like that:               -trunk       -src         -MyFooService         -MyFooService2       -configs         -MyFooService           -Configs             Dev.config             Test.config             Prod.config         -MyFooService2           -Configs             Dev.config             Test.config             Prod.config


Post-hoc testing in TDD recommended?

I have a personal project that doesn't have robust testing. I had a bit of TDD going on at the beginning, but it quickly became counterproductive as the project details changed dramatically over time. So a lot of previously written tests have become useless. Now that the project solidified a bit, I dont' think big changes are likely. Should I go back and rewrite those tests for old functionalities or just start fresh and write tests for new functionalities only?


What is needed to become a Software Engineer?

I obtained a BSc CS & Applied Mathematics November last year and started working as a Software Developer in December. I'm currently working for a very solid company and I'm part of a small core development team, developing big software. I absolutely love software development and would someday like to become a (Senior) Software Engineer, Systems Analyst or Solutions Architect (not 100% sure about all the senior titles). My questions is - what experience do I need to obtain to achieve this? What is the necessary/desired career path? What type of courses do I need to attend to gain the needed knowledge?


What are the pros and cons of the MVVM architecture?

In class today we were introduced to the MVVM architecture for Silverlight/WinPhone/WPF; it looks nice for big projects, but what are your thoughts on MVVM? What are the pros and cons? I want to get more into the architecture so that I know when I should use it.


what is the transferability of changes in terms of a GPL license

I have a program that is offered to the public on the web as a GPL program. This is a hobby type project that i stated 3.5 years ago and i have had one collaborator for most of that duration who has contributed some code me and my collaborator both like to see the program develop as it's both our hobbies. A person has adopted its game board to a play against the computer program. He wrote his own engine and his game he plays on the board uses a different set of rules. I think both me and my collaborator are ok with a more permissive licence grant. I've told the the derived work author that code he modifies he can add his copyright, and any java files that are all his code he can have sole copyright. I can grant a more permissive grant. But if i do what would his right of transferability be. By granting him a modification of gpl and he makes his code open source, could he in turn give the same grant to anyone else or does he not have a right of transferability? The first question (that would cause the second to be not applicable) is: would GPL work for what i'm doing to promote my brand and allow others somewhat permissive use. The secondary question is would my lack of enforcement or accepting modifications of terms be inherited by any users of his work. My open source software is in a hobby area, chess. Understanding the open source licences helps me be persuasive and helps with communication as the eventual adapters of code begin.


How do you control code quality on your team?

Here is my situation. After almost 2 years I was able to convince my boss to use TDD, version control, coding standards for the entire team and a MVC framework for our web projects. I was finally there. It should be heaven but it's ending up like hell. I prepared some material about MVC and code samples showing common unit tests. Showed to the team, explained how things should be done and got their support. It seemed all fine, after all, team members were very experienced. I also made sure that the members had time to do things. At first, writing tests can take a very long time. So I tried to make them comfortable with "losing" this time without any manager asking them to do things quickly and dirty. After 15 days I was doing the first review of the code. And the result was not good. I found business logic on controllers and on views and the tests folder were almost empty How do you deal with these kind of things? Do you recommend any tools that can help me on code review or this is something that I have to do manually? I'm using PHP with Zend Framework.


How to design a good receipt number

I am developing a web application, this application will need to generate receipt number for every confirmed transaction. What is a good receipt number? I think a receipt number should not be just a running number generated by database, but it should have some meaning beyond just a unique running number. Here is what I have come up with so far,               Format: EYY-ddd-XXXXXXX     Example output: E13-146-0000001      Where: `E` : It is just a to signify this receipt number was generated by my system. This value is always `E`. `YY` : Is the current year the receipt was generated, so in this case it is `13` `ddd` : Is the day of the year, `146` is May 26 (in 2013). `XXXXXXX` : Is a 7 digit running number, up to 9,999,999 So my system can generate up to 10 million unique receipt numbers daily until 2099. What do you think? Is this sensible? Any suggestion is appreciated. **Update** Judging from the comments so far, it looks like there is no specific 'pattern' or 'best practices' for receipt number. My intention in asking the question is to know whether there is specific best practises in generating the number that I should know about. Looks like I am free to use whatever pattern I feel sensible. Other requirements   * As short as possible (that is why I didnt go for YYYYMMdd-XXXXXXX)   * Somewhat not to obvious (YYYMMdd is way to obvious).   * Should be fixed length. (Easier to detect if customer entered invalid receipt number)   * Can generate fairly large numbers (10 million a day seems sensible, though I doubt my system will be that popular)   * Can be made into QR code (so staff can scan and verify the number is valid)   * Someone mentions about **error detection code like ISBN** , seems good but I havent read it yet.


View Source - is the Viewable markup important to you?

I just read a very compelling blog post from Scott Hanselman where he quoted colleague Erik Meijer as follows: > JavaScript is an assembly language. The JavaScript + HTML generate is like a > .NET assembly. The browser can execute it, but no human should really care > what’s there. - Erik Meijer He goes on to give examples of how some of today's biggest sites (the one he shows is from Google+, but cites also Bing, Facebook, etc.) are producing sites where when you do a "View Source", you will see a lot of tight "minified javascript". Essentially, unreadable on the surface. Simply put, you cannot go into a site and look at their source and see a pretty formatted version of the markup. My question to you is similar to what Hanselman asks: is that important to you? If it works, is that good enough? In my opinion, YES - results are what matters - Google is an example of that. But I must admit, as a developer, it is nice to have the ability to, once in a while, look at the source and get ideas and examples from sites I admire. Your thoughts?...


Issue when Return Message is a collection of objects (Sequence Diagram)

I have a sequence diagram for the following operation. The Activity class uses method present in ActivityBL class. The method is: GetActivities(ActivitySearch objt) The result message is a collection of Activity objects. (Colletion in C#). How do we represent the return message in the sequence diagram? At present, I am listing it as message containing only one Activity object. How to represent it as a collection? ![enter image description here](http://i.stack.imgur.com/9Sja7.gif)


What is the name of a grammar which can change its tokenizer in mid parse?

I was creating a language and discovered that my language tokenizer would have to change depending where in the parse it is. I.e. `abc[1]` would be parsed as 4 tokens (`abc`, `[`, `1`, `]`), where as `{ abc[1] }` would be parsed as 3 (`{`, `abc[1]`, `}`). Is a grammar that would change its tokenizer mid parse defined somewhere? Does a grammar even define such a thing or is it irrelevant to the grammar and is just not really done on a parser level?


About anonymous objects

In Java particularly Android development, is there any difference between declaring an object like               SomeObject object = new SomeObject();     someField.setObject(object);      compared to an anonymous object (not sure if that's what is called)               someField.setObject(new SomeObject());      performance wise? Or improvements in memory. Thanks.


How do "You Ain't Gonna Need it" and "Now is better than never" play together?

I often find myself embracing "now is better than never" when I'm advancing the DRYness of a design. Typically, I find that I need to cultivate an understanding of the One Authoritative Location for a piece of knowledge in the context of a system of other pieces of knowledge. Thus, I tend to design the system 'now.' Conversely, this practice causes me to build fairly far in advance, despite a reasonable chance that I ain't Gonna Need It. How do these two patterns square up? What practices do you use to ensure that they play nice? How do you teach them together without creating confusion?


Passing variables from PHP to C++

I need to call a program from PHP and pass some vars and/or sets of key-value pairs to it. How do I pass these vars, through arguments to the called function? `exec("/path/to/program flag1 flag2 [key1=A,key2=B]");` Or is there a better method to achieve this? Somebody suggested to me to write them into a txt file and pass the path to it to as an argument instead, `exec("/path/to/program path_to_txt_file);` but I’m not to excited about this method.


Why are cons lists associated with functional programming?

I have noticed that most functional languages employ a singly-linked list (a "cons" list) as their most fundamental list types. Examples include CLisp, Haskell and F#. This is different to mainstream languages, where the native list types are arrays. Why is that? For CLisp (being dynamically typed) I get the idea that the cons is general enough to also be the base of lists, trees, etc. This might be a tiny reason. For statically typed languages, though, I can't find a good reasoning, I can even find counter-arguments:   * Functional style encourages immutability, so the linked list's ease of insertion is less of an advantage,   * Functional style encourages immutability, so also data sharing; an array is easier to share "partially" than a linked list,   * You could do pattern matching on a regular array just as well, and even better (you could easily fold from right to left for example),   * On top of that you get random access for free,   * And (a practical advantage) if the language is statically typed, you can employ a regular memory layout and get a speed boost from the cache. So why prefer linked lists?


Do first-class methods exist?

Okay, I know first-class functions are cool, closures even better, etc. But is there any language with first-class methods? In my mind, I see a first-class method as an "object" that has both a function pointer and a pointer to a specific instance of the class/object, but the implementation doesn't matter. I just want to know if there is _any_ language that uses them. And as a bonus, how were they implemented?


How agile methodologies can be applied in a typical " services " company?

My company is a custom software services company for external clientes, which means our typical project is one in which the contract already states the full budget of the project. Our typical project starts by defining requirements (improving the proposal high-level requirements), then we code the project, test it and ship it. We have an acceptance phase were the client tests the software and in that phase we can usually implement small changes asked by the client, or we charge extra for change requests. In some projects we have intermediate releases so the clients can check the progress of the project and give feedback on it. In summary: something like waterfall... I've followed the "agile" movement for a bit now and I always see it being a good match for a "product" company, or a company building software for an internal client. But are there good stories / advantages on using agile methods in my kind of company/projects? What are your experiences, what do you think about this?


What do people in IT consulting firms do? Ok I can guess they _consult_ , provide answers to questions, but exactly what kind of questions do they answer that it is even possible people will pay enough for them to sustain their company expenses?


Should I use Dependency Injection or static factories?

When designing a system I am often faced with the problem of having a bunch of modules (logging, database acces, etc) being used by the other modules. The question is, how do I go about providing these components to other components. Two answers seem possible dependency injection or using the factory pattern. However both seem wrong:   * Factories make testing a pain and don't allow easy swapping of implementations. They also don't make dependencies apparent (e.g. you're examining a method, oblivious to the fact that it calls a method that calls a method that calls a method that uses a database).   * Dependecy injection massively swells constructor argument lists and it smears some aspects all over your code. Typical situation is where constructors of more than half classes look like this `(....., LoggingProvider l, DbSessionProvider db, ExceptionFactory d, UserSession sess, Descriptions d)` Here's a typical situation I have a problem with: I have exception classes, which use error descriptions loaded from the database, using a query which has parameter of user language setting, which is in user session object. So to create a new Exception I need a description, which requires a database session and the user session. So I'm doomed to dragging all these objects across all my methods just in case I might need to throw an exception. How do I tackle such a problem??


Why we use virtual and override keywords in c#

Can anyone explain me what's the point of overriding base class implementations (if its not abstract), because it's not ethical move to modify features of the parent class according to the wishes of derived classes. The best way is to make the base classes abstract and carry on the inheritance chain. Whereas when designing a class hierarchy initially we gather or elicit all the essential requirements/features that should be belonged to a base class. Therefore, in a middle of a project we do not need to change base class implementations. According to my knowledge, base class implementation should be a constant. Thus, under this aspect, there's no real use of "override" keyword in c#. If it's not so please explain me with an example.


Future of a ServiceStack based Solution in the Context of Licensing

I just want someone to clarify the following questions as Demis Bellot had announced a couple of weeks ago that ServiceStack would go commercial. Refer link below. https://plus.google.com/app/basic/stream/z12tfvoackvnx1xzd04cfrirpvybu1nje54 (Please note that when I say ServiceStack or SS I refer to all associated SS libraries such as ServiceStack.Text, etc.)   1. If I have a solution already developed using ServiceStack today will I have to purchase a license once SS goes commercial even if I don't upgrade the SS binaries to the commercial release version?   2. Will previous versions of SS (prior to commercial licensing) always be opensource and use the same license as before?   3. If I fork SS today (prior to commercial licensing) on Github, would it be illegal to maintain that after SS goes commercial?   4. If the answer to question 2 is yes, then would I still be able to fork a previous version after SS goes commercial without worrying about the commercial license (all the while maintaining and releasing the source to the public)?


Is MultiTasking in a development environment worthwhile?

If we get assigned to do multiple works simultaneosly, is it good for growth for a developer? If there is a development project and if you are assigned to work on a maintenance project as well, is it good for the growth or will it inhibit the progress?


Saving critical data in (third party) databases

How do you save important(privacy-wise) user data like SSN, Credit Card Numbers and Addresses in databases? **Scenario:**   Only data which needs to be available is saved. For eg, SSN is saved because the app uses the SSN to identify a particular record. or credit card details are saved to make 1-click transactions possible.Some such data can be encrypted and saved, but some data needs to be available in plain text(eg. for full text search). The app uses third party hosting. **Questions:**   How secure is such data in plain text(or otherwise) on third party hosts like HostGator or App Engine? Do you save such data on third party hosts(and is this practice recommended)? Do you store it in plain text or do you encrypt such data? Should only those companies who have the resources to have their own servers proceed to build such apps?


How to represent a Rubik's Cube in a data structure

If I am attempting to simulate a Rubik's Cube, how would you create a data structure to store the cube's state in memory, with X number of tiles per side? Things to consider:   * the cube can be of any size   * it is a Rubik's cube, so layers can be rotated


In Search of Automatic ORM with REST interface

I have this wish that so far Google hasn't been able to fulfill. I want to find a package (ideally in PHP, because I know PHP, but I guess that's not a hard requirement) that you point at a database, it builds an ORM based on what it finds there, and exposes a REST interface over the web. Everything I've found in my searches requires a bunch of code--like, it wants you to build the classes for it, but it'll handle the REST request routing. Or it does database and relational stuff just fine, but you have to build your own methods for all the CRUD actions. That's dumb. REST is well defined. If I wanted to re-invent the wheel, I totally could, but I don't want to. Isn't there somebody who's built a one- shot super-simple auto-RESTing web service package?


Should injecting dependencies be done in the ctor or per method?

Consider:               public class CtorInjectionExample     {         public CtorInjectionExample(ISomeRepository SomeRepositoryIn, IOtherRepository OtherRepositoryIn)         {             this._someRepository = SomeRepositoryIn;             this._otherRepository = OtherRepositoryIn;         }              public void SomeMethod()         {             //use this._someRepository         }              public void OtherMethod()         {             //use this._otherRepository         }     }      against:               public class MethodInjectionExample     {         public MethodInjectionExample()         {         }              public void SomeMethod(ISomeRepository SomeRepositoryIn)         {             //use SomeRepositoryIn         }              public void OtherMethod(IOtherRepository OtherRepositoryIn)         {             //use OtherRepositoryIn         }     }      While Ctor injection makes extension difficult (any code calling the ctor will need updating when new dependencies are added), and method level injection seems to remain more encapsulated from the class level dependency and I can't find any other arguments for/against these approaches. Is there a definitive approach to take for injection? (N.B. I have searched for information on this and tried to make this question objective.)


Is something like coderunner possible on PC?

I'd give my firstborn's left arm for something like this http://krillapps.com/coderunner/ Yes, I know, executing unknown code may be hazardous to your health, but I'm quite capable of reading some code before I run it


Concurrent development w/o central design?

I've got a team of developers which are trying to write specifications/tests concurrently for different (and sometimes adjacent) parts of the system. Typically, the person writing the specification/test is **not** the developer who will write the implementation and make the specification/test pass. Here's the problem we're having: the person _receiving_ the specification/test for which an implementation hasn't yet been written isn't familiar enough with the design of the system's many objects to know: _Do I solve this problem (the specification/test) with an existing object(s), or do I create (for the first time) the dependencies which will allow the system to pass this specification/test?_ Not all of the developers on the project have the domain knowledge to make these decisions _well_ , and we're colliding so far as disparate designs and objects created in relative isolation begin to conflict and duplicate each other. What is the solution(s) to this problem? Is it simply inescapable that every developer in the project must know (or be prepared to ask) the system's objects? Feel free to provide what you think are obvious answers.


To go for scjp 6(now ocp jp 6) or oca jp 7?

I have been preparing for scjp 6 since 2 weeks. Now I came to know about the OCA JP 7 and OCP JP 7 exams. Should I start preparing for OCA JP 7 or go ahead with OCP JP 6(formaly scjp 6)? Also I am currently referring SCJP 6 by Sierra and Bates.


How long can it take for a screen to appear before it's considered a performance issue?

I am involved with the development of a Windows application that has various screens. One of them takes ten seconds to appear with no spinner or other indication that the screen is loading. I consider this a serious performance issue but I seem to be the only one who is concerned. Am I being overzealous? What is an acceptable amount of time to wait for a screen to appear?


Where should the description about branches in a VCS be stored?

If you maintain many branches in your favorite version control system it is essential understand which branch for which indented. In SVN you can put _README_ on same level as trunk/branches/features dirs. How about DVCS? You can maintain _ChangeLog_. But with this approach it is hard get breif view that done in all branches (if you maintain different long lived releases changelogs between them they can be slightly different). In open source project info about branches usually can be found on project wiki, so stored separately from VCS. I think this is bad thing. When you clone project you also need aceess to wikis.


Does LaTeX have a future outside of CS?

_with emphasis on outside of cs science students & staff_ In the "good ol' days" LaTeX was **it** ; mainly because of two reasons, first - it gave such a better quality document that nothing else came close, and second - there was pretty much nothing else as a valid alternative. _I'm talking 1985-1995 here._ And because of that, a major part of technical (or medicine, biochems., ... which have a logical way of thinking in them) users (people in general, in those professions) used it for their documents. It wasn't too hard to learn, and gave excellent results. Nowadays, however, _things are a changin_ , as old Dylan would put it. MS Word** for example as the most common one, is giving _quite a nice_ result, with a much higher gain/pain ratio. For most people, it is _good enough_. If one wants to create a document for which there is no LaTeX template, pros start to weight even more on Word's side. So, the question is this - do you think /and why - argument it/ LaTeX & co. has a future outside of cs sciences world (which users are inclined towards programming, and therefore usually take in LaTeX structure naturally, or at least with much less effort) given the recent trends? ** insert your favourite word processor; MS Word was taken just as an example p.s. This was inspired by one other question that came about recently, but also with the trend I noticed recently, but which has been going for a while now (past few years) that even technical magazines, which used to demand articles in TeX, now ask for them in .doc format (or ...).


Why it is `(cons 1 (cons 2 (cons 3 nil)))` and not `(cons 3 (cons 2 (cons 1 nil)))` for [1,2,3]?

Is there any special reason that to construct list in Scheme you use               (cons 1 (cons 2 (cons 3 nil)))      instead of               (cons 3 (cons 2 (cons 1 nil)))      ? While the first seems more obvious because it **reads** in the right order, the second is the one which actually **reduces** in the right order. Also, it seems more natural to construct a list starting with nil and adding elements to it, not the opposite. I've also found the latter has properties such as being very curry friendly: `(cons 1)` nicely becomes `a function that appends 1 to a list`.


What defines a good developer from an employer’s perspective?

Suppose the company who the developer starts at is a cooperative, team of 10-15 members. The company follows SDLC.   * **What qualities do you think an employer seeks in a developer?**   * **You are welcome to explain why the quality is important from employer’s point of view.** Here are some examples:   * Analytic / Logical / Critical / Questioning / Methodical   * Team player   * Responsible    * Social   * Problem solver


What features would you like to have in PHP?

Since it's the holiday season now and everybody's making wishes, I wonder - which language features you would wish PHP would have added? I am interested in some practical suggestions/wishes for the language. By practical I mean:   1. Something that can be practically done (not: "I wish PHP would guess what my code means and fix bugs for me" or "I wish any code would execute under 5ms")   2. Something that doesn't require changing PHP into another language (not: "I wish they'd drop $ signs and use space instead of braces" or "I wish PHP were compiled, statically typed and had # in it's name")   3. Something that would not require breaking all the existing code (not: "Let's rename 500 functions and change parameter order for them")   4. Something that _does_ change the language or some interesting aspect of it (not: "I wish there was extension to support for XYZ protocol" or "I wish bug #12345 were finally fixed")   5. Something that is more than a rant (not: "I wish PHP wouldn't suck so badly") Anybody has any good wishes? Mod edit: Stanislav Malyshev is a core PHP developer.


Architecture design with MyBatis mappers

I am creating rest web service for providing data. I am using Spring MVC for handling rest requests, and MyBatis for data access. Application should be designed in the way that it should be easy to change the data access implementation (for example to hibernate or something else) and it has to be fast (so I am trying to avoid unnecessary overcomplication of design). Now my question is about the general design of layers. I would normally use DAO interface and then different implementations for different data access strategies, but MyBatis uses interfaces to access the data. So I can think of 2 possible models but I am not sure which one is better or if there is any other nice way:   1. Controller layer - uses Service layer interfaces     * services are then implemented for each data access stretegy - for example for mybatis:     * service implementation uses Mapper classes to access data and do whatever it needs to do with them and sends them to controller layer   2. Controller layer - uses Service layer - service layer uses DAO interfaces     * DAOs are then implemented for each data access strategy - for example for mybatis:     * DAO class uses mapper interface to access data and sends them to service layer, service layer then do whatever it needs to do with them and sends them to controller layer I prefer the first strategy as it seems to be less complicated, but then I would have to write all of the service code for another data access again. What do you think? Thank You


Lending epub files for limited time to users

I am looking for components to build a digital library who lends people epub (ebooks) for about a week. It's like a digital version of the offline old public library. Now I have found several flash (pdf) file streaming solutions. But that would require an active internet link. And like the public library, you are able to take your books to the beach or pool on holiday abroad where you have no connection. So streaming is no option. The other file restriction method I have found was DRM, but that would require a really expensive license of Adobe Content Server 4 which is not suitable for my little hobby project. But it seems that adobe content server and Adobe Digital Editions is the only option at the moment. Or are there open source alternatives?


Create ASP.NET input forms from XSD?

I have several types of XML document. The format of (i.e. the elements in) each document type is defined in an XSD. Is there a convenient way to create HTML elements (or ASP.NET controls) on an ASP.NET form, to display/edit the elements in (contents of) an XML document, given the XML document and/or the document's XSD definition as input? Within the XML/XSD:   * Complex (i.e. parent) elements may contain sub-elements   * Simple elements are of type 'string', 'integer', 'list of string values', etc.: which should map to corresponding HTML input elements   * Elements are documented (labelled) using `<xs:annotation>` in the XSD (these would be suitable HTML `<label>` elements for the corresponding `<input>` elements).   * Each element is required, not required, and/or there may be several of them, specified using `minOccurs` and `maxOccurs` in the XSD As well as generating the ASP.NET form, when the user posts the completed form, the software should read the returned data and pack it into an XML document. How to do this? I can write software to parse the XSD and generate the forms myself but that seems like a lot of code to write in-house and maintain.


Is there a proper way to create a file format?

I'm building a proprietary file format for an application I wrote in C# .NET to store save information and perhaps down the line project assets. Is there a standard on how to do this in any way? I was simply going to `Serialize` my objects into binary and create a header that would tell me how to parse the file. Is this a bad approach?


Apply vs. Ok buttons

Often when configuring settings, applications have both an "Apply" and an "Ok" button. Should the "Ok" button always perform the "Apply" before closing the window out? Are there pros and cons to doing this?


Why do I need unit tests for testing repository methods?

I need to play devils advocate on this question a bit because I cannot defend it well because of lack of experience. Here is the deal, I get _conceptually_ the differences between unit testing and integration testing. When specifically focusing in on persistence methods and the repository, a unit test would use a mock possibly via a framework like Moq to assert that say an order searched for was returned as expected. Let's say I have built the following unit test:               [TestMethod]     public void GetOrderByIDTest()     {        //Uses Moq for dependency for getting order to make sure         //ID I set up in 'Arrange' is same one returned to test in 'Assertion'     }      So if I set up `OrderIdExpected = 5` and my mock object returns `5` as the ID my test will pass. I get it. I _unit tested_ the code to make sure what my code preforms returns the expected object and ID and not something else. The argument I will get is this: > "Why not just skip the unit tests and do integration tests? It's testing the > database stored procedure **and** your code together that's important. It > seems like too much extra work to have unit tests and integration tests when > ultimately I want to know if the database calls and the code work. I know > the tests take longer, but they have to be run and tested regardless so it > seems pointless to me to have both. Just test against what matters." I could defend it with a text book definition like: "Well that's an _integration test_ and we need to test the code separately as a unit test and, yada, yada, yada..." This is a case where a purist explanation of practices vs. reality is loosing out. I run into this sometimes and if I can't defend the reasoning behind unit testing code that ultimately relies on external dependencies, than I can't make a case for it. Any help on this question is greatly appreciated, thanks!


Command line merge conflict tools

I sometimes prefer to work in a terminal. I use git, and sometimes have merge conflicts. Are there any merge-conflict-resolution tools that work in a command-line only environment?


Drawing shapes dynamically on an image through web browser

We have a scenario where we create floor plans of locations when we visit. The floor plan is finally shown on the web. It's come to the point now where we want to show floor plans but have a key with various items on them, when an item on the key is clicked, the image should highlight all the areas of the floorplan that have that specific item. I guess we're looking for some sort of open standard javascript lib to deal with SVG (has to work pre IE9 so pure SVG wont cut it) and the floor plans have to be able to be created through a .net application to be deployed on the web. I'd rather stay away from flash if at all possible to be honest. Below are a few conceptual images of what we're trying to achieve. ![enter image description here](http://i.stack.imgur.com/gUBpc.png) ![enter image description here](http://i.stack.imgur.com/pGbCh.png) ![enter image description here](http://i.stack.imgur.com/ectLN.png)


In-memory DB to perform intersects on set slices

I have a specific programming need where I need to efficiently store large sorted sets in memory, query them for ranges, and intersect them against other sets that are also queried for ranged. I am looking at Redis, but I can't see a range slice command. MongoDB can only use 1 index, so it has to perform row-level scans, whereas I wish to process using columns that are intersected. I'm also looking at Counchbase, but can't easily determine from the documentation if it is suited to this. I know it uses Memcached, which is AFAIK not suited to this usage. Could anyone share potential solutions for this specific problem? **EDIT** For example, I need to perform the following: Get the IDs of all cars where the price is between 2000 and 3000, and intersect that will all cars where the engine capacity is between 3000 and 4000.