How to get familiar with "what happens underneath of Java"?

I did not study CS nor IT. I just became a developer, now working with Java. Actually, since I now work with a big company writing high-scalable web applications, I think I need to be better with details. I have no understanding of what happens underneath of Java. Java Performance, Server-Side Java might be the buzz words?!! I am very poor with those more of low-level details but I do not know where to look honestly. I started looking for some keywords in Amazon, ended up reading books like "pragmatic programmer", "clean code", "code complete" which IMO they are not what I am looking for. Could you please give me some learning resources (books, articles, blog posts, online trainings) for this matter? I also read this post as well: Approaching Java/JVM internals But I think I need a pre-step before jumping into the OpenJDK, right?!


What is the difference between dependent typing and contracts?

What is the difference between dependent typed languages and languages like Spec# and Eiffel that allow you to specify "contracts" for functions in your code for pre/postconditions? Is dependent typing basically the purely functional version of Eiffel's "contracts"? From what I understand, dependently typed languages let you specify your function's pre and post conditions using predicate logic as part of the type. Eiffel's concept of contracts seems to be similar, but based on imperative programming, not functional programming.


Core data syncing (deletion) using a custom REST web service

I need to sync my local core data stack against a server running a persistent data storage underneath the covers. (I've gone through other posts here and on SO on similar topics) My requirements:   1. One way syncing. Meaning my server is always updated and my clients just merely need to be fed incremental deltas which they feed into their core data stack.   2. The server could arbitrarily insert new records, modify existing ones or even delete them. I would rather not use RestKit because I can do the work of making queries and updating local state myself. I don't need an extra library to do this. My solution: I keep a last updated date (UTC) locally. I send this date to my server periodically and my server responds with the data I need to update or insert, based on a server timestamp for each record. **My problem:** I don't know how to handle deletes. How would I handle deletes in such a scenario? If I delete the record from the server, how will clients know to delete that record as well. Thoughts? I can think of a number of complicated ways to do it (e.g. don't really delete the record, or keep track separately of deleted records, etc.), but I'm looking for the simplest.


Why are pointers to literals not possible?

Reference to a literal is possible only if the reference is declared as constant. But why is a pointer to a const object not possible in case of literals? i.e.               int const& ref = 5;//      But why is the same feature not available for a pointer, pointing to a constant object?


Best practice for comments above methods in a grails application?

I'm writing a grails application and am not sure what the best practice is with regard to comments outside of method blocks. I've done a bit of research and there seems to be conflicting views on how and when these sort of comments should be used. In lots of source code I have seen there seems to be comments above every method detailing what that method does. I'm not sure if grails should be differnet? My question is should I have a comment above each method in my controllers, services and domain objects? i.e               /*     * This method displays the index page     */     def index(){     render view : "index"     }


Is it ever justifiable to write code without tests when doing TDD?

Is it ever justifiable to write production-code without also writing tests for it when doing Test Driven Development?


What are the most common mistakes and anti-patterns NHibernate user programmers make? Please explain why those are bad practices or give link to resource for further reading. **For example:**   * One anti-pattern common for new NHibernate programmers is to use identity/native POID's instead of ORM style onces. Read more here...


Is it a code smell if an object knows a lot of its owner?

In our Delphi 2007 application we are using a lot of the following constructs               FdmBasic:=TdmBasicData(FindOwnerClass(AOwner,TdmBasicData));      The FindOwnerClass travels the Owner hierarchy of the current component upwards to find a specific class (in the example TdmBasicData). The resulting object is stored in the Field variable FdmBasic. We use this primarily to pass datamodules along. Example: When generating a report, the resulting data is compressed and stored in a Blob field of a table accessed through a datamodule TdmReportBaseData. In a separate module of our application, there is functionality to show the data from the report in a Paged form using ReportBuilder. The main code of this module (TdmRBReport), uses a class TRBTempdatabase to convert the compressed blob data into different tables that are usable in the Reportbuilder runtime reportdesigner. TdmRBReport has access to TdmReportBaseData for all kinds of report-related data (type of report, report calculationsettings, etc). TRBTempDatabase is constructed in TdmRBReport but has to have access to TdmReportBasedata. So this is now done using the construction above:               constructor TRBTempDatabase.Create(aOwner: TComponent);     begin       inherited Create(aOwner);            FdmReportBaseData := TdmRBReport(FindOwnerClass(Owner, TdmRBReport)).dmReportBaseData;     end;{- .Create }      My feeling is that this means that TRBTempDatabase knows a lot of its owner, and I was wondering if this is some sort of code smell or Anti-pattern. What are your thoughts about this? Is this a code smell? If so, what is a better way?


Why do so many websites prefer "git rebase" over "git merge"?

One of the advantages of using a DVCS is the **edit-commit-merge** workflow (over **edit-merge-commit** often enforced by a CVCS). Allowing each unique change to be recorded in the repository independent of merges ensures the DAG accurately reflects the true pedigree of the project. Why do so many websites talk about wanting to "avoid merge commits"? Doesn't merging pre-commit or rebasing post-merge make it more difficult to isolate regressions, revert past changes, etc.? **EDIT:** Point of clarification: The default behavior for a DVCS **is** to create merge commits. Why do so many places talk about a desire to see a linear development history that hides these merge commits?


Design advice for building pluggable componentry in AngularJS

I'm currently working on a team that's developed several, extremely similar web applications in flash, and wants them ported into JavaScript. They also want a single application harness to host all of these applications, since they're all very similar. The application(s) are fairly standard. Each application consists of a set of selection/filter widgets, and a set of display(visualization) widgets. Selecting things in the "sidebar" will change what is displayed in the visualization area. Sometimes selecting things in the visualization area will affect what is in the selection/filter widgets. Both the set of selections, and the set of display widgets, may change from app to app, so they all have to be written to be pluggable. I've been working on this and have come up with the idea that a JSON based configuration file will be loaded into my next-gen application, and will essentially specify what the application will contain, and what interactions are permitted. I load an "application" file into my JavaScript application- harness, and that file tells my app what selections widgets to select from a set of pre-defined selection widgets (applications may share the same selections widgets). That's about as far as I've gotten as far as the implementation goes. it works, but I think the harder challenge lies ahead. Now I have to begin getting my display-visualization widgets working together, communicating with each other, and doing it in a way that's configuration based so that new applications can be created without writing any code for the client. My current plan is to define my display-visualization widgets in the same application file I currently define my selection widgets in, and for communication between these dynamically loaded components, I'll have a set of callback mappings from each selection widget to each display-visualization widget and vice-versa. Selection widgets will look through the file, see which functions they're supposed to call in an application-level namespace on certain events, and set those functions as callbacks for widget events. Display-Visualization widgets will do the same. So here are my questions:   1. Does this sound like a sane approach? Is there a better way to do something like this? Is there some kind of design pattern that people use in these situations that I might not be aware of?   2. I'm doing this in AngularJS, but I don't REALLY know AngularJS. I understand scoping, and some directives, but I'm very new to the framework, and I don't know what the AngularJS "way" of implementing this would be, so an angular-based design sketch would be very useful.  For instance, one thing that worries me is the design I have above is heavily based on eventing and callbacks, which I understand is really not the Angular way. On the other hand, many of the widgets (both types) cannot be angular. They'll be line graphs, data-grids, maps, bubble charts etc. I don't have the experience necessary to really understand how and whether my design should change based on my framework.


Why doesn't my IDE do background compiling/building?

Today I develop on a fairly complex computer, it has multiple cores, SSD drives and what not. Still, most of the time I'm programming the computer is leasurely doing nothing. When I need to compile and run/deploy a somewhat complex project at best it still takes a couple of seconds. Why? Now that we're living more and more in the "age of instant" why can't I press F5 in Visual studio and launch/deploy my application instantly? A couple of seconds might not sound so bad but it's still cognitive friction and time that adds up, and frankly it makes programming less fun. So how could compilation be instant? Well, People tend to edit files in different assemblies, what if Visual Studio/The IDE constantly did compilation/and building of everything that I modified anytime that it might be appropriate. Heck if they wanted to go really advanced they could do per-class compilation. The compilation might not work but then it could just silently do nothing (except adding error messages to the error window). Surely todays computer could dedicate a core or two to this task, and if someone found it annoying it could be disabled by option. I know there's probably a thousand technical issues and some fancy shadow copying that would need to be resolved for this to be seamless and practical but it sure would make programming more seamless. Is there any practical reason why this scenario isn't possible? Would the wear and tear of continually writing binaries be too much? Couldn't assemblies be held in memory until deployed/run?


Indexing data in C++. Could a constructor make a new entry if needed, or increment an existing one elsewhere in the larger object containing it?

I am indexing a file of key pairs, and counting number of appearances. The file goes: A B C A B A D E B F and so forth. Seems like a struct or object being pushed back into a vector is a good place to start, sortable on the first or second entry, etc. Once I have a relationship, A B or B A, I figure I can start counting when a pair is repeated, because what pairs with what and the frequency that they appear are the interesting thing I'm trying to find. If I had a very clever constructor for a class or struct containing the right hand entry and a count, I could have a meta object that looks like               struct entry     {       valueAndCount ID;       vector"<"valueAndCount">" pairsWith;     };       Which would then, itself, be used in a vector               class indexObj     {       vector"<"entry">" index;       bool exists( value );     };      In a given vector pairsWith pushback, if I gave the valueAndCount constructor a value, would it be proper for it to check if an entry for that value already existed? If not, go ahead and create a new one with count = 1. If it already exists, increment that (other) count, then free itself as redundant? Or is looking up from the instance constructor to the structure that contains it too messy?


Is it correct to keep version numbers of all components always the same?

We are planning to use a setup that uses several modules to complete a whole application, example modules include:   * The core (code shared by all other modules)   * The server   * The client (Windows, OS X, Linux)   * The client (iOS)   * The client (Android)   * Tool #1   * Tool #2 And now while we preparing to deliver our first release, it is a good time to think about the numbering scheme. We have defined to use a major.minor.patch format, but we are struggling about one question: **Should every module have the same version number as newest release, and consequently, should we bump version numbers if there has been no update to them?** Example to illustrate: 1) Assume all our components are running on version 0.1.0 (early development), once we do a significant update, should then all components be bumped to version 0.2.0? It also works the other way around: 2) Assume again every component is running 0.1.0 initially, and now we introduce a signifcant update (could be a GUI rework) on the Android client, should we then release a version 0.2.0 for _every_ component, even though the other versions have not received any update? And perhaps the most tricky one: 3) Assume that we still run 0.1.0 one very component in the start, and we figure out Tool #2 has a bug and we need to hotfix it to 0.1.1, should we also then update every component to 0.1.1? * * * I am currently doubting whether we should pursue correct versioning, or should go for compatability? People outside to the development team will most likely expect that all modules run on version 0.3.0 for example, while we as developers are a bit confused and perhaps feel uneasy with bumping a version number up, while the module did not have any change to it. What is the best way to deal with this? * * * **Edit** , something I have forgot to mention, but which may change opinions is that all releases will be done in automated way. On Github/git a specific commit will be tagged being version major.minor.patch and after that the build system (here: Travis CI) will pick up the tag and automatically build every release and publish it somewhere if necessary and/or wanted.


Design Patterns in Delphi

Delphi has a few problems implementing some design patterns because some features it lacks, like multiple inheritance and no pure abstract classes. Are there any good resources or "Adaptation-Patterns" to convert some or all of the Design Patterns in the GoF book, to Delphi applications?


Who organizes your MATLAB code?

After reading http://stackoverflow.com/questions/2326609/how-to-organize- matlab-cod, I had a follow up question. If you work in a group of MATLAB programmers, who enforces the organization of the shared MATLAB code and project matfiles? For example do you have a dedicated MATLAB IT person, or does the most senior programmer issue guidelines that everyone must follow, or does everyone agree to follow a system? In my small group, each person has their own 'system'. MATLAB code and project matfiles are either piled into a shared drive or tucked away on people's own computers. Hard to recreate work done by another person, or even to locate their code. There were lots of good suggestions on how to get organized. But it seems like someone has to make the trains run on time. Who does it in your group?


Better server to client communication mechanism over HTTP

I have a single server with several clients. I want to push messages to a particular client at a given time. Clients should not polling to the server. what are good patterns and practices to solve this problem?


Equating multiple new variables with an old one

Sometimes I run into a situation where I need to equate two new variables with an old one. Which of the following (if any) is a good practice (w.r.t. code readability or any other factor), under what conditions?               a=b;     c=b;      or               a=b;     c=a;      Note, `a`,`b` and `c` are just the names chosen in this example.


why is len not a reserved keyword in python

why is functions like **`len`** and **`max`** not a reserved keyword in python. Following are the only reserved words http://docs.python.org/2/reference/lexical_analysis.html#keywords


How to synchronize client and server model objects?

We have a client-server application with a thick client (GWT). There are client-side MVP presenters (MVC controllers) which hold references to some objects viewed in the GUI. Some user actions cause these objects to be updated on the server. After that we can send updated objects back to the client and reassign them to the presenter. The problem is that there are usually a few references to an object on the client (Lists, HashMaps, etc.) and it is hard to update all of them. Another approach is not to update the references but update the object itself, e.g. copy all the properties from the server object to the client one. But if an object is complex it is not easy too. Which approach is better? Or maybe I miss something?


How do libraries such as DirectX relate to drivers?

I've always been curious, how libraries such as DirectX, OpenGL and OpenAL are implemented. Do they use some sort of unified API provided by OS? Talk directly to kernel? Maybe hardware drivers provide unified API? Or vendors provide their own backends to such libraries? Even entire implementations of such libraries? Or such libraries handle different drivers on their own?


Is doing an assignment inside a condition considered a code smell?

Many times I have to write a loop that requires initialization of a loop condition, and an update every time the loop executes. Here's one example:               List<String> currentStrings = getCurrentStrings();     while(currentStrings.size() > 0) {       doThingsThatCanAlterCurrentStrings();       currentStrings = getCurrentStrings();     }      One things I dislike about this code is the duplicate call to `getCurrentStrings()`. One option is to add the assignment to the condition as follows:               List<String> currentStrings;     while( (currentStrings = getCurrentStrings()).size() > 0) {       doThingsThatCanAlterCurrentStrings();     }      But while I now have less duplication and less code, i _feel_ that my code is now harder to read. On the other hand, it is easier to understand that we are looping on a variable that may be changed by the loop. What is the best practice to follow in cases like this?


What is the word to describe languages that have classes and inheritance?

What is the word used to describe the type of programming languages that provide explicit syntax for defining classes and that support inheritance? For example: "A ______ language, such as C++, Java, C#, or D." I keep thinking "object oriented", but that also includes languages like Lua and JavaScript, which aren't quite what I'm thinking of. I am sure there is a definitive term for this group of languages, I just do not know what it is.


Do system background services affect languages benchmarking?

Today I was looking at some blogs on Ruby and Python. A Python loyalist wrote a few lines of code with a loop to show how Python is faster than Ruby, with a similar code. I also found a blog of a Ruby disciple who says that it is wrong and he too submitted a code sample and benchmarking results. I am wondering whether background programs or background processes may sometime hinder the results and we may not get exact benchmarking scenario. Please correct me if I am wrong.


I'm in charge of managing mobile application development at my company, and I am currently building a mobile device "library" for testing. Essentially, we want to have a representative device in-house for each of the OSes we are developing for, currently iOS (iPhone-only), Blackberry, and Android. Simulators only go so far, but I'm placing into the process a step to test software on the devices themselves. The problem we're finding is with Android. I don't think any of us here ever really understood just how fragmented the whole platform is until we started looking at devices to acquire. We are going to wait until v2.3 of Android is released, but which products to choose? Do we go by the most popular by market share? Do we get a small range of products by specs from least to most powerful overall? We're trying to avoid having to manage a dozen different devices to test each app, if not because of cost if only for the repeated time sink. How do you manage the testing of your Android software on physical devices? UPDATE: To bring some context to what I am asking, the applications being created are for educational purposes only, and there are no plans to use any of the hardware features of the devices themselves. We are simply displaying content in a variety of ways: eBooks, test questions, flash cards, etc. that may or may not be downloadable content. So, no cameras, GPS, user-driven content management, or anything like that; just as device-agnostic as we can possibly make it.


Scala as a language for Generic Programming

In the paper “An Extended Comparative Study of Language Support for Generic Programming” by Garcia et al. an interesting comparison of programming languages features for generic programming is given: ![enter image description here](http://i.stack.imgur.com/8kNzR.png) with the brief explanation of terminology: ![enter image description here](http://i.stack.imgur.com/LuQLi.png) Can anyone test Scala support for generic programming inside this framework? I.e. add a column in the first table with explanations if possible.


Security issue about making my code public in GitHub

I'm developing a big community/forum website and I'd like to upload my code to GitHub to have at least some sort of version control over it (because I have nothing other than a .rar file as a backup, not even SVN), to let others contribute to the project, and also perhaps using it to let my potential future employers see some of my code as some sort of curriculum. But what I'm wondering now, and I'm suprised I haven't seen anyone mention it before is the security aspect of it. Isn't publishing the code of a website a **_HUGE_** security hole? Is like giving a potential hacker or anyone who would like to find any potential exploit possible, even considering that the critical files aren't uploaded (database passwords, authentication scripts, etc.). Of course that there are millions of projects uploaded to GitHub and no one will find mine just 'by chance'. But if they look for it, it would indeed be there. Bottomline: my problem is not about copyright or licenses, but others finding exploits in my website. I'm I missing something here?


Is it appropriate to run a complex enterprise-system configuration and migration project in a similar way to a Scrum development project?

I'm just starting out on the implementation of a large enterprise-wide system, which has complex requirements and many stakeholders. The company has been through high-level evaluation and tender process and determined to purchase a highly configurable "off-the-shelf" product rather than building an entirely bespoke system. The system will replace several existing systems and will require a significant amount of data migration. I'm thinking that the implementation of this system (which is expected to take over 2 years) could be run in a similar way to a Scrum software development project. With the first sprints targeted at building the minimal possible functionality needed (across all functional areas), and then iteratively deepening the level of functionality according the stakeholder feedback. I think this will de-risk the project and help ensure a balance of stakeholder needs within the available time. The user stories are still the same, it's just that to implement them we have work within the constraints of the pre-purchased system. When it comes to 'building stuff', instead of writing custom code the team will be configuring the off-the-shelf package, writing data conversion scripts and the like (and it should be a lot quicker!). Does this sound like a sensible approach? Does the Agile approach makes sense here?


How to improve efficiency with functional programming?

I've recently been going through the Learn You a Haskell for Great Good guide and as practice I wanted to solve Project Euler Problem 5 with it, which specifies: > What is the smallest positive number that is evenly divisible by all of the > numbers from 1 to 20? I decided to first write a function determining whether a given number is divisible by these numbers:               divisable x = all (\y -> x `mod` y == 0)[1..20]      Then I calculated the smallest one using `head`:               sm = head [x | x <- [1..], divisable x]      And finally wrote the line to display the result:               main = putStrLn $ show $ sm      Unfortunately this took about 30 seconds to finish. Doing the same thing with the numbers 1 to 10 yields a result almost immediately, but then again the result is much smaller than the solution for 1 to 20. I solved it earlier in C and there the result for 1 to 20 was also calculated almost instantly. This leads me to believe I'm misunderstanding how to interpret this problem for Haskell. I looked through other people's solutions and found this:               main = putStrLn $ show $ foldl1 lcm [1..20]      Fair enough, this uses a built-in function, but why is the end result so much slower when doing it yourself? The tutorials out there tell you how to use Haskell, but I don't see much help with transforming algorithms into fast code.


How to remove duplicate exception block code

I have good number of Service and DAO classes which has the same set of 30 line exception code block which gets repeated and it shows up in Code Duplication report. The approach which i can think of is to   * Extract the common exception code block to a common method and call   the method in one shot Re-organize the methods to ensure there is always one entry and exit point to Services or DAOs which will have just one set of exception code. Are there any better ways to approach this scenario?


generic chaining technique for overloaded method

A common operation in JavaScript is to replace an object method with a new one while still calling the original method. This is often done like this:               var originalMethod = obj.method;     obj.method = function(arg) {         // call original method         originalMethod.call(this, arg);         // do my stuff new stuff     }      I'd like to create a utility function for a specific object method that handles the chaining part so that the user doesn't need to be concerned about it. One option is to use the above design, in which each added function is wrapped in a new function that calls the previous one. Another option is to create an array of functions and make the object method just iterate over the array, calling each function in turn.               function addXyzMethod1(fn) {         if (obj.method) {             var previousMethod = obj.method;             obj.method = function(value) {                 value = previousMethod.call(this, value);                 return fn.call(this, value);             };         } else {             obj.method = fn;         }     }          function addXyzMethod2(fn) {         if (obj._methodList) {             obj._methodList.push(fn);         } else if (obj.method) {             obj._methodList = [obj.method, fn];             obj.method = function(value) {                 for (var i = 0, n = obj._methodList.length; i < n; i++) {                     value = obj._methodList[i].call(this, value);                 }                 return value;             };         } else {             obj.method = fn;         }     }      At this point, I can't decide which method to use since I feel the trade-offs of each are about even. So my question here is: Which of these method is better (more natural, or accepted, or quicker) or is there another method that improves on both of these?


Branching breaks continous integration?

I think this article, A Successful Git Branching Model, is very well known among experienced DVCS users. I use `hg` mostly, but I would argue this discussion is fine for any DVCS. Our current workflow is each developer clones the master repo. We write code on our own local repo, runs tests, and if all goes well pushes to the master. So we want to setup CI servers like Jenkins and improve our workflow with the future provisioning system (chef, puppet, ansible, etc). **Real part** Well, the model presents above works nice but branches can break CI. The feature branch should sync with the origin (according to the article, it would be `development` branch) to make CI and merging smooth, right? Say Alice and Bob are working on two features. But Alice is done the next day. Bob's feature takes a week. By the time Bob is done, his changes are out of dated (maybe Alice refactored/rename some classes). One solution is each morning developers must pull `master/origin` to check if there's any changes. If Alice commited, Bob should pull and merge into his workspace so his feature branch is up-to-date.   1. Is this a good way?    2. Should these branches exist in the master repo (not local clone?) Meaning should every developer has commit privilege to the master repo on GitHub/Bitbucket so they can create a new branch? Or this is done locally?   3. Lastly, the model presents by the article should break CI if branches are not sync with the `origin/master`. Since we want to do nightly build, should developers pull and merge before they leave work, and have CI runs on each feature branch as well? Thanks.


Re-writing a large web application - alternatives to LAMP

We have a very large, 10 year old LAMP (Linux, Apache, MySQL, PHP) web application that is out of control and poorly written due to a large number of patches and possible hundreds of programmers. If we were to do a re-write, what are alternatives to the LAMP stack? One of the reasons behind LAMP was that it's easy to develop and cheap. Now the company can afford to spend more time/effort/money on a new system. I thought about Java or C++ with Oracle? Is there a common 'Enterprise' stack companies use? Many thanks.


If I were to build a website just like this one for programming practice, what specific knowledgebase would I need?

I learned C++ in college (now we are moving to Java.) On the side I learned basic scheme, php and javascript. However my knowledge is basic enough that I wouldn't even know how to start building a website such as this. The reason I ask is I want to further develop my web-development skills/knowledge by doing a project and I REALLY love the design of this website so I thought I could build a variant of it. Can someone point me to guides or what I need to learn next to start moving in that direction? Thanks!


What are some good ways to represent relationship among three numbers

I'm trying to find a clean, intuitive way to implement this problem. Basically, I have three numbers, and based on relationship (less than, greater than, and equal to) among these numbers would change how I execute the next set of code. For example, if there are numbers A, B, and C. Here are some examples of relationships among them:   * A < B < C   * A = B > C   * A = B = C   * B < A = C A consumer of my framework would build this kind of relationships between the three numbers and would pass into a class that would process the relationships. So far, I could think of one way to implement that is relatively simple but not clean. I would represent relationships between the three numbers in flags. So, there would three different flags (A to B, B to C, and A to C). Each flag would have LessThan, EqualTo, and GreaterThan options. I would have to run through many checks to make sure that the 3 given flags are valid. If A < B and B < C, then A cannot be greater than C. If A = B and A < C, then B cannot be greater than C. The list goes on. Is there a better way to design this?


What are the good practices for including namespaces in C++ that avoid more typing?

I am starting out with C++ and almost everywhere I see there is these 2 sentences at the top.               #include <iostream>     using namespace std;      As I understand namespaces are something to keep names separate and have same identifiers in different namespaces. So isn't including `std` in the beginning undoing all the hard work of creating namespaces? Isn't it better to have something like `std::cout` when I need a certain function from a particular namespace? Would including the namespace in the particular function that uses it a good tradeoff between less typing (`std::cout` vs. `cout` everywhere) and avoiding the name conflicts(abc in foo and abc in bar avoided using `foo::abc` and `bar::abc`)? Something like               int function_using_abc_namespace(int a)     {         using namespace abc;         //Rest of the function     }      I wanted to know because avoiding name conflicts is necessary but avoiding more typing is also important. If this isn't good way to get a middle ground then what are the alternatives?


Face Recognition(OpenCV) with MySQL and PHP

First of all I have asked this question on stackoverflow and got down vote for question being not belonging to the site. I am trying my luck se now(more suitable to se I guess) and I hope I will not get down vote from here too I want to develop a face recognition app that searches the database for an image. I looked at opencv a little. I really liked it and I want to use it but the problem is I am planning to use PHP for server backend and OpenCV is in C++. My app will require lots of communication between PHP and C++ and also I will have to connect to the database and fetch images from them. Basically what I am planning to do is :   * PHP will get the request which includes the desired image file   * PHP will pass this image to my C++ code   * C++ will search the database to find the person   * C++ will pass the result to PHP   * PHP will return the result to client However this approach makes me really scared because there are lots of gray areas for me to how to do it. Should I use sockets to do the communication or IPC (POSIX Messages etc if possible) or should I use entirely C++ for my project(C++ server could be very difficult) or should I use PHP extensions(I know almost nothing about it). How can I use OpenCV with a Database and how can I perform a fast search(Hash values for grayscale cropped images maybe?). I also have to detect faces to train some images for a user which also requires the steps above. What are the suggestions you can make? Which way would be easiest for me to implement this application? Excuse me for the language and disorganized structure question but I am really worried about almost everything about the project and I really want to do it. Any guidance will be appreciated


When there are multiple scrum teams, how often should the 'scrum of scrums' meet and who should attend?

When there is too much work for one scrum team to manage, multiple teams are created. A scrum team has a stand up meeting everyday. How often should the intra-scrum team meeting occur and who should attend? What should they talk about?


Algorithm to Copy data faster than windows default copy provider

I need an algorithm which can copy data(files/folder) from one place to another, faster than windows default copy/paste option. I'm working in vc++. Is there any algorithm by which I can do copy/paste faster.   Or _Is there is any other suggestion to perform this task?_   Thanks


Workflow Foundation to seperate data from business logic on a mid-sized App?

We are currently developing a .net app in WPF, that will be a desktop app with a good bit of data-access to local (and some remote) servers. The business logic here is very complex, and currently it is built into the code along with the data access and whatnot (being WPF the UI is seperated pretty nicely).      Now I have been tasked with reorganizing this system to make it more maintainable in the longrun as certain logic changes. I know that workflows are supposed to seperate the logic out pretty nicely and allow you to visualize it a bit. Is workflow a good choice for an app that does not need to be run over long periods? (since workflows CAN wait in idle for months) What has been your experience with the platform? Is it slow for dealing with a mid- sized company; around 150 simultaneous users? If you liked it, do you know of any good online tutorials(preferably not MSDN) that can give me a taste for the platform and do some testing before I commit to implementing it on a huge app?


What is the difference between Callback<T> and Java 8's Supplier<T>?

I've been switching over to Java from C# after some recommendations from some over at CodeReview. So, when I was looking into LWJGL, one thing I remembered was that every call to `Display` must be executed on the same thread that the `Display.create()` method was invoked on. Remembering this, I whipped up a class that looks a bit like this.               public class LwjglDisplayWindow implements DisplayWindow {         private final static int TargetFramesPerSecond = 60;         private final Scheduler _scheduler;              public LwjglDisplayWindow(Scheduler displayScheduler, DisplayMode displayMode) throws LWJGLException {             _scheduler = displayScheduler;             Display.setDisplayMode(displayMode);             Display.create();         }              public void dispose() {             Display.destroy();         }              @Override         public int getTargetFramesPerSecond() { return TargetFramesPerSecond; }              @Override         public Future<Boolean> isClosed() {             return _scheduler.schedule(() -> Display.isCloseRequested());         }     }      While writing this class you'll notice that I created a method called `isClosed()` that returns a `Future<Boolean>`. This dispatches a function to my `Scheduler` interface (which is nothing more than a wrapper around an `ScheduledExecutorService`. While writing the `schedule` method on the `Scheduler` I noticed that I could either use a `Supplier<T>` argument _or_ a `Callable<T>` argument to represent the function that is passed in. `ScheduledExecutorService` didn't contain an override for `Supplier<T>` but I noticed that the lambda expression `() -> Display.isCloseRequested()` is actually type compatible with both `Callable<bool>` **and** `Supplier<bool>`. My question is, is there a difference between those two, semantically or otherwise - and if so, what is it, so I can adhere to it?


Solving a probabilistic problem

So I am interested in Computational Investing and came across this problem on a wiki page: > Write a program to discover the answer to this puzzle:"Let's say men and > women are paid equally (from the same uniform distribution). If women date > randomly and marry the first man with a higher salary, what fraction of the > population will get married?" I don't have much knowledge in probability theory, so I'm not really sure how to implement this in code. My thinking:   1. Populate two arrays(female,male) with random salary values from a uniform distribution.    2. Randomly pair one female and one male array element and see if condition of higher salary is met.   3. If it is, increment a counter.   4. Divide counter by population and get percentage. Is this the correct logic? Do woman continually date until there is no males left with higher salaries than women?


Strategies for Indexing Custom Fields in RavenDB

In the relational database world, if I was developing a CRM system and wanted to have the user add their own custom fields that are searchable, I could have tables that store the name of the new column, the data type and the value, etc. (which would be less inefficient to index) or I could use the less elegant (but more searchable) solution that software like Dynamics and SharePoint use, whereas I create a load of columns on my aggregate root called CustomInt1, CustomInt2, etc. (which looks dirty and has a limit of how many custom fields a user can have, but has indexing advantages). But my questions is this, in NoSQL databases, what would be the best way of achieving the same thing? My priority would be for searchability. So what would be the best way to store this data? If I used a predefined set of properties (i.e. CustomData1, CustomData2, etc.), because these are all stored as JSON (i.e. strings) in the database, does this make it simpler because I don't have to worry about data types?


Overloading methods that do logically different things, does this break any major principles?

This is something that's been bugging me for a bit now. In some cases you see code that is a series of overloads, but when you look at the actual implementation you realize they do logically different things. However writing them as overloads allows the caller to ignore this and get the same end result. But would it be more sound to name the methods more explicitly then to write them as overloads?               public void LoadWords(string filePath)     {         var lines = File.ReadAllLines(filePath).ToList();              LoadWords(lines);     }          public void LoadWords(IEnumerable<string> words)     {         // loads words into a List<string> based on some filters     }      Would these methods better serve future developers to be named as `LoadWordsFromFile()` and `LoadWordsFromEnumerable()`? It seems unnecessary to me, but if that is better what programming principle would apply here? On the flip side it'd make it so you didn't need to read the signatures to see exactly how you can load the words, which as Uncle Bob says would be a double take. But in general is this type of overloading to be avoided then?


Multiple Instantiate of 1 class affects memory?

I am currently struggling with memory handling. I have an if statement and each `case` instantiate a new object from a class. Does this affect the memory allocation in java?               switch()     {     case 1:     test t1 = new test();          case 2:     test t2 = new test();          case 3:     test t3 = new test();          case 4:     test t4 = new test();          case 5:     test t5 = new test();          case 6:     test t6 = new test();          }


Who controls the npm registry?

NPM's docs say that anyone can call `npm-publish` and add his own NPM package to the "official" registry. Who controls this registry? How reliable is it for production deployment scenarios? What's preventing people from spamming this registry? Is there any moderation/QA process?


What is a reasonable way to structure relationships in MongoDB

I am also using Node - which I am not the most familiar with - if the articles/books/tutorials pertained to this also - that would help even more. I come from a mostly MySQL background - but in this api, all data is going to be served as JSON - so at first glance, using Mongo made a lot of sense (I could be wrong). One thign I have been unable to wrap my head around though, is relational models. e.b. `Object has many Assets`. To use some examples most people would be familiar with, let's assume I am trying to do something like:   * Select a blog post and all of its comments. **or**   * Select a photo gallery and all of its photos Is it as simple as storing a call back inside of my assets like this?:               Photo {         __id: 5,         content: '...',         gallery_id: 9      }      And performing a `.find({ gallery_id: 9 })`? I know this would _work_ , but is that best practice? I am **very** new to Document Databases, and have not seen much on this particular topic.


Has Javascript developed beyond what it was originally designed to do?

I've been talking with a friend about the purpose of Javascript, when and how it should be used, etc. He quoted that: > JavaScript was designed to add interactivity to HTML pages > > [...] > > JavaScript gives HTML designers a programming tool > >   * HTML authors are normally not programmers, but JavaScript is a scripting > language with a very simple syntax! Almost anyone can put small "snippets" > of code into their HTML pages JavaScript can react to events >   * A JavaScript can be set to execute when something happens, like when a > page has finished loading or when a user clicks on an HTML element > JavaScript can read and write HTML elements >   * A JavaScript can read and change the content of an HTML element > JavaScript can be used to validate data >   * A JavaScript can be used to validate form data before it is submitted to > a server. This saves the server from extra processing >   * JavaScript can be used to detect the visitor's browser - A JavaScript > can be used to detect the visitor's browser, and - depending on the browser > - load another page specifically designed for that browser. >   * JavaScript can be used to create cookies - A JavaScript can be used to > store and retrieve information on the visitor's computer. > However, it seems like Javascript's getting used to do a lot more than these days. My friend also advocates against using Javascript's OOP functionality, claiming that "you shouldn't be processing data, merely validating." Is Javascript really limited to validating data and making flashy graphics on a web page? He goes on to claim "you shouldn't be attempting to access databases through javascript" and also says " in general you don't want to be doing your heavy lifting in javascript". I can't say I agree with his opinion, but I'd like to get some more input on this. So, my question: Has Javascript evolved from the definition above to something more powerful, has the way we use it changed, or am I just plain wrong? While I realize this is a subjective question, I can't find any more information on it, so a few links would be good, if nothing else. I'm not looking for a debate, just an answer.


Higher coding standards for dynamic languages?

Due to the inherent risks associated with using dynamic languages (e.g. Python, Ruby) carelessly, what (if any) standards should be imposed on production code written in these languages?


How is a software backdoor implemented?

The wikipedia article on Limewire says that "LimeWire 5.5.11 and newer have been disabled using a backdoor installed by the company". How are such backdoors implemented? Is it as simple as the the program going out and checking a web service and disabling itself? If it's in fact so simple, it has to be stored somewhere on the user's drive (in a plist, or in the registry for example). It's hard to imagine no one has in fact figured out a way to turn that flag off and use the program.


What should I "forget" when going to Javascript?

I went from C=64 Basic and assembler to FORTRAN and C to C++ and Java. Professionally I started in Visual Basic for applications then to Visual Basic 4, 5, 6. After that VB.NET AND C# with some Java here and there. I have played with Ruby and Python and found both fun. During each step I never felt like I had to forget what I had learned before. I always felt like I was just learning better and/or _slightly_ different ways of doing things but the difference was not major. The difference was like the difference between American, Australian and British English. (Maybe assembler was Latin and FORTRAN was Spanish.) But now I am using JavaScript to do real, actual work. (Before used it as a "Scripting" language pure a simple.) And I just feel like I have to forget some things to become proficient in it. It feels like some old Egyptian language. What should I forget? Is it just that code organization is different (no real classes so no one class one file)? Or is it something more basic? *Edit. Even though closed I think the few answers provided have been very helpful. I thought about it today and looked at, and wrote, some code. I may be wrong but I think the major things are:   1. Scope is not to be so tightly controlled or maybe it can't be as tightly controlled? Anyway I can't think of scope in JavaScript as I do in class based system. I have to forget those ideas.   2. Classes/Interfaces are not the basic unit of functionality. Not sure what is the basic unit actually is yet (the function? the prototype? TBD) but at least I know not to try to think about classes. (This is probably the basic one.)


Is it important to obfuscate C++ application code?

In the Java world, it seems to sometimes be a problem, but, what about C++? Are there different solutions? I was thinking about the fact that someone can replace the C++ library of a specific OS with a different version of the same library, but full of debug symbols to understand what my code does. IS tt a good thing to use standard or popular libraries? This can also happen with some dll library under Windows replaced with the "debug version" of that library. Is it better to prefer static compilation? In commercial applications, I see that for the core of their app they compile everything statically and for the most part the dlls (dynamic libraries in general) are used to offer some third party technologies like anti-piracy solutions (I see this in many games), GUI library (like Qt), OS libraries, etc. Is static compilation the equivalent to obfuscation in the Java world? In better terms, is it the best and most affordable solution to protect your code?


How to manage Agile developers working with traditional (serial) business persons?

Good afternoon, My work environment has some problems. Our IT team is trying to be more agile, but we're not really getting buy-in from the business. They attend our daily stand-ups and sprint reviews, and they help with sprint planning, but then they turn around and do 4 months of requirements gathering for a project before moving forward with a (mostly) serial development style. The sprint goals are things like "get XX% closer to release". For the IT team, they've turned the Sprints into a sort of death march. We end a Sprint one day and start a new Sprint the very next day. There's no reflection or changes done between sprints, only during. Having never done any of the agile methodologies before, I haven't had a very pleasant introduction to them. So my questions are: 1) Should there be some time (perhaps a week or so) between sprints to do the reflection/introspection/changes/etc.? Or are back-to-back-to-back sprints the norm? 2) Is there any chance for survival for an agile team with no agile business counter-parts? If not, are there some transitional methodologies or even tips for moving the business towards an iterative if not necessarily agile mindset? 3) Should your entire team be on every sprint? We have almost 20 programmers on a single sprint but working on completely different projects (typically teams of 3-5, sometimes larger). Is it normal to have a single sprint or should we be trying to manage multiple independent sprints? Should we be trying to keep the multiple sprints in concurrent lockstep or should their timetables be allowed to overlap and be flexible? Any thoughts or advice is appreciated. This is my first time coming over from SO for a question, so please let me know if there are better ways to phrase these kinds of questions (faq was rather helpful, but still not sure I'm following it perfectly). Thanks!


Undefined behavior, in principle

Whether in C or C++, I think that this illegal program, whose behavior according to the C or C++ standard is undefined, is interesting:               #include <stdio.h>          int foo() {         int a;         const int b = a;         a = 555;         return b;     }          void bar() {         int x = 123;         int y = 456;     }          int main() {         bar();         const int n1 = foo();         const int n2 = foo();         const int n3 = foo();         printf("%d %d %d\n", n1, n2, n3);         return 0;     }      Output on my machine (after compilation without optimization):               123 555 555      I think that this illegal program is interesting because it illustrates stack mechanics, because the very reason one uses C or C++ (instead of, say, Java) is to program close to the hardware, close to stack mechanics and the like. However, on StackOverflow, when a questioner's code _inadvertently_ reads from uninitialized storage, the most heavily upvoted answers invariably quote the C or C++ (especially C++) standard to the effect that the behavior is undefined. This is true, of course, as far as the standard goes--the behavior is indeed undefined--but it is curious that alternate answers that try, from a hardware or stack-mechanical perspective, to investigate why a _specific_ undefined behavior (such as the output above) might have occurred, are rare and tend to be ignored. I even remember one answer that suggested that _undefined behavior_ could include reformatting my hard drive. I didn't worry too much about that, though, before running the program above. My question is this: _Why is it more important to teach readers merely that behavior is undefined in C or C++, than it is to understand the undefined behavior?_ I mean, if the reader understood the undefined behavior, then would he not be the more likely to avoid it? My education happens to be in electrical engineering, and I work as a building-construction engineer, and the last time I had a job as a programmer _per se_ was 1994, so I am curious to understand the perspective of users with more conventional, more recent software-development backgrounds.


Does learning a functional language make a better OOP programmer?

As a Java/C#/C++ programmer I hear a lot of talk about functional languages, but have never found a need to learn one. I've also heard that the higher level of thinking introduced in functional languages makes you a better OOP/procedural language programmer. Can anyone confirm this? In what ways does it improve your programming skills? What is a good choice of language to learn with the goal of improving skills in a less sophisticated language?


Properly design program database to reflect organization structure

I'm having trouble setting up my program's database the 'right' way. I was hoping you guys could give me suggestions on doing it properly. I am creating a database+client for a non-profit organization that runs all across Canada. I'll describe how it works below to give you guys a better understanding of what I'm trying to do. ## First off, What are you using? - - - - - > ** _Laravel_** I've started to create it already with a web based (PHP with **_Laravel_** , HTML, CSS [bootstrap]) frontend and a MySQL based backend. ## How the organization is setup? Currently the organization I am making this database for has 3 main tiers; Main Management ({MM}) > Sub-Management ({SM}) > and Local ({L}). {MM} has multiple {SM}, {SM} has multiple {L}.   ![Diagram of Org. Structure](http://i.imgur.com/kqurrsW.png)   Currently I am focusing on the _last 2 tiers_ , {SM} and {L}. {SM} makes sure {L} is running properly and {L} regularly submits different paperwork and reports to {SM}. ## What kind of data do you need to keep track of? I am looking to store some Personal information; address, email phone, etc. As well as class/instruction results (marks included). Some inventory management (who has what, very simple). Some positional information (who has what job). And some Attendance info (Who did what, where, for how long). ## So what's your actual question? Currently, I am assigning every {L} an id and using that as a foreign key in all the inventory/personnel/positional tables, but it's getting ridiculous to do the 'where' call everywhere in my queries; tough to keep track of when doing more complex queries.   I was wondering if it would be better to _separate_ each {L} into it's own database and access each depending on which user is logged in? I'm not sure what would be best or what is accepted as best practice. I could **really** use your help! I've been having a **lot** of fun so far learning laravel and amazed at the features it has to offer. **Thanks so much for any and all suggestions,   Chris** **If you need a better explanation or have any questions please ask!** **Edit:** Sorry, I thought about this after... I also (probably) want to be able to allow different members of different {L}s to communicate or transfer member/information between {L}s. Would this be more difficult if they were split up? Maybe I should keep everything together in one database? Yeah. I'm just lost and confused... :)


Encoding issues from MySQL database to PHP page

So I've been working on a small, small side project to learn a bit more about PHP database interactions. I bought a small, cheap database of "Inspirational Stories" and set to work on turning it into a web site that no one will ever remember. :P I've worked out a number of issues so far and learned a fair bit, however, one issue that I can't seem to pinpoint is issues with entities. I'm not entirely sure if this issue is arising from the initial database encoding, or perhaps I'm pulling in the data wrong from the database, or something... I'm not quite sure what's wrong, and on top of it, I don't really know how to pinpoint it. For an example of what I mean, see here. Any hints or clues on this would be appreciated. I'm not even sure if I'm using the correct terminology here.


What does scannerless parsing have to do with the "Dangling Else Problem"?

I do not understand this sentence from the Wikipedia article on the Dangling Else problem: > [The Dangling Else problem] is a problem that often comes up in compiler > construction, especially scannerless parsing. Can someone explain to me how scannerless parsing techniques might exacerbate this problem? It seems to me that the problem is with the grammar -- since it's ambiguous -- not with the choice of parsing technique. What am I missing?


Is this really necessary for solving this problem?

I came across the following article which presents the problem: > A group of people walk into a restaurant and want to spend exactly $15.05 on > appetizers. They also want them as fast as possible. This leaves waiter with > an NP-hard problem to solve, a variation of knapsack problem. The article goes on to create some sort of "genetic algorithm" to solve the problem. My question is, is that really necessary? First of all, no programming solution would be possible if no combination of existing appetizers could equal $15.05. Right? Also, if I were approached with this problem, I would do something like this:               // loop through appetizers       // deduct price from total amount ($15.05) until the difference <= zero       // add to new array of appetizers          // sort the new appetizers array by "time to make the appetizer"     // return new appetizers array      Isn't it that simple? Thanks for your review.


Ways of developing for small system. What is expedient?

I'm developing a small system for internal automation. I use asp.net webforms and faced with a choice:   1. develop a system architecture in an object-oriented style (development becomes more difficult and time-consuming) or   2. just put controls on forms and write sql queries in control handlers (high speed development, the complexity of testing) Сurrently I'm using the first method, but starting to have doubts that my choice is correct. What way is expedient?


Priority value meaning

The library that I'm working on has a parameter which defines priority of a certain process. I want the interface to be as clear as possible, but it seems that different people have opposite interpretations of priority values.               1. Lowest number has highest priority (1 - highest priority, 10 - lowest priority)     2. Highest number has highest priority (1 - lowest priority, 10 - highest priority)      Which way do you think is more natural/logical?


What is the opposite of initialize (or init)?

The term will be used as a method name. The method is called when a part of the user interface is hidden (or removed), and it is used to reset values to default and dispose objects that will not be used any more. Possible names are: release, remove, dispose, clear etc. Which do you think is the most appropriate?


What is the most appropriate top level domain for a programmer's personal home page

Say you're a programmer and you have your personal home page (blog, about me, contacts, cv and so forth). Several top-devel domain names could apply to this situation. **.com** : This is an open TLD; any person or entity is permitted to register. Though originally intended for for-profit business entities, for a number of reasons it became the "main" TLD for domain names and is currently used by all types of entities including nonprofits, schools and private individuals. Domain name registrations may be challenged if the holder cannot prove an outside relation justifying reservation of the name, to prevent "squatting". **.pro** : Currently, .pro is reserved for licensed or certified lawyers, accountants, physicians and engineers in France, Canada, NL, UK and the U.S. A professional seeking to register a .pro domain must provide their registrar with the appropriate credentials. **.info** : This is an open TLD; any person or entity is permitted to register. **.name** : This is an open TLD; any person or entity is permitted to register; however, registrations may be challenged later if they are not by individuals (or the owners of fictional characters) in accordance with the domain's charter. Then, you obviously have the geographically local domains ( **.it, .co.uk** , etc.). Other domains are also often misused (for example **.me** , being Montenegro), just because they sound appropriate for a personal home page and they are usually cheaper than others. What would be the most appropriate choice for this situation?


Is it relevant to warn about truncating real constants to 32 bits?

I'm toying around with LLVM and looking at what it would take to make yet another strongly-typed language, and now that I'm around the syntax, I've noticed that it seems to be a pet peeve of strongly typed language to warn people that their real constants won't fit inside a `float`:               // both in Java and C#     float foo = 3.2;     // error: implicitly truncating a double into a float     // or something along these lines      Why doesn't this work in Java and C#? I know it's easy to add the `f` after the `3.2`, but is it really doing anything useful? Must I really be _that_ aware that I'm using single-precision reals instead of double-precision reals? Maybe I'm just missing something (which, basically, is why I'm asking). Note that `float foo = [const]` is not the same thing as `float foo = [double variable]`, where requiring the cast seems normal to me.


What is a clean Agile (Scrum) Sprint Presentation?

Suppose someone of your development team is presenting a sprint to the customer but he is having web connection problems such that a complete story cannot be presented. For the sake of the cleanness of the presentation, do you help your colleague suggesting possible solutions and try to fix it in the moment? Or is it kind of messy? May be the customer (who is "part" of the team) will understand? Why?


Flexible authorization design in ASP.NET pages?

I'm developing an ASP.NET webforms application with pages which displays information based on the authorization level of the authenticated user (very typical). I will write a simple example of the issue I'm facing: Let's pose I want to have a page with 4 buttons: 1- "OnlyForAdmins" button. 2- "OnlyForManagersAndAdmins" button 3- "Guest" button 4- "Authenticated" button Depending on the permission level of the visitor, one or several buttons must be displayed. Right now in code behind buttons are handled in the following way:               public void Page_Load(object sender, EventArgs e)     {         if (HttpContext.Current.User.Identity.IsAuthenticated)             Athenticated.Visible = true;         if (HttpContext.Current.User.IsInRole("Admins"))             OnlyForAdmins.Visible = true;         if (HttpContext.Current.User.IsInRole("Manager") || HttpContext.Current.User.IsInRole("Admins"))             OnlyForManagersAndAdmin.Visible = true;     }      While this works, honestly I think that this approach is rather inflexible, having to add more "ifs" for every new role I introduce. I wonder if there exist approaches to handle this kind of problems. I'd be grateful if someone can enlighten me. Thank you.


Http meta tag for refreshing/redirecting

I am not doing web programming usually, but while looking at the generated source of a webpage learned that a standard way to refresh a web page is to use `<meta http-equiv="refresh" content="_sec">`. I find this an abuse of "metadata" which for my understanding is supposed to be only "data about data" and not something to affect user experience (in this case I cannot imagine how often a page is refreshed qualifying as "data about data"). My questions are 1) Was this way of redirecting, a workaround because early days of html/browsers did not provide another standard way to redirect/refresh? 2) Is my idea/definition of "metadata" as strictly being a description of what the data is all about (like charset, type, keywords etc.) too narrow ?


Does it make sense to choose UTF-32, based on concern that some basic rule will be broken for UTF-8?

I'm working on an cross platform C++ project, which doesn't consider unicode, and need change to support unicode. There is following two choices, and I need to decide which one to choose.   * Using UTF-8 (std::string) which will make it easy to support posix system.   * Using UTF-32 (std::wstring) which will make it easy to call windows API. So for item #1 UTF8, the benefit is code change will not too many. But the concern is some basic rule will broken for UTF8, for example,   * string.size() will not equal the character length.   * search an '/' in path will be hard to implement (I'm not 100% sure). So any more experience? And which one I should choose?


Getting started with ClojureScript and Google Closure

I would like to investigate whether ClojureScript, with the associated Google Closure library is a reasonable tool to build modern, in-browser, Javascript applications. My current Javascript stack consists of jQuery, Backbone and RequireJS with the possible additions of some widgets libraries like jQueryUI or KendoUI. So it will be quite a big leap (I already know how to work in Clojure, although I have little experience). What is a good roadmap to do so? Should I learn the Google Closure library first, or can I grasp it together with ClojureScript? One thing I am concerned about is the overall application structure. Backbone is rather opinionated on how to organize your application. I am not sure whether Google Closure also includes some components to help with the design of the application. And, if this is the case, I do not know how to tell whether this structure will port to ClojureScript or a ClojureScript application will require a different organization anyway, and only use - say - the widgets and DOM manipulation features of Closure.


What standards to use in Business Process Modelling?

There are several approaches on how to model a business process in software applications (BPM software). For instance, a processes can be described in BPMN, EPC, IDEF0, SOMF, etc. Additionally, different process execution languages such as BPEL, RPC, Wf-XML are available. If I were to develop software for the BPM-market, which standards should I implement or focus on? Which standards are most suitable if my BPM software was going to be implemented in my client's IT-System?


Is MySQL viable for small-medium business applications

After having worked with a Microsoft stack - VB.Net, ASP.Net, SQL Server - for the past 10 years, we are now faced with having to develop an application for both Windows and Mac environments. It has been suggested that MySQL, for the database, is available on both platforms. I've been under the impression that MySQL is an open source project, but has recently been bought? / taken over? by Oracle. The MySQL web site seems to indicate that unless it is being used in another open source project, there are licencing fees to be paid, and the fees are in the order of other database costs - eg. SQL Server, Filemaker. Somebody has suggested that MySQL is free to use in a LAMP environment (but what about for a Windows Server?). Can somebody with deployed MySQL experience confirm or explain this, along with any other gotchas that might be pertinent?


Rewriting a Procedural PHP App - Should we use a framework?

We have an app that's currently only got about 120 users. The userbase will probably grow by 50% over the next 12 months - but we're going to have to separate storage etc. because we're looking at several TB of data. Later this year, we will move to cluster based hosting. The app will also be provided in multiple languages. I'm at a stage with the project now where we sometimes need to add additional features rather quickly, and whilst the building the app the way it is was a business decision (time and money was short then and we had to have something running fast), now we need to have multiple developers working on the application, and it's a little tough, even though we have everything templated and documented well. I have the opportunity to rewrite the application - we can build one team to simultaneously redo the codebase, whilst one team manages the existing application. Once the new version is caught up, we'll switch over to it. The question is- should we use a framework for this application. I've looked at Symfony and CodeIgnitor, and obviously the latter is easier with a smaller learning curve for our team. On the other hand, if we just re-architecture the application and build our own 'framework' and classes (I know, no need to reinvent the wheel, but we already have hundreds of functions written which seamlessley talk to our database). Now I've seen comments like 'if you want have an app you want to make a living with, use Symfony', but I just don't know how that works. I've made a living with WordPress websites before too, so that statement is, well, not helpful! Any advice, please. Developer resource is not a problem for us, but I don't particularly like the restrictions Symfony imposes in terms of directory names, etc. (but I guess this is just a matter of getting used to things). The thing is, I now have to make a business decision, ultimately, and I'd like to be able to justify it to my team. At this point, from my point of view, the only major benefit is that when we hire new developers, if they are familiar with the framework, their learning curve will be less. This logic supports Symfony, but to me it is not enough. Qualified opinions will help, please. Thanks!


Right Amount of Security on Machine

I am basically asking this question to see if I am being unreasonable. My current employer has locked down the machines of all developers so that we do not have access to the root or c: drive. For example, I cannot write a directory under C:. I also cannot install any software which touches the registry. Is this an extreme action or am I overreacting to common security measures? What is the extent of security on your company provided machine? To add some scope to this question, I am a web application developer and I'm talking about a laptop owned by the company.


What is your suggestion to write clean and well organized php code?

I am a php beginner coder. I always find myself in a mess when I try to alter or add something to my scripts. Because they are not well organized. So, I want to learn how to organize my code, so it becomes easy later on to change it. Also, there is a lot of code snippets that I use frequently in all of my scripts. Like the database codes. Is there is a way to arrange those snippets?


License for available for free, but closed source web app

Anyone know of a free license that offers the user the right to use the software freely, but not modify it or share it? In other words, it is closed source, but it's free. And since it's gonna be a website it can only be used on this one website. What would be a good simply license for this? If possible that it's not too long, simple as the MIT license for example.


Is it a good practice to use branches to maintain different editions of the same software?

We have a product that has a few different editions. The differences are minor: different strings here and there, very little additional logic in one, very little difference in logic in the other. When the software is being developed, most changes need to be added to each edition; however, there are a few that don't and a few that needs to differ. Is it a valid use of branches if I have release-editionA and release-editionB (..etc) branches? Are there any gotchas? Good practices? Update: Thanks for the insight everyone, lots of good answers here. The general consensus seems to be that it is a bad idea to use branches for this purpose. For anyone wondering, my final solution to the problem is to externalize strings as configuration, and externalize the differing logic as plugins or scripts.


Should I use a config file or database for storing business rules?

I have recently been reading The Pragmatic Programmer which states that: > Details mess up our pristine code—especially if they change frequently. > Every time we have to go in and change the code to accommodate some change > in business logic, or in the law, or in management's personal tastes of the > day, we run the risk of breaking the system—of introducing a new bug. > > Hunt, Andrew; Thomas, David (1999-10-20). The Pragmatic Programmer: From > Journeyman to Master (Kindle Locations 2651-2653). Pearson Education (USA). > Kindle Edition. I am currently programming a web app that has some models that have properties that can only be from a set of values, e.g. (not actual example as the web app data confidential): light->type = sphere / cube / cylinder The light type can only be the above three values but according to TPP I should always code as if they could change and place their values in a config file. As there are several incidents of this throughout the app, my question is: Should I store possibly values like these in:   * a config file: 'light-types' => array(sphere, cube, cylinder), 'other-type' => value, 'etc => etc-value   * a single table in a database with one line for each config item   * a database with a table for each config item (e.g. table: light_types; columns: id, name)   * some other way? Many thanks for any assistance / expertise offered.


Would I gain enough by reading these books or would you recommend some other?

I've been on this job for mere 5 years now. I feel like I've learned a lot in that time, and I continue to challenge myself whenever I can, even though my job doesn't allow that very often. Still, I feel like I've just started my professional career as a developer, and there is still much to learn. This is obviously true, being a developer is all about learning. So I've decided to order a book or two from this list: http://www.codinghorror.com/blog/2004/02/recommended-reading-for- developers.html These guys (Jeff et al.) must be doing something right, so I'm guessing Jeff's recommendations have some weight. I'm considering buying Code Complete and The Mythical Man Month since they are on top of the list, but I am not sure these two are the right choice. Would you recommend these two as a good learning/self-improvement books? Regardless of your answer, please state your reasons. I'm just curious if these two have a good ROI or should I just keep my money and buy tons of ice- cream. Some of the questions would be: are they still relevant? Will they _really_ make me a better developer? Feel free to recommend other books, or argue about other books on Jeff's list, but keep in mind my question about these two in particular :)


What's the best way to acknowledge many FOSS sources in a single project?

I have a project which uses a large number of LGPL, Artistic and other open- source licensed libraries. What's the canonical (i.e. the "standard") way of acknowledging multiple sources in a single project download? Also, some of the sources I've used are from sites where using the code is okay, but publishing the source isn't. What's the usual manner of attribution in that case, and the usual manner of making the source available in an open- source project?


Does The College Matter?

Does it matter all that much about what college you go to, to get a degree in computer programming/computer science? I didn't do all that well in high school, I actually barely graduated with a general High School Diploma. So getting into a decent college could be difficult. Companies won't deny you just because you got your degree at a college they have never heard of or a community college will they?


Databases and the single responsibility principle

Can the single responsibility principle be applied to databases? relational databases I mean. I'm asking this because a typical database will have several tables and we may find something like that between them:   * Tables handle ACL and permissions.   * Tables handle user authentication.   * Tables relating to cron jobs and scheduled tasks.   * Tables relating to the domain itself.   * Tables relating to emails and invitations and so on.   * Look ups. Moreover the tables relating to the domain might be divided according to the application module they back up. In code we usually divide our code base to modules/packages/namespaces, but that concept is absent from relational databases as far as I know. so what I'm asking should the database be divided somehow to smaller databases? or maybe database (modules?!) Or should we just lump everything together and hope for a good naming convention if any?!


How to document and teach others "optimized beyond recognition" computationally intensive code?

Occasionally there is the 1% of code that is computationally intensive enough that needs the heaviest kind of low-level optimization. Examples are video processing, image processing, and all kinds of signal processing, in general. **The goals are to document, and to teach the optimization techniques,** so that the code does not become unmaintainable and prone to removal by newer developers. (*) _(*) Notwithstanding the possibility that the particular optimization is completely useless in some unforeseeable future CPUs, such that the code will be deleted anyway._ Considering that software offerings (commercial or open-source) retain their competitive advantage by having the fastest code and making use of the newest CPU architecture, software writers often need to tweak their code to make it run faster while getting the same output for a certain task, whlist tolerating a small amount of rounding errors. Typically, a software writer can keep many versions of a function as a documentation of each optimization / algorithm rewrite that takes place. How does one make these versions available for others to study their optimization techniques? Related:   * Clean readable code vs fast hard to read code. When to cross the line?


How much C/C++ knowledge is needed for Objective-C/iPhone development?

First, a little background. I'm a .Net developer (C#) and have over 5 years experience in both web development and desktop applications. I've been wanting to look into iPhone development for some time now, but for one reason or another always got side tracked. I finally have a potential project on the horizon, and I'm now going full steam ahead learning this stuff. My question is this: I haven't done any C/C++ programming since my schooling days, I've been living in managed land ever since. How much knowledge if any is needed to be successful as an iOS developer? Obviously memory management is something that I'll have to be conscious about (although with iOS 5 there seems to be something called ARC which should make my life easier), but what else? I'm not just talking about the C API (for example, in order to get the sin of a number, I call the sin() function), that's what Google is for. I'm talking about fundamental C/C++ idioms that the average C# developer is unaware of.


Why put the business logic in the model? What happens when I have multiple types of storage?

I always thought that the business logic has to be in the controller and that the controller, since it is the 'middle' part, stays static and that the model/view have to be capsuled via interfaces. That way you could change the business logic without affecting anything else, program multiple Models (one for each database/type of storage) and a dozens of views (for different platforms for example). Now I read in this question that you should always put the business logic into the model and that the controller is deeply connected with the view. To me, that doesn't really make sense and implies that each time I want to have the means of supporting another database/type of storage I've to rewrite my whole model including the business logic. And if I want another view, I've to rewrite both the view and the controller. May someone explain why that is or if I went wrong somewhere?


How do I keep my classes in MVC from becoming bloated?

I'm not sure how I should have worded the question. If I have a Student and Classes database, and I have queries that involve both. Where do I put my queries? In one case, someone wants student information, and I query Students and Classes in my Student class, if I put it in Classes, I cross over to the Students, [edit] violating single responsibility. I thought I should only have queries for Students and queries for Classes in each class of this part of the Model layer, each utilized by services. Also, What do I do when I need new queries? I have this set of queries, then someone comes along and wants some special query. I then copy and paste and change one thing or add an if then or a switch, this gets multiplied across the class in my model _layer_ in multiple objects, giant switch statements, etc. That does not seem to be what Model layers should be composed of, giant Models with code everywhere, violating DRY. I have a service in one object in Students, `findAllClassesByStudent($student_id)` I call in my View perhaps, and another in Classes, `findAllStudentsInAParticularClass($class_id)`. Those are pretty close. I realize I can abstract yet more layers and isolate logic in some other layer, but I can't abstract forever, sooner or later I have what appears as some violation of OOP's encapsulation. ViewModel View, Abstracted Data Access Layer, the services, etc. and so on. If I do too little, then my objects are anemic. I've been reading a lot and while there is a lot of interpretations, I'm assuming I'm leaving all the business logic in the Model layer, not on the controller or the View. * * * Pseudo examples:               class Student extends Model {          private $student          public function __construct() {          }          public function getStudentByID($student_id){     ...SQL     }          public function getStudentClasses($student_id){  //first time          }                    }          class Classes extends Model {          public function __construct(){          }          public function findAllStudentsInAParticularClass($class_id){  //feels like bloat     ...SQL     }          }      This seems like duplication to me. Perhaps I haven't thought it through enough. I just know from experience there's always someone that wants slightly different queries, and I end up copying and pasting.


Why is Akka being marketed as reactive? Is Actor Model reactive?

As far as I understand the Actor Model and the Reactive Programming are separate concepts. Actor Model does not seem to be inherently reactive to me. However the Akka framework which is an Actor Model implementation is being described as reactive: > "Java and Scala program logic lives in lightweight Actor objects, which send > and receive messages in a reactive fashion." > > "We Are Reactive" Is it a case of misusing the term or they are completely correct? Is any actor model implementation (e.g. Erlang) already reactive? Is simply generating messages as a response to other messages considered reactive as well? Some related reading where the approaches are contrasted: http://stackoverflow.com/questions/20740114/rx-vs-messaging-queues-like- rabbitmq-or-zeromq http://cs.stackexchange.com/questions/9038/how-do-functional-reactive- programming-and-the-actor-model-relate-to-each-other http://lambda-the-ultimate.org/node/2203


Is there a design pattern for splitting up files into smaller files?

I am developing a project where I have to load very large files (upto 50 MB). Currently I am loading these files completely into (consecutive) memory. This has the advantage that I can very easily change bytes at certain locations, because I do not know the structure of all bytes. However, my intention is to also change the structure, e.g. removing/adding 'chunks'. Now I have the idea to remove the 'known' parts out of it, store them in classes with a data chunk only containing those parts and make a sort of reference list to those chunks. E.g.: Original file:   * Header   * ChunkA 1   * ChunkA 2    * Intermediate   * ChunkB 1   * Footer The result will be: ChunkA 1 and ChunkA 2 instance. ChunkB 1 instance 'File' instance and a reference with base offsets + reference to all chunks. At the end I have to 'recreate' or write the original file (with changes) back. Is this in general a good idea or is there some design pattern helping me in this?


Calculating NPath Complexity

I'm trying to calculate the NPath Complexity within a function, but I'm unsure what parts I count. My understanding is that it'll sum:   * If   * Else   * Else If   * Switch   * Case   * Default   * Do   * While Is this correct? Or am I missing something?


any document which says exactly what range of numbers are .NET BigIntegers designed for?

I'm playing around with the .NET BigInteger and basically I'm wondering what number _\--an estimated answer would be fine--_ is the point of deviation of the curve of (the graph of (increase of time required for operations) vs (value of BigInteger))? or are they designed with no such deviation such that if we plot the increase of time required for operations vs value of BigInteger from 1 to infinity, we will have a smooth curve all the way? for example, assuming arrays are designed with capability of handling 50 items . this means that if i have 1 item, operations are f(1) time. and when i have 2 items, operations are f(2) time. if i have 50 items, operations are f(50) time. but since it is designed for handling 50 items only, the operations done when we have 51 items will be g(51) where g(51) > f(51). > If implemented properly the complexity of BigInteger arithmetic should be a > smooth curve. For example the time complexity of multiplication should be > O(NM) where N is the number of digits in the first multiplicand, and M is > the number of digits in the second multiplicand. Of course there are > practical limits in that you could pick N and M so large that the numbers > wouldn't fit in your machine. Are there any / does anyone know of any documents claiming that it is implemented as such?


Security for data produced by ASP.NET web serivce

I'm developing an ASP.NET 2.0 web service that serves XML data from a database. Almost all data traffic is one-way, from server to client, and there is no user-specific data. All clients will receive the same data. But I only want approved clients to be able to consume the data. In this situation, what are the best options for encrypting the data produced by the web service?   * I've looked at SSL, but I've been told by management to find another way, so that we can either avoid the hassle of setting up an SSL certificate on the site or implement both SSL _and_ my solution.   * SOAP encryption has been suggested, but I want to have good support for iOS clients, and there does not appear to be SOAP support built into the iOS SDK or available open-source.   * Because no data is being modified server-side, and we have no user-specific data or user accounts, I don't think OAuth is necessary. It will become necessary in the future, but we'll cross that bridge when we come to it. Am I wrong here?   * I've suggested encrypting the content of the XML data so that `<Prop1>StringData</Prop1` becomes `<Prop1>EncryptedGarbageHere</Prop1>`, but I've been told that's not as secure an approach as SOAP encryption. EDIT: In either case, I'm also planning on adding a sort of "password" parameter that is required by all WebMethods in the web service, and will be required of each unique client application.


How to deal with low level guys?

Recently I have started working for company which is developing mainly low level stuff (like device drivers, system level apps etc.). I was hired as high level programmer to develop a machine learning system (details of this system are not so important). My problem is that my coworkers, that are all low level programmers, do not respect my job, because I am using high level techniques. They think that high level programming is easy and only low level requires skill and knowledge. This is quite unfair for me because writing a scalable machine learning system only by myself is not trivial task. How can I convey them that my work is also valuable? Or maybe I am wrong and low level programming is so hard that only gods can handle it? ;) What are your opinions about that?


What's the proper way to organize ViewControllers and XIB?

I am developing a very simple iPhone game with this view hierarchy:               Main Menu View       └> New Game View       |    └> Player vs Computer Game View       |    |    └> Pause View       |    |    └> End Turn View       |    |    └> End Game View       |    |        |    └> Player vs Player (offline) Game View       |         └> Pause View       |         └> End Turn View       |         └> End Game View       |       └> Information View      My current implementation has a single **`ViewController`** that controls every aspect of the user interface and a single **`XIB`** file that contains every **`View`** of the game.   Is this correct? It looks a bit confusing...   Should i have more **`ViewControllers`** and more **`XIB`** files? And what's the proper way to make them cooperate?


Authenticating users for a website

I'm working on a website and I want to validate that an individual is an employee at one of a large number of companies (probably using their company's email address, which I don't know before hand). The idea being some users are the general public and others are from these companies. And I need some way to authenticate that the users claiming to be employees are being honest while still having a friendly enough UI. I did an informal survey of people I know and the domains and emails will match in a majority of cases but they might not always match exactly so you might have a company with a website foo.com and an email billy@foobar.com (although foobar.com did redirect back to foo.com). And while I can easily check that I'm not sure what other variations might be out there (maybe fooLA.com and email billy@foolosangeles.com, etc.)


Should Unit Testing be used in Prototypes?

When constructing prototypes, should we also create appropriate unit tests as if we were writing production code? Would it make a difference if we knew in advance that the code **was** or **wasn't** going to be re-used for the final solution?


Coding standards and coding style, is it that much important?

There are a lot of ways of typing code, but I can't understand what is the good reason to adopt a certain standard or style if it does not change the way the code can be read and understood. Everyone can type code the way (s)he thinks it's better, but is there a really good reason to force all programmers for a certain style ? Does it really make a difference in the end ? Is it for pleasing the managing folks, or the control freaks ? Apart from this post about those very stupid coding standard, are there companies who encourage employees to choose what works for them ? EDIT: Wow thanks for the answers, the thing that made me post this is the BSD vs K&R brace style: this is a big issue, and this really made me rant.


What is the difference between a function and a component?

I just listened to Software engineering Radio podcast on components. Their description of components were very vague, they made them sound like lower level versions of functions. I am trying to figure out what components mean in the context of the composite pattern.   1. What is the difference in purpose between a function and a component?   2. What does a component have to do with the composite pattern?   3. Can you describe what a component is by using a funny metaphor? For example, explain how creating a component like baking an apple pie.


Why don't we store the syntax tree instead of the source code?

We have a lot of programming languages. Every language is parsed and syntax checked before being translated into code so an abstract syntax tree (AST) is built. We have this abstract syntax tree, why don't we store this syntax tree instead of the source code (or next to the source code)? By using an AST instead of the source code. Every programmer in a team can serialize this tree to any language they want (with the appropriate context free grammar) and parse back to AST when they are finished. So this would eliminate the debate about the coding style questions (where to put the { and }, where to put whitespace, indentation, etc.) What are the pros and cons of this approach?


Is it bad to learn multiple programming languages?

I started learning PHP and I was able to get myself familiar with it. Now, i want to explore other programming languages like PERL so that i can compare it myself to PHP. Will I be confused to learn two language? Or are there any disadvantages?